Simon Peyton Jones pushed to branch wip/case-bndr-unf at Glasgow Haskell Compiler / GHC Commits: cbe0a6bf by fendor at 2026-11-17T09:25:55-05:00 Add support for streaming `ghc -M` to stdout Adds the flags `-dep-json-stdout` and `-dep-makefile-stdout` which streams dependency information line-by-line to stdout. Each dependency generation can be redirected to separate outputs. Providing any extra `-dep-{json,makefile}[-stdout]` disables the default generation of the `Makefile` file. Allows consumers to start processing the dependency information as it comes in and not waiting for the dependency generation to finish. `DepStream` abstracts over the possible output handles, which is either a file or the stdout handle. Writing to a file requires temporary file paths, thus `DepStream` must provide a way to perform clean up when dependency processing finished or when an error is thrown for any reason. We further decouple the rendering and writing of the result from the dependency generation, localising side effects and making the code slightly more readable. The testsuite now also handles `ghc -M` writing to stdout. We add a test for each combination of writing to stdout and file, except for writing both makefile and json. While it probably works, is really undefined behaviour. Closes #27937 - - - - - fbd49db2 by Sylvain Henry at 2026-11-17T09:27:09-05:00 Link the on-demand iserv without --gc-sections GHC links an iserv program each time a session needs the external interpreter. The link is static, against the ghci library and the boot libraries. Like all executable links, it passed -Wl,--gc-sections to a GNU linker. On libraries built with -split-sections (the release bindists), the section garbage collection of ld.bfd is the largest part of that link: with binutils 2.45, the link takes 3 times longer with --gc-sections than without. The program is temporary and its size is not important. Thus the iserv link does not use --gc-sections. Other executable links do not change. In CI, each ext-interp or ghci-ext test takes 12 to 18 times longer in the x86_64-linux-fedora43-release test job (split sections) than in the x86_64-linux-deb13-validate test job (no split sections) on the same runner, while a normal-way test takes the same time in both. This link is most of that difference. See Note [No --gc-sections for the on-demand iserv] in GHC.Runtime.Interpreter.C. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> - - - - - 09c965e2 by mangoiv at 2026-11-17T09:27:51-05:00 ci: make tests-primops run on marge CI test primops dispatch was disabled on the *full-ci group label to avoid dispatching for some of its configs but wasn't reenabled for marge ci runs which it ought to run Fixes #27765 - - - - - 83038fbe by David Eichmann at 2026-11-17T09:28:32-05:00 test driver refactor: replace `.format(**locals())` with f-string - - - - - e7c958e9 by Simon Peyton Jones at 2026-11-18T16:21:29+00:00 Make pushCast pure, and move it to Simplify.Utils pushCast and pushCastMCo were in the SimplM monad, but no longer do anything monadic. (Historically, pushing a coercion into an argument used to simplify that argument; but now the coercion is recorded in the sc_cast field of ApplyToVal.) This patch makes them pure functions, and moves them, together with addCastMCo, optOutCoercion and Note [The sc_cast field of ApplyToVal], from GHC.Core.Opt.Simplify.Iteration to GHC.Core.Opt.Simplify.Utils, alongside the SimplCont type they manipulate. No change in behaviour. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> - - - - - c9af9996 by Simon Peyton Jones at 2026-11-18T16:21:29+00:00 Lambda and case binders have vanilla IdInfo (#27965) Lambda binders, case binders, and case-alternative binders should never have RULES, a (non-default) inline pragma, or a stable unfolding. See new Note [Core binder IdInfo invariants] in GHC.Core, which lays out the invariants. This patch * Makes Core Lint check the invariant, using the new predicate GHC.Types.Id.lamBndrInfoOK. * Fixes the desugarer, which violated it. For a strict binding let !x = rhs in body we generate let x = rhs in case x of x { DEFAULT -> body } re-using x (shadowed) as the case binder; see Note [Desugar Strict binds]. But the case binder inherited x's IdInfo, including, say, a NOINLINE pragma (e.g. `res1` in GHC.Internal.Control.Monad.ST.Lazy.Imp). Now GHC.HsToCore.Utils.seqVar gives the case binder vanilla IdInfo. This was not just a matter of taste. For example h fm s = let {-# NOINLINE res1 #-} !res1 = fm s !(f, s') = res1 in (f+1, s') The NOINLINE case binder becomes a NOINLINE alias `let res3 = res2`, which is never inlined, and survives (as a silly join point) into the final code. * Fixes the Simplifier, which could violate it when duplicating a StrictBind continuation, which makes a join point let x = <> in b ==> join j x = b in j <> If x has such IdInfo, we now use a fresh binder for the join point let x = <> in b ==> join j x' = let x = x' in b in j <> See (DSB1) in Note [Duplicating StrictBind]. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> - - - - - 044451ff by Simon Peyton Jones at 2026-11-18T16:21:29+00:00 Add varIsHNF, and use it in move_transit_vars `varIsHNF v` is the same as `exprIsHNF (Var v)`, but avoids building the Var only to take it apart. The (Var v) case of exprIsHNFlike now uses the shared varIsHNFlike, so the two cannot drift apart. In GHC.Core.Opt.WorkWrap.Utils.move_transit_vars we had the guard isUnliftedType var_ty || exprIsHNF (Var var) but exprIsHNF is already True of variables of (definitely) unlifted type, so the isUnliftedType test was redundant. Now it is just (varIsHNF var). No change in behaviour. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> - - - - - 840dd77f by Simon Peyton Jones at 2026-11-18T16:21:29+00:00 Use SimplClo for the argument of ApplyToVal This patch renames SimplSR to SimplClo (a "closure"), and uses it not only as the range of the Simplifier's substitution, but also as the argument of an ApplyToVal continuation. ApplyToVal used to have three fields sc_env :: StaticEnv sc_arg :: CoreExpr sc_cast :: MOutCoercion but now has just sc_dup :: DupFlag sc_arg :: SimplClo An un-simplified argument is (ContEx env arg mco), and an already-simplified one is (DoneEx arg _). See Note [The argument of ApplyToVal] in GHC.Core.Opt.Simplify.Utils. The main payoff is that, since the substitution maps an Id to a SimplClo, beta-reduction can substitute the argument for the lambda binder without further ado. Accordingly, preInlineUnconditionally is split into * preInlineLetUnconditionally, for let-bindings * preInlineBetaUnconditionally, for beta-redexes, which takes a SimplClo The latter omits some checks that cannot fire for lambda binders. Other notes * The new (ContEx env arg mco) form makes it easy to push a cast into an argument (mkCloCastMCo), whether or not it has been simplified. See Note [The MOutCoercion field of ContEx]. * `preInlineUnconditionally` gets split into two variants, one for let-bindings and one for beta-reduction (which takes a `SimplClo`). There is a little bit of duplication here, but not much. * Fixes #27962. The simplifier was previously dropping a cast when dealing with runRW#. The new `SimplClo` makes that bug much harder to allow. * Fixes #27963. contOutArgs, which supplies the arguments for Plan (BEFORE) rule matching, ignored the sc_cast field of ApplyToVal. So in (f |> co) n ==> f (n |> co1) -- co1 in sc_cast a rule for `f` saw `f n` rather than `f (n |> co1)`, and failed to match (the rule matcher checks the types of template variables). If f's unfolding is active, f may then be inlined, and the rule is lost for good. Now contOutArgs uses simplCloExpr, which includes the pending cast. Almost no change in behaviour, except for the #27963 bug-fix. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> - - - - - 4f143f95 by Simon Peyton Jones at 2026-11-18T16:21:29+00:00 wibble Iteration.hs [skip ci] - - - - - 2df59907 by Simon Peyton Jones at 2026-11-18T16:21:29+00:00 Wibble - - - - - dd6ed8b6 by Simon Peyton Jones at 2026-11-18T16:21:29+00:00 Add splitThunkCpr Needs documentation Also be willing to lose CPR or strictness info for StrictBind, when (but only when) we need to duplicate. ToDo: re `useStrictBind` * Explain why we accept losing strictness info: let f* {- Str=<S> =} = case x of { True -> f1; False -> f2 } in body If f1 and f2 are both strict, then f is too. NB: we can't do w/w on thunks. But at least calls to f in `body` will be CBV. But if we make a join point we might get join j f* = ...body... in case x of { True -> j f1; False -> j f2 } Now calls to f in body are not CBV. But in exchange, we don't get a thunk for f. * Explain why we do *not* want to inhibit StrictBind for a thunk with CPR info e.g. f a b c xs = let y = case xs of [0] -> Just a [1] -> Just b _ -> Just c in h y (case y of Just z -> <big> Nothing -> xs++xs) where h is strict in y. We can't * NB if we have f* = \x. blah, using the StrictBind path won't lose anything, becuase we won't duplicate the continuation. So the `useStrictBind` choice doesn't matter for RHS's that are lambdas. - - - - - 41 changed files: - .gitlab-ci.yml - + changelog.d/T27962 - + changelog.d/T27963 - + changelog.d/iserv-no-gc-sections.md - + changelog.d/make-depends-streaming-output - compiler/GHC/Core.hs - compiler/GHC/Core/Lint.hs - compiler/GHC/Core/Opt/CprAnal.hs - compiler/GHC/Core/Opt/Simplify/Env.hs - compiler/GHC/Core/Opt/Simplify/Iteration.hs - compiler/GHC/Core/Opt/Simplify/Utils.hs - compiler/GHC/Core/Opt/SpecConstr.hs - compiler/GHC/Core/Opt/WorkWrap.hs - compiler/GHC/Core/Opt/WorkWrap/Utils.hs - compiler/GHC/Core/Ppr.hs - compiler/GHC/Core/Utils.hs - compiler/GHC/Driver/DynFlags.hs - compiler/GHC/Driver/MakeFile.hs - compiler/GHC/Driver/Session.hs - compiler/GHC/HsToCore/Utils.hs - compiler/GHC/Linker/Executable.hs - compiler/GHC/Runtime/Interpreter/C.hs - compiler/GHC/Types/Cpr.hs - compiler/GHC/Types/Id.hs - docs/users_guide/separate_compilation.rst - testsuite/driver/my_typing.py - testsuite/driver/testglobals.py - testsuite/driver/testlib.py - testsuite/tests/driver/mkdepend/all.T - testsuite/tests/driver/mkdepend/mkdepend_mhu01.dep-json → testsuite/tests/driver/mkdepend/mkdepend_mhu01a.dep-json - testsuite/tests/driver/mkdepend/mkdepend_mhu01.dep-makefile → testsuite/tests/driver/mkdepend/mkdepend_mhu01a.dep-makefile - + testsuite/tests/driver/mkdepend/mkdepend_mhu01b.stderr - + testsuite/tests/driver/mkdepend/mkdepend_mhu01c.stderr - + testsuite/tests/driver/mkdepend/mkdepend_mhu01d.dep-makefile - + testsuite/tests/driver/mkdepend/mkdepend_mhu01d.stderr - testsuite/tests/simplCore/should_compile/T15445.stderr - + testsuite/tests/simplCore/should_compile/T27962.hs - + testsuite/tests/simplCore/should_compile/T27963.hs - + testsuite/tests/simplCore/should_compile/T27963.stderr - + testsuite/tests/simplCore/should_compile/T27965.hs - testsuite/tests/simplCore/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/a23a6e8d0f876737a372a48ca3a2221... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a23a6e8d0f876737a372a48ca3a2221... You're receiving this email because of your account on gitlab.haskell.org. Manage all notifications: https://gitlab.haskell.org/-/profile/notifications | Help: https://gitlab.haskell.org/help
participants (1)
-
Simon Peyton Jones (@simonpj)