-
01a5b0ac
by Sylvain Henry at 2026-11-22T16:35:34-05:00
NCG: List each destination of a jump table once
jumpDestsOfInstr listed a block once per jump table entry that named
it. The linear register allocator makes a fixup block per listed
destination, so such a block got several fixup blocks. The patch of
the jump sends every entry to the first one. The other fixup blocks
were dead code, and the CFG had an edge to each of them.
jumpDestsOfInstr now lists each destination once, in every backend.
joinToTargets asserts it in debug builds.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
-
e4498112
by Andreas Klebinger at 2026-11-22T16:35:34-05:00
x86 ncg: Track the current block in NatM to keep the CFG in sync
The x86 NCG uses a CFG for code layout. When instruction selection
makes new blocks (word2Float#, cmpxchg loops, 64-bit shifts on i386),
it must add them to the CFG. Some sites did not. The CFG went out of
sync, the layout was bad, and the register allocator panicked when it
added fixup blocks (#27694, #27915).
NatM now keeps the current block in its state. Combinators update the
CFG and the current block together. See Note [Updating the CFG during
CodeGen] in GHC.CmmToAsm.Monad.
Other changes:
* -dasm-lint checks that the jumps in the code and the edges in the
CFG agree in both directions. This found a second desync: the CFG
did not follow the jumps that allocMoreStack retargets. The new
addPreentryBlock fixes it.
* The code must be emitted in generation order, because the CFG
records new blocks in that order. A store now generates the code of
its value before the code of its address, in the order it emits
them. Atomic operations take their address from the new
getNonClobberedAmode, so the code of their other operands cannot
clobber it.
Fixes #27694, #27915
Co-authored-by: Sylvain Henry <sylvain@haskus.fr>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
-
f59fb957
by Sylvain Henry at 2026-11-22T16:35:34-05:00
x86 ncg: Maintain the CFG on i386
The i386 NCG now keeps its CFG in sync with the code (see the previous
commit), so backendMaintainsCfg is now True for i386. i386 gets the
CFG based code layout, dead code elimination and the -dasm-lint check,
like x86-64.
The compiler allocates more on i386: the CFG now goes through the
register allocator, branch shortcutting and optimizeCFG, which i386
skipped before. x86-64 already does this work.
Metric Increase:
CoOpt_Read
ManyAlternatives
T10421
T12425
T12707
T13056
T13253
T13253-spj
T13960
T15164
T15304
T15630
T15630a
T15703
T16577
T17516
T17836
T18140
T18282
T18304
T18698a
T18698b
T18730
T18923
T19695
T20049
T21839c
T24471
T26425
T26989
T5642
T6048
T783
T9233
T9630
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
-
2091b89a
by fendor at 2026-11-22T16:36:17-05:00
`ghc -M`: Add support for link nodes to json output
`LinkNode`s are part of the module graph and indicate that a certain
linking artefact is to be produced from other module graph nodes.
We expose `LinkNode`s in the output of `ghc -M -dep-json`, allowing
consumers to see when a linking artefact is to be produced.
Only the JSON output format of `ghc -M` supports `LinkNode` as it is
unclear how the Makefile output should be retrofitted to express the
dependencies, and whether it would require a feature guard.
Closes #28007
-
cfd4fb67
by Ryan Scott at 2026-11-22T16:36:59-05:00
GHC.HsToCore.Quote: Quote \cases with the correct type
Previously, `\cases` expressions inside of Template Haskell quotes would
incorrectly use the `Match` type instead of `Clause` for the element type. We
now use `nonEmptyCoreList` when quoting `\cases`, which infers the correct type
automatically. This works because `\cases` has an invariant that the list of
clauses is always non-empty.
Fixes #27826.
-
06e71ddf
by Simon Peyton Jones at 2026-11-22T16:37:40-05:00
Better desugaring for bang patterns
Ticket #27862 showed that we were desugaring bang patterns in a
silly way, which led to bad code. This small fix makes it much
better.
I ended up refactoring `decomposeFirstPat` to be of type
(LPat -> LPat) instead of (Pat -> Pat)
which made it much easier to keep the locations correct.
On the way I also fixed #28137, a missing warning.
See Note [Tidying patterns] which has new (TP1) and (TP2)
and Note [Grouping equations] especially (GE1)
-
cd6c2a96
by Simon Jakobi at 2026-11-22T16:38:23-05:00
Cmm: drop eliminated blocks from the graph in CBE
Previously, common block elimination only made the eliminated blocks
unreachable. They stayed in the graph until stack layout discarded
them.
Removing these blocks right away reduces the potential for confusion
(e.g. #27368). It does not appear to make any significant difference
to compiler allocations.
Assisted-by: Claude Opus 5.5
-
c0764c69
by Hannes Siebenhandl at 2026-11-22T16:39:04-05:00
Use Set operations over Foldable operations
Use `O(log n)` operations over `O(n)` for all call-sites of `hsc_all_home_unit_ids`.
-
242f8daf
by Alan Zimmerman at 2026-11-22T16:39:46-05:00
EPA: Use AnnList in DecBrl
Via updating the TTG extension point payload
-
1e568190
by David Eichmann at 2026-11-22T16:40:28-05:00
Fix race condition in IOManager test
-
64f821c6
by Simon Peyton Jones at 2026-11-22T16:41:09-05:00
Fix a zonking bug
As #28135 showed, we were failing to zonk some type-variable
binders before doing scoped-sort dependency analysis, resulting
in chaos.
The fix is easy.
-
ed5124b3
by mangoiv at 2026-11-22T16:41:50-05:00
ci: nightly push can run on any arch
-
1340d255
by ARATA Mizuki at 2026-11-23T20:13:03-05:00
rts: Fix unwinding information for StgRun
The unwinding rule for rsp updated in a5ec467ee3d4e77c026437a545981269acde3434
was wrong. It gave the value of rsp _after_ the call instruction (i.e.
on entry to StgRun), whereas it should give the value _before_ the call
instruction (i.e. the caller's rsp).
Fixes #27637
-
56bb91d9
by Alan Zimmerman at 2026-11-23T20:13:44-05:00
EPA: Replace AnnListLayout / AnnListBrackets with EpLayout
We have harmonised the use of `AnnListLayout` and `AnnListBrackets` to
be equivalent to `EpLayout`.
We now take the final step, and remove them completely in favour of
`EpLayout`.
The change looks bigger than it is, because a lot of golden test
output gets updated.
-
72f8dc4d
by Alan Zimmerman at 2026-11-24T20:22:07+00: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.
-
ca7db8a3
by Alan Zimmerman at 2026-11-24T20:22:07+00:00
P:EPA: Introduce LayoutFrame stacks in ExactPrint state
-
0d22462e
by Alan Zimmerman at 2026-11-24T20:22:07+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?
-
368c51e3
by Alan Zimmerman at 2026-11-24T20:22:07+00:00
P:Align with ghc-exactprint
-
8687a250
by Alan Zimmerman at 2026-11-24T20:22:07+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
-
a525531d
by Alan Zimmerman at 2026-11-24T20:22:07+00:00
MOVE EPA: Plan for Fixing AnnList Layout Properly
Also Exactprint layout scope plan
-
79043af7
by Alan Zimmerman at 2026-11-24T20:22:07+00:00
P:Exactprint: tidy up layout capturing
-
05236d22
by Alan Zimmerman at 2026-11-24T20:22:07+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.
-
9679e169
by Alan Zimmerman at 2026-11-24T20:22:07+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
-
add5bf51
by Alan Zimmerman at 2026-11-24T20:22:07+00:00
EPA: Make IPBinds LocatedA
-
fa750262
by Alan Zimmerman at 2026-11-24T20:22:07+00:00
EPA: Make ClsInstDecl decls LocatedA
-
30bbc0f3
by Alan Zimmerman at 2026-11-24T20:22:07+00:00
P:EPA: Make ClassDecls decls LocatedA
-
e031f506
by Alan Zimmerman at 2026-11-24T20:22:07+00:00
EPA: Make ClosedTypeFamily equations Located
For FamilyDecl/ClosedTypeFamily
-
19e0d72a
by Alan Zimmerman at 2026-11-24T20:22:07+00:00
Perf ok:EPA: Make dd_cons located
-
1777d695
by Alan Zimmerman at 2026-11-24T20:22:07+00:00
EPA: Make HsMultiIf options located
-
a5c1d66f
by Alan Zimmerman at 2026-11-24T20:22:07+00:00
EPA: Make DecBrl contents LocatedA
-
e4c23f27
by Alan Zimmerman at 2026-11-24T20:22:07+00:00
EPA: Located do statements
-
6ba41852
by Alan Zimmerman at 2026-11-24T20:22:07+00:00
EPA: Print RecStmt located
-
ebeb6a82
by Alan Zimmerman at 2026-11-24T20:22:07+00:00
P:EPA: HsCmdDo Located
-
f9da7939
by Alan Zimmerman at 2026-11-24T20:22:07+00:00
Extend Test20297 for additional occurrences
-
51264e71
by Alan Zimmerman at 2026-11-24T20:22:07+00:00
EPA: Tweak PatSynBind location for comments
-
abda3cc2
by Alan Zimmerman at 2026-11-24T20:22:07+00:00
EPA: WIP, add test for where ;; ValBinds
-
acbfa330
by Alan Zimmerman at 2026-11-24T20:22:07+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?
-
2edad0c9
by Alan Zimmerman at 2026-11-24T20:22:07+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
-
fc98f693
by Alan Zimmerman at 2026-11-24T20:22:07+00:00
Perf ok:TODO: XClassDecl: remove additional EpLayout
-
a1777a0b
by Alan Zimmerman at 2026-11-24T20:22:07+00:00
Perf ok:EPA: Remove CanUpdateAnchorOnly
-
d5f5c1d3
by Alan Zimmerman at 2026-11-24T20:22:07+00:00
Perf:decrese:EPA: Sync with ghc-exactprint after EPWriter -> CPS
-
434c449d
by Alan Zimmerman at 2026-11-24T20:22:07+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
-
2662ae6f
by Alan Zimmerman at 2026-11-24T20:22:07+00:00
EPA: ClsInstDecl where clause span
-
c42e7457
by Alan Zimmerman at 2026-11-24T20:22:07+00:00
EPA: GADT parens printing, fix
-
003687ef
by Alan Zimmerman at 2026-11-24T20:22:07+00:00
Plan update DO NOT COMMIT
-
a4d41edc
by Alan Zimmerman at 2026-11-24T20:22:07+00:00
F1:EPA: fix AnnList opening span for some cases
F1 as per ANNLIST-LAYOUT-FINDINGS.md
-
c031552c
by Alan Zimmerman at 2026-11-24T20:22:07+00:00
F2:EPA fix vocurly start
F2
-
1f284ba0
by Alan Zimmerman at 2026-11-24T20:22:07+00:00
F3:EPA multi way if
-
b946e65a
by Alan Zimmerman at 2026-11-24T20:22:07+00:00
F4:EPA: Parse leading semis for gadt_contrs
-
14735a0c
by Alan Zimmerman at 2026-11-24T20:22:07+00:00
EPA:F5: Leading semicolons dropped in closed-type-family bodies
-
93c902ad
by Alan Zimmerman at 2026-11-24T20:22:07+00:00
F6: ALR: skip, the feature is deprecated
-
94c63f23
by Alan Zimmerman at 2026-11-24T20:22:07+00:00
[WIP]:F7 leading semi differences
-
62b67b58
by Alan Zimmerman at 2026-11-24T20:22:07+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
-
95a567b2
by Alan Zimmerman at 2026-11-24T20:22:07+00:00
EPA: HsList attempt WIP
-
904d88bb
by Alan Zimmerman at 2026-11-24T20:22:07+00:00
Enable ppr test for Haddock1. It currently fails
-
713a3c24
by Alan Zimmerman at 2026-11-24T20:22:07+00:00
WIP on removing NoEpAnn. Likely abandon
-
c039c837
by Alan Zimmerman at 2026-11-24T20:22:07+00:00
EPA: Add an overview doc for exact printing
-
9def32b8
by Simon Peyton Jones at 2026-11-24T20:22:07+00:00
Added an intro section