Simon Peyton Jones pushed to branch wip/T20264 at Glasgow Haskell Compiler / GHC
Commits:
29c0aceb by Simon Peyton Jones at 2026-01-16T17:18:11-05:00
Improve newtype unwrapping
Ticket #26746 describes several relatively-minor shortcomings of newtype
unwrapping. This MR addresses them, while also (arguably) simplifying
the code a bit.
See new Note [Solving newtype equalities: overview]
and Note [Decomposing newtype equalities]
and Note [Eager newtype decomposition]
and Note [Even more eager newtype decomposition]
For some reason, on Windows only, runtime allocations decrease for test
T5205 (from 52k to 48k). I have not idea why. No change at all on Linux.
I'm just going to accept the change. (I saw this same effect in another
MR so I think it's a fault in the baseline.)
Metric Decrease:
T5205
- - - - -
8b59e62c by Andreas Klebinger at 2026-01-16T17:18:52-05:00
testsuite: Widen acceptance window for T5205.
Fixes #26782
- - - - -
9e5e0234 by mangoiv at 2026-01-17T06:03:03-05:00
add a new issue template for getting verified
To reduce spam created by new users, we will in future not grant
any rights but reporting issues to new users. That is why we will
have to be able to verify them. The added issue template serves that
purpose.
- - - - -
b18b2c42 by Cheng Shao at 2026-01-17T06:03:44-05:00
llvm: fix split sections for llvm backend
This patch fixes split sections for llvm backend:
- Pass missing `--data-sections`/`--function-sections` flags to
llc/opt.
- Use `@llvm.compiler.used` instead of `@llvm.used` to avoid sections
being unnecessarily retained at link-time.
Fixes #26770.
-------------------------
Metric Decrease:
libdir
size_hello_artifact
size_hello_unicode
-------------------------
Co-authored-by: Codex
- - - - -
ebf66f67 by Cheng Shao at 2026-01-17T13:16:50-05:00
Update autoconf scripts
Scripts taken from autoconf a2287c3041a3f2a204eb942e09c015eab00dc7dd
- - - - -
598624b9 by Andreas Klebinger at 2026-01-17T13:17:32-05:00
CString.hs: Update incorrect comment.
Fixes #26322
- - - - -
eea2036b by Cheng Shao at 2026-01-18T10:00:49-05:00
libraries: bump haskeline submodule to 0.8.4.1
This patch bumps the haskeline submodule to 0.8.4.1 which includes an
important fix for an ANSI handling bug on Windows
(https://github.com/haskell/haskeline/pull/126).
- - - - -
87d8f6c2 by Cheng Shao at 2026-01-18T10:01:30-05:00
hadrian: replace default -H32m/-H64m with -O64M to improve mutator productivity
Most hadrian build flavours pass `-H32m`/`-H64m` to GHC as
conventional wisdom to improve mutator productivity and reduce GC
overhead. They were inherited from the legacy Make build system, and
there used to be make flags to instrument a build process with
`-Rghc-timing` option to collect GC stats of each GHC run from stderr.
It's time to revisit whether there are better defaults for
`-H32m`/`-H64m`, and this patch changes it to `-O64M` which indeed
improves mutator productivity based on real statistics. `-O64M` is
more aggressive than `-H64m`; it allows the old generation to grow to
at least 64M before triggering major GC and reduces major GC runs.
The stats of a clean build with `validate` flavour and `-H64m`:
```
h64m.log
matched RTS stat lines: 5499
sum MUT cpu : 2400.808 s
sum GC cpu : 1378.292 s
sum MUT elapsed : 2788.253 s
sum GC elapsed : 1389.233 s
GC/MUT cpu ratio : 0.574 (GC is 57.4% of MUT)
GC/MUT elapsed ratio : 0.498 (GC is 49.8% of MUT)
GC fraction of (MUT+GC) cpu : 36.5%
GC fraction of (MUT+GC) elapsed : 33.3%
per-line GC/MUT cpu ratio: median 0.691, p90 1.777
per-line GC/MUT elapsed ratio: median 0.519, p90 1.081
```
The stats of a clean build with `validate` flavour and `-O64M`:
```
o64m.log
matched RTS stat lines: 5499
sum MUT cpu : 2377.383 s
sum GC cpu : 1127.146 s
sum MUT elapsed : 2758.857 s
sum GC elapsed : 1135.587 s
GC/MUT cpu ratio : 0.474 (GC is 47.4% of MUT)
GC/MUT elapsed ratio : 0.412 (GC is 41.2% of MUT)
GC fraction of (MUT+GC) cpu : 32.2%
GC fraction of (MUT+GC) elapsed : 29.2%
per-line GC/MUT cpu ratio: median 0.489, p90 1.099
per-line GC/MUT elapsed ratio: median 0.367, p90 0.806
```
Mutator time is roughly in the same ballpark, but GC CPU time has
reduced by 18.22%, and mutator productivity has increased from 63.5%
to 67.8%.
- - - - -
8372e13d by Cheng Shao at 2026-01-18T10:02:12-05:00
rts: remove unused .def files from rts/win32
This patch removes unused .def files from `rts/win32`, given we don't
build .dll files for rts/ghc-internal/ghc-prim at all. Even when we
resurrect win32 dll support at some point in the future, these .def
files still contain incorrect symbols anyway and won't be of any use.
- - - - -
f6af485d by Cheng Shao at 2026-01-18T10:03:19-05:00
.gitmodules: use gitlab mirror for the libffi-clib submodule
This patch fixes .gitmodules to use the gitlab mirror for the
libffi-clib submodule, to make it coherent with other submodules that
allow ghc developers to experiment with wip branches in submodules for
ghc patches. Fixes #26783.
- - - - -
41432d25 by Cheng Shao at 2026-01-18T10:05:13-05:00
hadrian: remove the horrible i386 speedHack
When hadrian builds certain rts objects for i386, there's a horrible
speedHack that forces -fno-PIC even for dynamic ways of those objects.
This is not compatible with newer versions of gcc/binutils as well as
clang/lld, and this patch removes it. Fixes #26792.
- - - - -
323eb8f0 by Cheng Shao at 2026-01-18T21:48:19-05:00
hadrian: enable split sections for cross stage0
This patch fixes a minor issue with `splitSectionsArgs` in hadrian:
previously, it's unconditionally disabled for stage0 libraries because
it's not going to be shipped in the final bindists. But it's only true
when not cross compiling. So for now we also need to enable it for
cross stage0 as well.
- - - - -
3fadfefe by Andreas Klebinger at 2026-01-18T21:49:01-05:00
RTS: Document -K behaviour better
- - - - -
75be3485 by Joseph Fourment at 2026-01-19T23:29:55+00:00
Add type-lets into Core
The plan for #20264 is to introduce let-bound types to have observable sharing in types.
To avoid the need to carry an environment when dealing with occurrences of these type variables,
we embed the types they're bound to (if any) in a `tv_unfolding :: Maybe Type` attribute.
This way, one can look through let-bound type variables using `coreView` and friends.
In particular, definitional equality looks through unfoldings.
simple-opt: don't inline type-lets
specialise: fix type-lets in DFun unfoldings
During specialisation, a dictionary being specialised gets a new unfolding by turning
`DFun \ bndrs -> MkD @<T1> ... @<Tm> <op1> ... <opn>` into
`DFun \ spec_bndrs -> MkD @((\ bndrs -> TYPE: <T1>) spec_args) ... ((\ bndrs -> <opn>) spec_args)`
which in turns gets beta-reduced into
`DFun \ spec_bndrs -> MkD (let { bndrs = spec_args } in TYPE: <T1>) ... (let { bndrs = spec_args } in <opn>)`.
Previously, such let binders would immediately be substituted into the type so it didn't cause any issue,
but now we want to avoid inlining.
Arguments of the form `let { bndrs = spec_args } in TYPE: <T1>` are not considered as type arguments since they're
not of the canonical form `TYPE: something`.
This commit restores the previous behavior of substituting the specialised type arguments.
Alternatively, we could attach some floated type bindings to `DFun`s.
occur-anal: implement occurence analysis for type variables
In order to find out let-bound type variables that are used only once, in the hope of inlining them,
we need to track type variables as well in the occurrence analiser. Just like Id's, we attach an
`OccInfo` to each (immutable) type variable, and we walk into types and coercions to accurately gather
occurrences.
simplifier: don't inline type-lets
Keep propagating type-lets further down the pipeline, in the simplifier.
We also update CallArity, CprAnal, DmdAnal, WorkWrap, and Specialise to ignore type-lets.
prep: make type-lets pass through CorePrep
As a first attempt, ignore type-lets in CorePrep to avoid crashes.
However, this is not enough: CorePrep also does some let-floating.
If we don't float type-lets along with value-level let-bindings,
the latter can float out of the scope of a type variable in use.
simple-opt: fix simple_type_bind
Also:
- Inline small types using a new typeIsSmallEnoughToInline predicate
- Inline single-occurrence variables
simple-opt: make beta-reduction use simple_bind_type
iface: add IfaceTypeLetBndr to represent non-top-level type-let binders
IfaceLetBndr isn't fit to represent type-let binders, as it includes a
bunch of vacuous flags for Ids only.
Instead of putting squares in circles, I added a new constructor for type binders.
The downside is that it breaks existing iface files, so since we can't bootstrap
yet so we have to bootstrap a cherry-picked branch and then checkout again to build
with --freeze1.
To avoid similar issues in the future, IfaceTyVarInfoItem serialises with a tag
despite there being only one constructor for now.
dmd-anal: prefix unused variable with _ to avoid warning
type: inline unfoldView in sORTKind_maybe
tidy: deal with type-lets
notes: add Note [Type and coercion lets]
notes: update Note [Comparing nullary type synonyms] to account for type variables
While updating backlinks, I noticed the optimisation for type variables
could be performed in more places.
simplifier: inline single-occurring type-lets
cleanup: remove NOINLINE on tyVarOccInfo
Wibbles
Wibbles
Progress
Progress
More progress
Progress
...doesn't compile though
Mostly working now
Aggressively create type-lets
more progress
More progress
Temp debug printing
Remove bogus assert
Fix anoher couple of bugs
in SimpleOpt and exprIsTrivial
Improve zonking of foreign decls to avoid TcTyVars escaping
Wibbles
Some small wibbles
Improvements
Rmmove trace
Wibbles
Use lambda, not let, in WorkWrap
Using type let did not work right with type lets and shadowing
Requires Lint to be OK join points under beta redexes -- but it is!
Needs better documentation
Wibbles
More improvements
More improvements
* Less cloning in SpecConstr
* Lint checks RULES for imported binders
Comments only
Wibble
Wibbles
Wibbles
.. getting Lint errors when compiling GHC.Internal.Classes
Wibbles
More improvements
..now getting to the back end an interface file generation
Wibbles
Wibble unsed var
Missing case in tyThingEntityInfo
Add IfaceExtTyVar
Wibbles
Start to make OccAnal count TyCoVars properly [skip ci]
Proper occurrence analysis for TyCoVars
Wibble imports
Wibble imports again
Fix two tricky buglets
More small fixes
Add missing mkAbsCoreApps
...which caused bad Lint errors
More wibbles
More wibbles exp around mkPolyAbsLams
- - - - -
1452180a by Simon Peyton Jones at 2026-01-19T23:29:55+00:00
Make it compile again
- - - - -
621e545b by Simon Peyton Jones at 2026-01-19T23:29:55+00:00
Simplify mkcoreAbsLams a bit
..Needs documentation
- - - - -
08bf5d7c by Simon Peyton Jones at 2026-01-19T23:29:55+00:00
Fix build
Several important fixes, need better docs
- - - - -
1e0811d8 by Simon Peyton Jones at 2026-01-19T23:29:56+00:00
Wibbles
- - - - -
4d2e80d9 by Simon Peyton Jones at 2026-01-19T23:29:56+00:00
Make it compile
- - - - -
695308fe by Simon Peyton Jones at 2026-01-19T23:29:56+00:00
Improve Lint error message slightly
- - - - -
3cc57d6f by Simon Peyton Jones at 2026-01-19T23:29:56+00:00
Wibble lint rules
- - - - -
675ecbc1 by Simon Peyton Jones at 2026-01-19T23:29:56+00:00
Wibbles
- - - - -
f4f35f69 by Simon Peyton Jones at 2026-01-19T23:29:56+00:00
Wibbles
- - - - -
131 changed files:
- + .gitlab/issue_templates/get-verified.md
- .gitmodules
- compiler/GHC/CmmToLlvm.hs
- compiler/GHC/CmmToLlvm/Base.hs
- compiler/GHC/Core.hs
- compiler/GHC/Core/Coercion/Axiom.hs
- compiler/GHC/Core/DataCon.hs
- compiler/GHC/Core/FVs.hs
- compiler/GHC/Core/FamInstEnv.hs
- compiler/GHC/Core/Lint.hs
- compiler/GHC/Core/Make.hs
- compiler/GHC/Core/Opt/Arity.hs
- compiler/GHC/Core/Opt/CSE.hs
- compiler/GHC/Core/Opt/CallArity.hs
- compiler/GHC/Core/Opt/CprAnal.hs
- compiler/GHC/Core/Opt/DmdAnal.hs
- compiler/GHC/Core/Opt/Exitify.hs
- compiler/GHC/Core/Opt/FloatIn.hs
- compiler/GHC/Core/Opt/OccurAnal.hs
- compiler/GHC/Core/Opt/SetLevels.hs
- compiler/GHC/Core/Opt/Simplify.hs
- compiler/GHC/Core/Opt/Simplify/Env.hs
- compiler/GHC/Core/Opt/Simplify/Iteration.hs
- compiler/GHC/Core/Opt/Simplify/Monad.hs
- compiler/GHC/Core/Opt/Simplify/Utils.hs
- compiler/GHC/Core/Opt/SpecConstr.hs
- compiler/GHC/Core/Opt/Specialise.hs
- compiler/GHC/Core/Opt/WorkWrap.hs
- compiler/GHC/Core/Opt/WorkWrap/Utils.hs
- compiler/GHC/Core/Ppr.hs
- compiler/GHC/Core/Predicate.hs
- compiler/GHC/Core/Rules.hs
- compiler/GHC/Core/Seq.hs
- compiler/GHC/Core/SimpleOpt.hs
- compiler/GHC/Core/Subst.hs
- compiler/GHC/Core/Tidy.hs
- compiler/GHC/Core/TyCo/Compare.hs
- compiler/GHC/Core/TyCo/FVs.hs
- compiler/GHC/Core/TyCo/Ppr.hs
- compiler/GHC/Core/TyCo/Ppr.hs-boot
- 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/Core/Unfold/Make.hs
- compiler/GHC/Core/Unify.hs
- compiler/GHC/Core/Utils.hs
- compiler/GHC/CoreToIface.hs
- compiler/GHC/CoreToStg.hs
- compiler/GHC/CoreToStg/Prep.hs
- compiler/GHC/Driver/Config/Core/Lint.hs
- compiler/GHC/Driver/DynFlags.hs
- compiler/GHC/Driver/Flags.hs
- compiler/GHC/Driver/Pipeline/Execute.hs
- compiler/GHC/Driver/Session.hs
- compiler/GHC/HsToCore/Binds.hs
- compiler/GHC/HsToCore/Monad.hs
- compiler/GHC/HsToCore/Pmc/Solver.hs
- compiler/GHC/HsToCore/Pmc/Utils.hs
- compiler/GHC/Iface/Decl.hs
- compiler/GHC/Iface/Ext/Types.hs
- compiler/GHC/Iface/Ext/Utils.hs
- compiler/GHC/Iface/Rename.hs
- compiler/GHC/Iface/Syntax.hs
- compiler/GHC/Iface/Tidy.hs
- compiler/GHC/Iface/Type.hs
- compiler/GHC/IfaceToCore.hs
- compiler/GHC/Tc/Deriv.hs
- compiler/GHC/Tc/Deriv/Infer.hs
- compiler/GHC/Tc/Errors.hs
- compiler/GHC/Tc/Errors/Ppr.hs
- compiler/GHC/Tc/Gen/Bind.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/Instance/Family.hs
- compiler/GHC/Tc/Solver/Equality.hs
- compiler/GHC/Tc/Solver/Monad.hs
- compiler/GHC/Tc/Solver/Rewrite.hs
- compiler/GHC/Tc/TyCl.hs
- compiler/GHC/Tc/Types/BasicTypes.hs
- compiler/GHC/Tc/Types/Constraint.hs
- compiler/GHC/Tc/Utils/Env.hs
- compiler/GHC/Tc/Utils/TcMType.hs
- compiler/GHC/Tc/Utils/Unify.hs
- compiler/GHC/Tc/Zonk/TcType.hs
- compiler/GHC/Tc/Zonk/Type.hs
- compiler/GHC/Types/Basic.hs
- compiler/GHC/Types/Id.hs
- compiler/GHC/Types/Id/Info.hs
- compiler/GHC/Types/Id/Make.hs
- compiler/GHC/Types/TyThing.hs
- compiler/GHC/Types/TypeEnv.hs
- compiler/GHC/Types/Var.hs
- compiler/GHC/Utils/Outputable.hs
- compiler/GHC/Utils/Trace.hs
- compiler/Language/Haskell/Syntax/Decls.hs
- config.guess
- config.sub
- docs/users_guide/runtime_control.rst
- hadrian/doc/flavours.md
- hadrian/src/Settings/Builders/SplitSections.hs
- hadrian/src/Settings/Default.hs
- hadrian/src/Settings/Flavours/Benchmark.hs
- hadrian/src/Settings/Flavours/Development.hs
- hadrian/src/Settings/Flavours/GhcInGhci.hs
- hadrian/src/Settings/Flavours/Performance.hs
- hadrian/src/Settings/Flavours/Quick.hs
- hadrian/src/Settings/Flavours/QuickCross.hs
- hadrian/src/Settings/Flavours/Quickest.hs
- hadrian/src/Settings/Flavours/Validate.hs
- hadrian/src/Settings/Packages.hs
- libraries/ghc-internal/src/GHC/Internal/CString.hs
- libraries/haskeline
- − rts/win32/libHSffi.def
- − rts/win32/libHSghc-internal.def
- − rts/win32/libHSghc-prim.def
- testsuite/tests/deriving/should_fail/T8984.stderr
- testsuite/tests/deriving/should_fail/deriving-via-fail.stderr
- testsuite/tests/deriving/should_fail/deriving-via-fail4.stderr
- testsuite/tests/deriving/should_fail/deriving-via-fail5.stderr
- testsuite/tests/perf/should_run/all.T
- + testsuite/tests/typecheck/should_compile/T26746.hs
- testsuite/tests/typecheck/should_compile/all.T
- testsuite/tests/typecheck/should_fail/T15801.stderr
- testsuite/tests/typecheck/should_fail/T22924b.stderr
- testsuite/tests/typecheck/should_fail/TcCoercibleFail.hs
- testsuite/tests/typecheck/should_fail/TcCoercibleFail.stderr
- testsuite/tests/typecheck/should_fail/all.T
- utils/haddock/haddock-api/src/Haddock/Convert.hs
The diff was not included because it is too large.
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/24d8bb95e142ad124f62e397dd88bbd...
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/24d8bb95e142ad124f62e397dd88bbd...
You're receiving this email because of your account on gitlab.haskell.org.