-
ac870ad5
by Simon Jakobi at 2026-10-28T04:40:42-04:00
X86 NCG: use 32-bit POPCNT for sub-word popcounts
A 32-bit write zero-extends the result to the full register, so we
don't need to emit additional code for this.
We also skip emitting zero-extension instructions for the argument
when it is already visibly zero-extended.
For the byte-wise popcount loop from #24813, this shrinks the popcount
sequence from 5 instructions to 3.
Assisted-by: Claude Fable 5.1
-
53087373
by Facundo Domínguez at 2026-10-28T04:41:32-04:00
Use a ShortByteString in Serialized instead of [Word8]
This makes the in-memory representation 40x more compact for all values
stored in annotations.
A test is added to measure the representation size of annotations
specified in the compiler input.
The GHC API is modified. All functions that previously handled annotations
in [Word8] form now use ShortByteString. The following definitions have
modified types:
* GHC.findGlobalAnns
* GHC.Tc.Gen.Splice.getAnnotationsByTypeRep
* GHC.Core.Opt.Monad.getAnnotations
* GHC.Core.Opt.Monad.getFirstAnnotations
* GHC.Types.Annotations.deserializeAnns
* GHC.Types.Annotations.findAnns
* GHC.Types.Annotations.findAnnsByTypeRep
* GHC.Serialized.Serialized
* GHC.Serialized.toSerialized
* GHC.Serialized.fromSerialized
* GHC.Serialized.serializeWithData
* GHC.Serialized.deserializeWithData
* GHCi.Message.ReifyAnnotations
Fixes #28002.
-
cc533b66
by Sasha Bogicevic at 2026-10-31T09:18:15-04:00
Don't report -XStrict-generated bangs under -Wredundant-bang-patterns
The -XStrict flag causes the desugarer to insert bang patterns.
These are not user-written, so -Wredundant-bang-patterns must not
report them.
To achieve this, the desugarer now tracks whether it is desugaring
compiler-generated code (similar to the typechecker's 'tcl_in_gen_code').
Bangs inserted by -XStrict are given generated spans, which suppresses
the "redundant bang" warnings without otherwise affecting pattern-match
warnings.
Fixes #27323
-
13d38047
by Luite Stegeman at 2026-10-31T09:19:11-04:00
rts: tombstone Weak# copies that lose an evacuation race (#23160)
Mark the losing copy of a Weak# during an evacuation race in parallel
GC with stg_DEAD_WEAK_info. This ensures that the nonmoving GC
doesn't follow dangling pointers, leading to crashes.
Fixes #23160
-
63347328
by Zubin Duggal at 2026-10-31T09:19:52-04:00
ghci: Drop GHCi's exception context when rethrowing in ghc -e
Fixes #27847.
-
a85fef3f
by Zubin Duggal at 2026-10-31T09:19:52-04:00
base: Preserve exception context in modifyIOError
Fixes #27851.
CLC proposal: https://github.com/haskell/core-libraries-committee/issues/446
-
1d60b591
by Zubin Duggal at 2026-10-31T09:19:52-04:00
base: Preserve exception context in mapException
Fixes #27851.
CLC proposal: https://github.com/haskell/core-libraries-committee/issues/446
-
3c029a1b
by Zubin Duggal at 2026-10-31T09:19:52-04:00
base: Preserve exception context when rethrowing exceptions in Handle reads
Fixes #27875.
CLC proposal: https://github.com/haskell/core-libraries-committee/issues/447
-
ab2b317a
by Zubin Duggal at 2026-10-31T09:19:52-04:00
base: Preserve exception context when rethrowing exceptions in hClose
Fixes #27875.
CLC proposal: https://github.com/haskell/core-libraries-committee/issues/447
-
f5abf277
by Zubin Duggal at 2026-10-31T09:19:52-04:00
base: Preserve exception context when rethrowing exceptions in Windows openFile
Fixes #27875.
CLC proposal: https://github.com/haskell/core-libraries-committee/issues/447
-
d842c672
by Zubin Duggal at 2026-10-31T09:19:52-04:00
base: Preserve exception context when rethrowing exceptions in executablePath
Fixes #27875.
CLC proposal: https://github.com/haskell/core-libraries-committee/issues/447
-
c5a8bb9f
by Simon Peyton Jones at 2026-10-31T09:20:34-04:00
Simplify a tc-trace which could crash the compiler
The trace formatted an error message, which prematurely
read the ExpType in a FunResCtxt.
Solution: don't put call the error message formatting
when tc-tracing.
-
ab49b1d2
by Simon Peyton Jones at 2026-10-31T09:20:34-04:00
Tiny comment change to uniqAway
-
6efe4ba3
by Simon Peyton Jones at 2026-10-31T09:20:34-04:00
Make niFixSubst idempotent
I discovered (when fixing #27994) that `niFixSubst` didn't actually
generate an idempotent subsitution despite its claims. It could
return a substitution that mentions domain variables on in its range,
when those variables are hidden inside the kind of a type variable
occurrence. As a result it can generate ill-kinded types. Boo!
The fix is simple, and uses deep substitution.
See Note [Finding the substitution fixpoint]
I don't think it actually /caused/ any bugs, so there is no
regression test.
-
3b60ae7e
by Simon Peyton Jones at 2026-10-31T09:20:34-04:00
Fix a nasty bug in fundeps
This MR fixes #27994, which turned out to be very tricky.
See Note [Exploiting closed type famililes], especially (CF7). I was
ending up with TyVars (not TcTyVars) in the solver, because the
substitution computed in `getRelevantBranches` mixed the two.
The code was just too clever. I ended up simplifying it quite a bit.
For /closed/ families we no longer call `trimQtvs` (was `trim_qtvs`).
Open families still do use `trimQtvs`. See Note [trimQTvs]
This patch also fixes one other buglet in the same code.
* Over-saturated type families were being mis-handled.
See the new use of `saturatedFamApp_maybe`.
-
e4610f2d
by Facundo Domínguez at 2026-10-31T09:21:24-04:00
Have haddock --incremental look for the module in -this-unit-id
-
bc6c0db6
by sheaf at 2026-10-31T09:22:20-04:00
mightBeFunTy: hotfix for #27979
ce01ccb6 refactored 'GHC.Types.RepType.mightBeFunTy' to look through
unary classes. That change introduced the helper function 'unwrap_type'
which was supposed to always return an unwrapped type, but its fallback
equation mistakenly returned the original type. This caused the
subsequent 'tyConAppTyCon_maybe' to fail in cases where it should
succeed (e.g. looking through foralls).
In this commit, we move all the unary class unwrapping logic into
'unwrapType' where it belonged from the start, and update the
documentation of 'unwrapType' to better explain what it should be used
for (#26695).
Fixes #27979 #26695
-------------------------
Metric Increase:
T5642
-------------------------
-
233cce46
by Alan Zimmerman at 2026-10-31T09:23:01-04:00
EPA: Tidy up ExactPrint.markAnnListA'
It takes an action which can modify the AnnList, but this
is never used. So remove it.
-
3594a908
by Sylvain Henry at 2026-10-31T09:23:51-04:00
gitmodules: ignore dirty libffi-clib submodule (#26785)
`./boot` runs autoreconf in libraries/libffi-clib, which leaves
`configure~` behind and rewrites the tracked `aclocal.m4` whenever the
local automake version differs from the one that generated it. Every
checkout then looks dirty. Ignore working-tree changes in the submodule
(`ignore = dirty`); a changed submodule commit is still reported.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
-
341223c0
by Rodrigo Mesquita at 2026-10-31T09:24:33-04:00
refactor: Keep the interactive Ids directly rather than Name
Removes things like
names <- map idName ids
map (\i -> let id = find (\x -> i==idName x) names) idso
and is more straightforward because there's less state going around (no
more updating HscEnv as an output)
It also kills `printTypeOfNames` completely, since now we just have the
Ids. No longer `lookupName` names to get back the ids...
```
printTypeOfName :: GHC.GhcMonad m => Name -> m ()
printTypeOfName n
= do maybe_tything <- GHC.lookupName n
case maybe_tything of
Nothing -> return ()
Just thing -> printTyThing thing
```
now is just `printTyThing . AnId`
Also:
```diff
- tythings <- catMaybes `liftM` mapM GHC.lookupName namesSorted
- docs <- mapM pprTypeAndContents [i | AnId i <- tythings]
+ docs <- mapM pprTypeAndContents idsSorted
```
(and yes, in ExecBreaks there are only Ids, no TyThings, bc they are
only constructed by the interpreter execution which can only bind ids.
for TyThings use runDecls which doesn't return execBreaks.)
There's some care to be had to make sure we use the "most refined" Ids,
whereas when using `Name`s we'd always fetch the most refined Id from
scratch.
Fixes #28052
-
54cf3c1e
by sheaf at 2026-11-03T07:00:23-05:00
Consolidate all CPU feature handling
This commit introduces GHC.Platform.CpuFeatures which consolidates all
of the logic for implications between CPU feature flags (mainly X86):
- DynFlags now only records the set of -m<feature> flags that were
passed, as an EnumSet CpuFeature. That keeps it a simple record of
the flags the user passed, with no post-processing.
- GHC.Platform.CpuFeatures.initCpuFeatures turns this set into a
CpuFeatures value, applying all implications and the per-architecture
baseline. This is the single home for all of the feature implication
logic.
Some datatypes were reworked to better reflect the implication
structure in the types, e.g. SseAvxVersion has a strategically
placed 'FMA' boolean.
- The NCG, LLVM backend, StgToCmm, CPP defines and LLVM -mattr
flags all consult CpuFeatures, via targetCpuFeatures.
See Note [CPU features], which replaces
Note [Implications between X86 CPU feature flags].
Behaviour changes:
- x86 feature flags (-msse3, -mavx, -mavx512*, -mgfni, ...) passed
when targeting a non-x86 architecture no longer cause x86 CPP
macros (__SSE3__, __AVX512BW__, __GFNI__, ...) to be defined, nor
x86 attributes to be passed to LLVM.
- Error messages reported when required CPU features are not enabled
now print out the minimal set of flags required
(e.g. "-mavx512vl" rather than "-mavx512f -mavx512vl").
-
9af64305
by Luite Stegeman at 2026-11-03T07:01:23-05:00
rts: move stack check to the start of the stg_unpack_cstring thunks
fixes a deadlock
see #27272
-
a2208b21
by Simon Jakobi at 2026-11-03T07:02:05-05:00
Cmm: exclude the entry block from common block elimination
a1d8139054c had fixed #27722 only partially, because it didn't prevent
elimination of the entry block in later rounds, where the entry block is
no longer guaranteed to come first.
To close this loophole, we exclude the entry block from the CBE merge
logic. See Note [Retain entry block during common block elimination] for
details.
This also deletes a misleading comment regarding unreachable blocks: the
control-flow optimiser doesn't actually guarantee that no unreachable
blocks reach CBE.
Fixes #27722.
Assisted-by: Claude Fable 5.1
-
37ad4710
by Alan Zimmerman at 2026-11-03T07:02:46-05:00
EPA: Use AnnList for GADT declarations
Continuing the process of using AnnList to capture parser layout
-
d3104741
by Alan Zimmerman at 2026-11-03T22:08:44+00:00
EPA: Use AnnList in AnnClassDecl
Capture parser layout
-
a9db823e
by Alan Zimmerman at 2026-11-04T18:15:40+00:00
P:EPA: Make local binds located
Use LHsLocalBinds instead of HsLocalBinds
This reverses an earlier change, and brings processing of local binds
into alignement with the exact printing principle that the LocatedA
contents provide the location and extent of the enclosed item,
together with any comments or context-specific trailing items like
commas or semi colons.
The internal TTG extension points only carry exact print annotations
related to printing the item within its bounds.
This change brings back the problem of EmptyLocalBinds, which by
definition cannot have a location. These get a noSrcSpan location,
which is ignored in the exact printing process.
-
2eae9880
by Alan Zimmerman at 2026-11-04T18:15:40+00:00
P:EPA: Use AnnList in HsMultiIf
It introduces layout, capture it
-
24145a53
by Alan Zimmerman at 2026-11-04T18:15:40+00:00
P:EPA: Use AnnList in DecBrl
-
5bf2bcba
by Alan Zimmerman at 2026-11-04T18:15:40+00:00
P:EPA: Replace AnnListLayout / AnnListBrackets with EpLayout
-
534d431f
by Alan Zimmerman at 2026-11-04T18:15:40+00:00
P:WIP: setLayoutBoth inside markAnnListA
Current problem is it is a global one-shot, and MG has one too
Check: is it needed?
if so, honouring EpLayout may be needed
-
fef95d30
by Alan Zimmerman at 2026-11-04T18:15:40+00:00
P:EPA some tests for layout. WIP
-
e87a925e
by Alan Zimmerman at 2026-11-04T18:20:24+00:00
MOVE EPA: Plan for Fixing AnnList Layout Properly
Also Exactprint layout scope plan
-
a8a83f6b
by Alan Zimmerman at 2026-11-04T18:20:49+00:00
P:EPA: tidy up a bit. Combine somewhere else
-
d77e6ef6
by Alan Zimmerman at 2026-11-04T18:20:49+00:00
P:EPA: Introduce LayoutFrame stacks in ExactPrint state
-
b00d83da
by Alan Zimmerman at 2026-11-04T18:20:49+00:00
F:Align with ghc-exactprint
-
0acac377
by Alan Zimmerman at 2026-11-04T18:20:49+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?
-
fd80d5d1
by Alan Zimmerman at 2026-11-04T18:20:49+00:00
EPA: Fix AnnList leading semis when layout
When there is layout, anything printed triggers it, including leading
semis.
Add some test case examples too
-
15de348e
by Alan Zimmerman at 2026-11-04T18:20:49+00:00
Exactprint: tidy up layout capturing
-
8b0d0da3
by Alan Zimmerman at 2026-11-04T18:20:49+00:00
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.
-
d23560e8
by Alan Zimmerman at 2026-11-04T18:20:49+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
-
f80c8098
by Alan Zimmerman at 2026-11-04T18:20:49+00:00
EPA: Make IPBinds LocatedA
-
e1f3dc1d
by Alan Zimmerman at 2026-11-04T18:20:49+00:00
EPA: Make ClsInstDecl decls LocatedA
-
36581062
by Alan Zimmerman at 2026-11-04T18:20:49+00:00
EPA: Make ClassDecls decls LocatedA
-
8f20a3fb
by Alan Zimmerman at 2026-11-04T18:20:49+00:00
EPA: Make ClosedTypeFamily equations Located
For FamilyDecl/ClosedTypeFamily
-
b2765ab6
by Alan Zimmerman at 2026-11-04T18:20:49+00:00
Perf ok:EPA: Make dd_cons located
-
b95c5be0
by Alan Zimmerman at 2026-11-04T18:20:49+00:00
EPA: Make HsMultiIf options located
-
6fa8041d
by Alan Zimmerman at 2026-11-04T18:20:49+00:00
EPA: Make DecBrl contents LocatedA
-
7b5f299c
by Alan Zimmerman at 2026-11-04T18:20:49+00:00
EPA: Located do statements
-
16c4d094
by Alan Zimmerman at 2026-11-04T18:20:49+00:00
EPA: Print RecStmt located
-
906f5cce
by Alan Zimmerman at 2026-11-04T18:20:49+00:00
EPA: HsCmdDo Located
-
fb45859b
by Alan Zimmerman at 2026-11-04T18:20:49+00:00
Extend Test20297 for additional occurrences
-
c001e673
by Alan Zimmerman at 2026-11-04T18:20:49+00:00
EPA: Tweak PatSynBind location for comments
-
6803e155
by Alan Zimmerman at 2026-11-04T18:20:49+00:00
EPA: WIP, add test for where ;; ValBinds
-
e77fe148
by Alan Zimmerman at 2026-11-04T18:20:49+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?
-
54271cc8
by Alan Zimmerman at 2026-11-04T18:20:49+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
-
1a11145c
by Alan Zimmerman at 2026-11-04T18:20:49+00:00
Perf ok:TODO: XClassDecl: remove additional EpLayout
-
04006734
by Alan Zimmerman at 2026-11-04T18:20:49+00:00
Perf ok:EPA: Remove CanUpdateAnchorOnly
-
c9fa7dc7
by Alan Zimmerman at 2026-11-04T18:20:49+00:00
Perf:decrese:EPA: Sync with ghc-exactprint after EPWriter -> CPS
-
481bd814
by Alan Zimmerman at 2026-11-04T18:20:49+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
-
567de930
by Alan Zimmerman at 2026-11-04T18:20:49+00:00
EPA: ClsInstDecl where clause span
-
4170cfee
by Alan Zimmerman at 2026-11-04T18:20:49+00:00
EPA: GADT parens printing, fix
-
67c80559
by Alan Zimmerman at 2026-11-04T18:20:49+00:00
Plan update DO NOT COMMIT
-
1a2b40dd
by Alan Zimmerman at 2026-11-04T19:41:52+00:00
WIP
-
b01ec374
by Alan Zimmerman at 2026-11-04T19:41: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
-
6e664963
by Alan Zimmerman at 2026-11-04T19:41:52+00:00
EPA: HsList attempt WIP
-
ae38bbc3
by Alan Zimmerman at 2026-11-04T19:41:52+00:00
Enable ppr test for Haddock1. It currently fails
-
f47e6ce7
by Alan Zimmerman at 2026-11-04T19:41:52+00:00
WIP on removing NoEpAnn. Likely abandon
-
5c3bfe21
by Alan Zimmerman at 2026-11-04T19:41:52+00:00
EPA: Add an overview doc for exact printing
-
614550f5
by Simon Peyton Jones at 2026-11-04T19:41:52+00:00
Added an intro section