-
2349dd26
by Simon Peyton Jones at 2026-11-26T21:19:27-05:00
Use a different herald for -ddump-simpl-trace
... so that we can more easily skip the high-volume ones
-
03b1faab
by Simon Peyton Jones at 2026-11-26T21:19:27-05:00
Update comments and user manual
This commit addresses the comment-related suggestions in #27973
-
24055252
by Simon Peyton Jones at 2026-11-26T21:19:27-05:00
Document and refactor eta-reduction documentation
Triggered by #27212, this patch does several related things.
* #27212 suggested that `findRhsArity` should ask for eta-expansion
whenever the RHS's `manifestArity` is less than the arity it finds.
That is a misconception: it deliberately compares with `exprArity`,
which counts PAPs, so that we do not eta-expand PAPs (#9020).
Switching to `manifestArity` makes compile time worse in T13960
and T13056.
So this patch changes no code here; we continue to expand only to
increase `exprArity` not `manifestArity`. Instead it documents the
design in `findRhsArity`, `tryEtaExpandRhs`, `wantEtaExpansion` and
Note [Do not eta-expand PAPs] (which now records the #27212
experiment).
* Refactor GHC.Core.Opt.Arity.tryEtaReduce, which was hard to
understand:
- Accumulate an MCoercion rather than a Coercion, so the common
no-cast case builds no coercions at all.
- Separate equations of `go` for type and value arguments. For
value arguments, the new `getTrivialHead_maybe` looks through any
nesting of casts and floatable ticks, and `mkEtaReduceFunCo` builds
the coercion.
- Make the FunCo with `mkFunCo2` and compute its right-hand
FunTyFlag from the coercion kinds. The cast can turn a Type-kinded
argument into a Constraint-kinded one. New test T27212 covers this.
- `mkEtaReduceForAllMCo` builds the ForAllCo for type arguments. It
is tiresomely similar to `mkEtaForAllMCo`, but with the visibilities
the other way round (#24014). It will go away again once !17006
lands.
- New helper `mCoToCo` in GHC.Core.TyCo.Make.
* Drop the checks on multiplicity in `tryEtaReduce`, which sometimes
disabled eta-reduction. For example, (\x. K x) has type Int -> T,
but the data constructor has type K :: Int %1 -> T, so we used to
refuse to eta-reduce it to K.
But Note [Linting linearity] in GHC.Core.Lint (EXAMPLE 4) already
says that we do not preserve linearity under eta-reduction, so this
change just puts that claim into practice. See (EtaMult) in
Note [Eta reduction soundness].
Consequences in the testsuite:
- T18052a: the pattern-synonym builder (\x y. (x,y)) is now just (,).
- T21888a: the NOINLINE function (f x = Just x) becomes (f = Just),
so f loses its CPR signature. The test is about demands, not CPR.
* Tidy up the documentation of eta-reduction:
- Relabel the criteria in Note [Eta reduction soundness] as (EtaA),
(EtaS), (EtaR), (EtaE), (EtaT), (EtaJ), (EtaB) and (EtaW), and
update all references to them. Also fix references to point (2) of
Note [Eta reduction makes sense], which no longer exists.
- Replace the confused "never reduce arity" bullet with an example in
(EtaA), cross-referenced from Note [Arity robustness].
- Add historical notes (EtaMult) and (EtaBot).
- Label the equations in Note [Eta reduction with casted arguments]
(ECA1-4), and point to the code that implements them.
LLM disclosure: I interacted with Claude a lot for this MR, but I
wrote all the code and docs myself.
-
e02a40c5
by Zubin Duggal at 2026-11-26T21:20:10-05:00
linker: Remove DotA and DotDLL constructors of LinkablePart
As far as I can, we have never actually used these constructors,
and they have never appeared in a positive position, ever since they
were introduced a long time ago.
Foreign libraries aren't loaded through these either, that happens either
through `loadPackages` which uses `LibrarySpec` or through 'loadCmdLineLibs'
Also, a Linkable defines the build product of a single home module. DotA/DotDLL
are library like things, so they don't fit into a Linkable anyway.
-
56ae5186
by Zubin Duggal at 2026-11-26T21:20:10-05:00
Identify Linkable with fingerprints of their contents rather than modtimes
-
3b1fe950
by Zubin Duggal at 2026-11-26T21:20:10-05:00
Linker cleanup
delete a bunch of unused functions
-
8f2d4513
by Zubin Duggal at 2026-11-26T21:20:10-05:00
Record constituent hashes for bytecode libraries
A bytecode library now records the combined hash of its constituents,
so relinking can be skipped when they haven't changed.
-
bd43176e
by Zubin Duggal at 2026-11-26T21:20:10-05:00
bytecode: Give persistent bytecode files a fixed-size header with a hash
The header of .gbc and .bytecodelib files now consists of the magic word,
the compiler version and a hash, all with fixed-length encodings. The hash
is the gbc_hash of a bytecode file, or the inputs hash of a bytecode
library.
readBinByteCodeHash and readBytecodeLibInputsHash now read only the header
rather than the whole file. The version is written as its four numeric
components instead of as a string.
-
c62000f2
by Zubin Duggal at 2026-11-26T21:20:10-05:00
driver: Refresh ms_bytecode_date when reusing a ModSummary
-
f979f719
by Zubin Duggal at 2026-11-26T21:20:10-05:00
bytecode: Treat persistent bytecode files with a bad header as stale
-
cf85181f
by Zubin Duggal at 2026-11-26T21:20:10-05:00
bytecode: Record the inputs hash in BytecodeLib
-------------------------
Metric Increase:
MultiLayerModulesRecomp
MultiLayerModulesTH_Make
MultiLayerModulesTH_OneShot
-------------------------
-
2948aea2
by Simon Jakobi at 2026-11-26T21:20:52-05:00
X86 NCG: use bt for single-bit tests
Previously the Cmm patterns
(x & (1 << i)) != 0
(x & (1 << i)) == 0
compiled to a mov/shl/and/test sequence. Now they compile to a single
bt, followed directly by a jc/jae or setc/setae.
As with btr/bts/btc, a literal single-bit mask that doesn't fit in an
imm32, such as x & 0x10000000000, is now also tested with bt instead of
being loaded into a register first.
Data.Bits.testBit doesn't benefit yet when the bit index is variable:
its bounds-checked shiftL wraps the shift in a mask that blocks this
optimization.
See Note [Bit-test instructions] in GHC.CmmToAsm.X86.CodeGen.
Fixes #27688.
Assisted-by: Claude Fable 5.1
-
d7206efa
by Simon Jakobi at 2026-11-26T21:21:33-05:00
ci: Anchor the release branch pattern
Branches with `ghc-X.Y` anywhere in their name, such as
wip/ghc-9.16-backports, were treated as release branches. Each push
started a full-ci branch pipeline next to the merge request pipeline,
and its jobs pushed perf notes.
Fixes #28172.
Assisted-by: Claude Fable 5.2
-
c3e21ac0
by Simon Jakobi at 2026-11-26T21:21:33-05:00
ci: Fix the release branch pattern of lint-submods-branch
The pattern had `[0.9]` for `[0-9]`, so the job didn't run on ghc-10.0.
Also anchor the pattern (#28172).
Assisted-by: Claude Fable 5.2
-
03036aef
by Simon Jakobi at 2026-11-26T21:22:15-05:00
ci: Retry some failed jobs automatically
Let GitLab retry a job up to twice when it fails with one of these
reasons:
- runner_system_failure: the runner could not run the job. This is
nearly always an image pull that fails before the job starts.
- stuck_or_timeout_failure: GitLab dropped the job, either because
its runner stopped reporting for an hour or because no runner
picked it up within a day.
Assisted-by: Claude Fable 5.2
-
e8139c28
by Simon Jakobi at 2026-11-26T21:22:56-05:00
Correct some comments about unreachable Cmm blocks
* ContFlowOpt claimed that maybe_concat drops every block that has no
predecessors left. But a block that loses its predecessors to
shortcutting stays in the graph.
* The linear register allocator claimed that the Cmm pipeline keeps
unreachable blocks away from it. But the NCG's own Cmm optimisations
can make more blocks unreachable after the Cmm pipeline has run. It
is sccBlocks that discards unreachable code before register
allocation (#7574).
Also:
* Remove a commented-out trace in the linear allocator that predates
#7574.
* Say in Note [unreachable blocks] that any pass in cpsTop can encounter
unreachable blocks. Rename it to Note [Unreachable blocks in the Cmm
pipeline], so its title no longer differs only in case from an
unrelated Note in GHC.Cmm.Dataflow.
Context: #27368
Assisted-by: Claude Fable 5.2
-
21abda33
by Teo Camarasu at 2026-11-26T21:23:37-05:00
Skip tests that excercise forkProcess when using non-moving GC
The non-moving GC creates a persistent marker thread. This causes issues
when users use forkProcess, since the child process ends up in a strange
state.
forkProcess is documented to not work well with the threaded Haskell
runtime. So, it's not surprising that it doesn't work with the
non-moving GC which is inherently threaded.
We should one day add support for forkProcess, but, for now, we just
disable these tests when using the non-moving GC.
The underlying issue is tracked by #27547.
-
79efb4a7
by Wolfgang Jeltsch at 2026-11-26T21:24:20-05:00
Switch fingerprint caches to `FastString` keys
Resolves #28139.
-
feacb69d
by mangoiv at 2026-11-26T21:25:01-05:00
ci: fix a bug where there's no runner that can pick up nightly push jobs
-
1d5c87ce
by Alan Zimmerman at 2026-11-26T21:25:43-05:00
EPA: Move setLayoutBoth inside markAnnListA
The current refactoring aims to capture layout only in the `AnnList`
exact print annotation. A consequence of this is that exact printing
should only process layout when printing in the context of `AnnList`.
To achieve this, this commit moves the layout printing enabler
`setlayoutboth` into the `AnnList` processing. Future commits will
remove the other occurrences.
It also adds some tests to confirm it still works as intended, and cleans
up some other unused functions.
-
8870d3e2
by Alan Zimmerman at 2026-11-28T13:12:16+00:00
EPA: Introduce LayoutFrame stacks in ExactPrint state
The exact print process keeps the current layout offset in its state,
for use in printing and updating for makeDelta.
Update it to use a stack rather than a single value, so it properly
handles nested layout, in particular when the layout is introduced but
the printing is empty.
Also simplify the exact print repl test runner to use a relative path
to the GHC libdir.
-
ddc9ccb8
by Alan Zimmerman at 2026-11-28T13:14:52+00:00
P:EPA: Make EpVirtualBraces noSpanAnchor if no contents
Otherwise the vocurly is emitted at the start of the next
item parsed
Check: is this needed, or just a check for empty contents?
-
22c5d138
by Alan Zimmerman at 2026-11-28T13:14:52+00:00
P:Align with ghc-exactprint
-
4ff724fa
by Alan Zimmerman at 2026-11-28T13:14:52+00:00
P:EPA: Fix AnnList leading semis when layout
When there is layout, anything printed triggers it, including leading
semis.
Add some test case examples too
-
7f9947e6
by Alan Zimmerman at 2026-11-28T13:14:52+00:00
MOVE EPA: Plan for Fixing AnnList Layout Properly
Also Exactprint layout scope plan
-
5c194a07
by Alan Zimmerman at 2026-11-28T13:14:52+00:00
P:Exactprint: tidy up layout capturing
-
b7bca6d1
by Alan Zimmerman at 2026-11-28T13:14:52+00:00
F:MD:EPA: add makeDelta test for Test20297
The original #20297 related to comment placement for exact printing
after running ExactPrint.makeDelta on ParsedSource. Add an additional
test that explicitly tests this.
-
12a2c29d
by Alan Zimmerman at 2026-11-28T13:14:52+00:00
EPA: Make ValBinds LocatedA in HsLocalBindsLR
If we have items with an AnnList Annotation, as part of another, which
has different content, it must be LocatedA. This is a technical requirement
due to the way comment allocation happens during the makeDelta processing.
Comments are queued for printing, and as soon as any non-comment is to
be printed, the pending comments before that position are printed, and
in makeDelta processing these attached as preceding comments to the thing
just printed.
The means they end up captured inside the layout region of the AnnList item.
So for
foo = x
where -- comment
x = 3
the comment ends up as a preceding comment of `x = 3`, inside the
layout, and prints as
foo = x
where
-- comment
x = 3
-
2b7a6eb6
by Alan Zimmerman at 2026-11-28T13:14:52+00:00
EPA: Make IPBinds LocatedA
-
52bd87dd
by Alan Zimmerman at 2026-11-28T13:14:52+00:00
[WIP] EPA: adding some notes to ExactPrint
-
a5ac5b23
by Alan Zimmerman at 2026-11-28T13:14:52+00:00
EPA: Make ClsInstDecl decls LocatedA
-
38069bab
by Alan Zimmerman at 2026-11-28T13:14:52+00:00
P:EPA: Make ClassDecls decls LocatedA
-
5cab4688
by Alan Zimmerman at 2026-11-28T13:14:52+00:00
EPA: Make ClosedTypeFamily equations Located
For FamilyDecl/ClosedTypeFamily
-
fb88afd3
by Alan Zimmerman at 2026-11-28T13:14:52+00:00
Perf ok:EPA: Make dd_cons located
-
d37944e3
by Alan Zimmerman at 2026-11-28T13:14:52+00:00
EPA: Make HsMultiIf options located
-
c96fa5b3
by Alan Zimmerman at 2026-11-28T13:14:52+00:00
EPA: Make DecBrl contents LocatedA
-
d3ac741b
by Alan Zimmerman at 2026-11-28T13:14:52+00:00
EPA: Located do statements
-
d6b48038
by Alan Zimmerman at 2026-11-28T13:14:52+00:00
EPA: Print RecStmt located
-
f53ecc3e
by Alan Zimmerman at 2026-11-28T13:14:52+00:00
P:EPA: HsCmdDo Located
-
b24d6ed4
by Alan Zimmerman at 2026-11-28T13:14:52+00:00
Extend Test20297 for additional occurrences
-
dacf1bb7
by Alan Zimmerman at 2026-11-28T13:14:52+00:00
EPA: Tweak PatSynBind location for comments
-
eed883b9
by Alan Zimmerman at 2026-11-28T13:14:52+00:00
EPA: WIP, add test for where ;; ValBinds
-
51ef8d2c
by Alan Zimmerman at 2026-11-28T13:14:52+00:00
EPA: Make EpVirtualBraces noSpanAnchor if no contents
Otherwise the vocurly is emitted at the start of the next
item parsed
Check: is this needed, or just a check for empty contents?
-
5778b800
by Alan Zimmerman at 2026-11-28T13:14:52+00:00
Perf ok:EPA: Use EpNoLayout in AnnList with empty contents and no explicit braces
TODO: get rid of unused first arg to epVirtualBraces
-
7b51d959
by Alan Zimmerman at 2026-11-28T13:14:52+00:00
Perf ok:TODO: XClassDecl: remove additional EpLayout
-
ce92f682
by Alan Zimmerman at 2026-11-28T13:14:52+00:00
Perf ok:EPA: Remove CanUpdateAnchorOnly
-
bfd7f1bd
by Alan Zimmerman at 2026-11-28T13:14:52+00:00
Perf:decrese:EPA: Sync with ghc-exactprint after EPWriter -> CPS
-
69e1b4db
by Alan Zimmerman at 2026-11-28T13:14:52+00:00
EPA: Fix EpVirtualBraces for HsDo
The start of layout must include the leading semi, so we comb3 to
ensure it is included if the initial stmts are empty
-
8070cf32
by Alan Zimmerman at 2026-11-28T13:14:52+00:00
EPA: ClsInstDecl where clause span
-
0aec7131
by Alan Zimmerman at 2026-11-28T13:14:52+00:00
EPA: GADT parens printing, fix
-
ee3d1c65
by Alan Zimmerman at 2026-11-28T13:14:52+00:00
Plan update DO NOT COMMIT
-
93c166f5
by Alan Zimmerman at 2026-11-28T13:14:52+00:00
F1:EPA: fix AnnList opening span for some cases
F1 as per ANNLIST-LAYOUT-FINDINGS.md
-
234c60e8
by Alan Zimmerman at 2026-11-28T13:14:52+00:00
F2:EPA fix vocurly start
F2
-
b847460c
by Alan Zimmerman at 2026-11-28T13:14:52+00:00
F3:EPA multi way if
-
ecf762e7
by Alan Zimmerman at 2026-11-28T13:14:52+00:00
F4:EPA: Parse leading semis for gadt_contrs
-
99c86698
by Alan Zimmerman at 2026-11-28T13:14:52+00:00
EPA:F5: Leading semicolons dropped in closed-type-family bodies
-
6b028e9a
by Alan Zimmerman at 2026-11-28T13:14:52+00:00
F6: ALR: skip, the feature is deprecated
-
4c51979b
by Alan Zimmerman at 2026-11-28T13:14:52+00:00
[WIP]:F7 leading semi differences
-
eea83643
by Alan Zimmerman at 2026-11-28T13:14:52+00:00
EPA: First pass implementation of HsList, for ClassDecls
Just as a straight list replacement to start with, no payload.
This shows the scope and invasiveness of the initial change
-
1ec33c64
by Alan Zimmerman at 2026-11-28T13:14:52+00:00
EPA: HsList attempt WIP
-
c6aeaeaf
by Alan Zimmerman at 2026-11-28T13:14:52+00:00
Enable ppr test for Haddock1. It currently fails
-
1b9f4098
by Alan Zimmerman at 2026-11-28T13:14:52+00:00
WIP on removing NoEpAnn. Likely abandon
-
3bb2db61
by Alan Zimmerman at 2026-11-28T13:14:52+00:00
EPA: Add an overview doc for exact printing
-
7abe6442
by Simon Peyton Jones at 2026-11-28T13:14:52+00:00
Added an intro section