[Git][ghc/ghc][wip/T21753] 488 commits: Correct documentation of defaults of the `-V` RTS option

Ben Gamari (@bgamari) gitlab at gitlab.haskell.org
Thu Oct 20 15:06:04 UTC 2022



Ben Gamari pushed to branch wip/T21753 at Glasgow Haskell Compiler / GHC


Commits:
c1a950c1 by Alexander Esgen at 2022-06-22T12:36:13+00:00
Correct documentation of defaults of the `-V` RTS option

- - - - -
b7b7d90d by Matthew Pickering at 2022-06-22T21:58:12-04:00
Transcribe discussion from #21483 into a Note

In #21483 I had a discussion with Simon Marlow about the memory
retention behaviour of -Fd. I have just transcribed that conversation
here as it elucidates the potentially subtle assumptions which led to
the design of the memory retention behaviours of -Fd.

Fixes #21483

- - - - -
980d1954 by Ben Gamari at 2022-06-22T21:58:48-04:00
eventlog: Don't leave dangling pointers hanging around

Previously we failed to reset pointers to various eventlog buffers to
NULL after freeing them. In principle we shouldn't look at them after
they are freed but nevertheless it is good practice to set them to a
well-defined value.

- - - - -
575ec846 by Eric Lindblad at 2022-06-22T21:59:28-04:00
runhaskell
- - - - -
e6a69337 by Artem Pelenitsyn at 2022-06-22T22:00:07-04:00
re-export GHC.Natural.minusNaturalMaybe from Numeric.Natural

CLC proposal: https://github.com/haskell/core-libraries-committee/issues/45

- - - - -
5d45aa97 by Gergo ERDI at 2022-06-22T22:00:46-04:00
When specialising, look through floatable ticks.

Fixes #21697.

- - - - -
531205ac by Andreas Klebinger at 2022-06-22T22:01:22-04:00
TagCheck.hs: Properly check if arguments are boxed types.

For one by mistake I had been checking against the kind of runtime rep
instead of the boxity.

This uncovered another bug, namely that we tried to generate the
checking code before we had associated the function arguments with
a register, so this could never have worked to begin with.

This fixes #21729 and both of the above issues.

- - - - -
c7f9f6b5 by Gleb Popov at 2022-06-22T22:02:00-04:00
Use correct arch for the FreeBSD triple in gen-data-layout.sh

Downstream bug for reference: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=261798
Relevant upstream issue: #15718

- - - - -
75f0091b by Andreas Klebinger at 2022-06-22T22:02:35-04:00
Bump nofib submodule.

Allows the shake runner to build with 9.2.3 among other things.

Fixes #21772

- - - - -
0aa0ce69 by Ben Gamari at 2022-06-27T08:01:03-04:00
Bump ghc-prim and base versions

To 0.9.0 and 4.17.0 respectively.

Bumps array, deepseq, directory, filepath, haskeline, hpc, parsec, stm,
terminfo, text, unix, haddock, and hsc2hs submodules.

(cherry picked from commit ba47b95122b7b336ce1cc00896a47b584ad24095)

- - - - -
4713abc2 by Ben Gamari at 2022-06-27T08:01:03-04:00
testsuite: Use normalise_version more consistently

Previously several tests' output were unnecessarily dependent on version
numbers, particularly of `base`. Fix this.

- - - - -
d7b0642b by Matthew Pickering at 2022-06-27T08:01:03-04:00
linters: Fix lint-submodule-refs when crashing trying to find plausible branches

- - - - -
38378be3 by Andreas Klebinger at 2022-06-27T08:01:39-04:00
hadrian: Improve haddocks for ghcDebugAssertions

- - - - -
ac7a7fc8 by Andreas Klebinger at 2022-06-27T08:01:39-04:00
Don't mark lambda binders as OtherCon

We used to put OtherCon unfoldings on lambda binders of workers
and sometimes also join points/specializations with with the
assumption that since the wrapper would force these arguments
once we execute the RHS they would indeed be in WHNF.

This was wrong for reasons detailed in #21472. So now we purge
evaluated unfoldings from *all* lambda binders.

This fixes #21472, but at the cost of sometimes not using as efficient a
calling convention. It can also change inlining behaviour as some
occurances will no longer look like value arguments when they did
before.

As consequence we also change how we compute CBV information for
arguments slightly. We now *always* determine the CBV convention
for arguments during tidy. Earlier in the pipeline we merely mark
functions as candidates for having their arguments treated as CBV.

As before the process is described in the relevant notes:
Note [CBV Function Ids]
Note [Attaching CBV Marks to ids]
Note [Never put `OtherCon` unfoldigns on lambda binders]

-------------------------
Metric Decrease:
    T12425
    T13035
    T18223
    T18223
    T18923
    MultiLayerModulesTH_OneShot
Metric Increase:
    WWRec
-------------------------

- - - - -
06cf6f4a by Tony Zorman at 2022-06-27T08:02:18-04:00
Add suggestions for unrecognised pragmas (#21589)

In case of a misspelled pragma, offer possible corrections as to what
the user could have meant.

Fixes: https://gitlab.haskell.org/ghc/ghc/-/issues/21589

- - - - -
3fbab757 by Greg Steuck at 2022-06-27T08:02:56-04:00
Remove the traces of i386-*-openbsd, long live amd64

OpenBSD will not ship any ghc packages on i386 starting with 7.2
release.  This means there will not be a bootstrap compiler easily
available.  The last available binaries are ghc-8.10.6 which is
already not supported as bootstrap for HEAD.

See here for more information:

https://marc.info/?l=openbsd-ports&m=165060700222580&w=2

- - - - -
58530271 by Bodigrim at 2022-06-27T08:03:34-04:00
Add Foldable1 and Bifoldable1 type classes

Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/9

Instances roughly follow
https://hackage.haskell.org/package/semigroupoids-5.3.7/docs/Data-Semigroup-Foldable-Class.html#t:Foldable1
but the API of `Foldable1` was expanded in comparison to `semigroupoids`.

Compatibility shim is available from https://github.com/phadej/foldable1 (to be released).

Closes #13573.

- - - - -
a51f4ecc by Naomi Liu at 2022-06-27T08:04:13-04:00
add levity polymorphism to addrToAny#

- - - - -
f4edcdc4 by Naomi Liu at 2022-06-27T08:04:13-04:00
add tests for addrToAny# levity

- - - - -
07016fc9 by Matthew Pickering at 2022-06-27T08:04:49-04:00
hadrian: Update main README page

This README had some quite out-of-date content about the build system so
I did a complete pass deleting old material. I also made the section
about flavours more prominent and mentioned flavour transformers.

- - - - -
79ae2d89 by Ben Gamari at 2022-06-27T08:05:24-04:00
testsuite: Hide output from test compilations with verbosity==2

Previously the output from test compilations used to determine whether,
e.g., profiling libraries are available was shown with verbosity
levels >= 2. However, the default level is 2, meaning that most users
were often spammed with confusing errors. Fix this by bumping the
verbosity threshold for this output to >=3.

Fixes #21760.
- - - - -
995ea44d by Ben Gamari at 2022-06-27T08:06:00-04:00
configure: Only probe for LD in FIND_LD

Since 6be2c5a7e9187fc14d51e1ec32ca235143bb0d8b we would probe for LD
rather early in `configure`. However, it turns out that this breaks
`configure`'s `ld`-override logic, which assumes that `LD` was set by
the user and aborts.

Fixes #21778.

- - - - -
b43d140b by Sergei Trofimovich at 2022-06-27T08:06:39-04:00
`.hs-boot` make rules: add missing order-only dependency on target directory

Noticed missing target directory dependency as a build failure in
`make --shuffle` mode (added in https://savannah.gnu.org/bugs/index.php?62100):

    "cp" libraries/base/./GHC/Stack/CCS.hs-boot libraries/base/dist-install/build/GHC/Stack/CCS.hs-boot
    cp: cannot create regular file 'libraries/base/dist-install/build/GHC/Stack/CCS.hs-boot': No such file or directory
    libraries/haskeline/ghc.mk:4: libraries/haskeline/dist-install/build/.depend-v-p-dyn.haskell: No such file or directory
    make[1]: *** [libraries/base/ghc.mk:4: libraries/base/dist-install/build/GHC/Stack/CCS.hs-boot] Error 1 shuffle=1656129254
    make: *** [Makefile:128: all] Error 2 shuffle=1656129254

Note that `cp` complains about inability to create target file.

The change adds order-only dependency on a target directory (similar to
the rest of rules in that file).

The bug is lurking there since 2009 commit 34cc75e1a (`GHC new build
system megapatch`.) where upfront directory creation was never added to
`.hs-boot` files.

- - - - -
57a5f88c by Ben Gamari at 2022-06-28T03:24:24-04:00
Mark AArch64/Darwin as requiring sign-extension

Apple's AArch64 ABI requires that the caller sign-extend small integer
arguments. Set platformCConvNeedsExtension to reflect this fact.

Fixes #21773.

- - - - -
df762ae9 by Ben Gamari at 2022-06-28T03:24:24-04:00
-ddump-llvm shouldn't imply -fllvm

Previously -ddump-llvm would change the backend used, which contrasts
with all other dump flags. This is quite surprising and cost me quite
a bit of time. Dump flags should not change compiler behavior.

Fixes #21776.

- - - - -
70f0c1f8 by Ben Gamari at 2022-06-28T03:24:24-04:00
CmmToAsm/AArch64: Re-format argument handling logic

Previously there were very long, hard to parse lines. Fix this.

- - - - -
696d64c3 by Ben Gamari at 2022-06-28T03:24:24-04:00
CmmToAsm/AArch64: Sign-extend narrow C arguments

The AArch64/Darwin ABI requires that function arguments narrower
than 32-bits must be sign-extended by the caller. We neglected to
do this, resulting in #20735.

Fixes #20735.

- - - - -
c006ac0d by Ben Gamari at 2022-06-28T03:24:24-04:00
testsuite: Add test for #20735

- - - - -
16b9100c by Ben Gamari at 2022-06-28T03:24:59-04:00
integer-gmp: Fix cabal file

Evidently fields may not come after sections in a cabal file.

- - - - -
03cc5d02 by Sergei Trofimovich at 2022-06-28T15:20:45-04:00
ghc.mk: fix 'make install' (`mk/system-cxx-std-lib-1.0.conf.install` does not exist)

before the change `make install` was failing as:

```
"mv" "/<<NIX>>/ghc-9.3.20220406/lib/ghc-9.5.20220625/bin/ghc-stage2" "/<<NIX>>/ghc-9.3.20220406/lib/ghc-9.5.20220625/bin/ghc"
make[1]: *** No rule to make target 'mk/system-cxx-std-lib-1.0.conf.install', needed by 'install_packages'.  Stop.
```

I think it's a recent regression caused by 0ef249aa where `system-cxx-std-lib-1.0.conf`
is created (somewhat manually), but not the .install varianlt of it.

The fix is to consistently use `mk/system-cxx-std-lib-1.0.conf` everywhere.

Closes: https://gitlab.haskell.org/ghc/ghc/-/issues/21784

- - - - -
eecab8f9 by Simon Peyton Jones at 2022-06-28T15:21:21-04:00
Comments only, about join points

This MR just adds some documentation about why casts
destroy join points, following #21716.

- - - - -
251471e7 by Matthew Pickering at 2022-06-28T19:02:41-04:00
Cleanup BuiltInSyntax vs UserSyntax

There was some confusion about whether FUN/TYPE/One/Many should be
BuiltInSyntax or UserSyntax. The answer is certainly UserSyntax as
BuiltInSyntax is for things which are directly constructed by the parser
rather than going through normal renaming channels.

I fixed all the obviously wrong places I could find and added a test for
the original bug which was caused by this (#21752)

Fixes #21752 #20695 #18302

- - - - -
0e22f16c by Ben Gamari at 2022-06-28T19:03:16-04:00
template-haskell: Bump version to 2.19.0.0

Bumps text and exceptions submodules due to bounds.

- - - - -
bbe6f10e by Emily Bourke at 2022-06-29T08:23:13+00:00
Tiny tweak to `IOPort#` documentation

The exclamation mark and bracket don’t seem to make sense here. I’ve
looked through the history, and I don’t think they’re deliberate – possibly
a copy-and-paste error.
- - - - -
70e47489 by Dominik Peteler at 2022-06-29T19:26:31-04:00
Remove `CoreOccurAnal` constructor of the `CoreToDo` type

It was dead code since the last occurence in an expression context got
removed in 71916e1c018dded2e68d6769a2dbb8777da12664.

- - - - -
d0722170 by nineonine at 2022-07-01T08:15:56-04:00
Fix panic with UnliftedFFITypes+CApiFFI (#14624)

When declaring foreign import using CAPI calling convention, using
unlifted unboxed types would result in compiler panic. There was
an attempt to fix the situation in #9274, however it only addressed
some of the ByteArray cases.

This patch fixes other missed cases for all prims that may be used
as basic foreign types.

- - - - -
eb043148 by Douglas Wilson at 2022-07-01T08:16:32-04:00
rts: gc stats: account properly for copied bytes in sequential collections

We were not updating the [copied,any_work,scav_find_work, max_n_todo_overflow]
counters during sequential collections. As well, we were double counting for
parallel collections.

To fix this we add an `else` clause to the `if (is_par_gc())`.

The par_* counters do not need to be updated in the sequential case
because they must be 0.

- - - - -
f95edea9 by Matthew Pickering at 2022-07-01T19:21:55-04:00
desugar: Look through ticks when warning about possible literal overflow

Enabling `-fhpc` or `-finfo-table-map` would case a tick to end up
between the appliation of `neg` to its argument. This defeated the
special logic which looks for `NegApp ... (HsOverLit` to warn about
possible overflow if a user writes a negative literal (without out
NegativeLiterals) in their code.

Fixes #21701

- - - - -
f25c8d03 by Matthew Pickering at 2022-07-01T19:22:31-04:00
ci: Fix definition of slow-validate flavour (so that -dlint) is passed

In this embarassing sequence of events we were running slow-validate
without -dlint.

- - - - -
bf7991b0 by Mike Pilgrem at 2022-07-02T10:12:04-04:00
Identify the extistence of the `runhaskell` command and that it is equivalent to the `runghc` command. Add an entry to the index for `runhaskell`. See https://gitlab.haskell.org/ghc/ghc/-/issues/21411
- - - - -
9e79f6d0 by Simon Jakobi at 2022-07-02T10:12:39-04:00
Data.Foldable1: Remove references to Foldable-specific note

...as discussed in
https://gitlab.haskell.org/ghc/ghc/-/merge_requests/8495#note_439455.

- - - - -
3a8970ac by romes at 2022-07-03T14:11:31-04:00
TTG: Move HsModule to L.H.S

Move the definition of HsModule defined in GHC.Hs to
Language.Haskell.Syntax with an added TTG parameter and corresponding
extension fields.

This is progress towards having the haskell-syntax package, as described
in #21592

- - - - -
f9f80995 by romes at 2022-07-03T14:11:31-04:00
TTG: Move ImpExp client-independent bits to L.H.S.ImpExp

Move the GHC-independent definitions from GHC.Hs.ImpExp to
Language.Haskell.Syntax.ImpExp with the required TTG extension fields
such as to keep the AST independent from GHC.

This is progress towards having the haskell-syntax package, as described
in #21592

Bumps haddock submodule

- - - - -
c43dbac0 by romes at 2022-07-03T14:11:31-04:00
Refactor ModuleName to L.H.S.Module.Name

ModuleName used to live in GHC.Unit.Module.Name. In this commit, the
definition of ModuleName and its associated functions are moved to
Language.Haskell.Syntax.Module.Name according to the current plan
towards making the AST GHC-independent.

The instances for ModuleName for Outputable, Uniquable and Binary were
moved to the module in which the class is defined because these instances
depend on GHC.

The instance of Eq for ModuleName is slightly changed to no longer
depend on unique explicitly and instead uses FastString's instance of
Eq.

- - - - -
2635c6f2 by konsumlamm at 2022-07-03T14:12:11-04:00
Expand `Ord` instance for `Down`

Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/23#issuecomment-1172932610

- - - - -
36fba0df by Anselm Schüler at 2022-07-04T05:06:42+00:00
Add applyWhen to Data.Function per CLC prop

Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/71#issuecomment-1165830233

- - - - -
3b13aab1 by Matthew Pickering at 2022-07-04T15:15:00-04:00
hadrian: Don't read package environments in ghc-stage1 wrapper

The stage1 compiler may be on the brink of existence and not have even a
working base library. You may have installed packages globally with a
similar stage2 compiler which will then lead to arguments such as
--show-iface not even working because you are passing too many package
flags. The solution is simple, don't read these implicit files.

Fixes #21803

- - - - -
aba482ea by Andreas Klebinger at 2022-07-04T17:55:55-04:00
Ticky:Make json info a separate field.

Fixes #21233

- - - - -
74f3867d by Matthew Pickering at 2022-07-04T17:56:30-04:00
Add docs:<pkg> command to hadrian to build docs for just one package

- - - - -
418afaf1 by Matthew Pickering at 2022-07-04T17:56:30-04:00
upload-docs: propagate publish correctly in upload_sdist

- - - - -
ed793d7a by Matthew Pickering at 2022-07-04T17:56:30-04:00
docs-upload: Fix upload script when no packages are listed

- - - - -
d002c6e0 by Matthew Pickering at 2022-07-04T17:56:30-04:00
hadrian: Add --haddock-base-url option for specifying base-url when generating docs

The motiviation for this flag is to be able to produce documentation
which is suitable for uploading for hackage, ie, the cross-package links
work correctly.

There are basically three values you want to set this to:

* off - default, base_url = ../%pkg% which works for local browsing
* on - no argument , base_url = https:://hackage.haskell.org/package/%pkg%/docs - for hackage docs upload
* on - argument, for example, base_url = http://localhost:8080/package/%pkg%/docs for testing the documentation.

The `%pkg%` string is a template variable which is replaced with the
package identifier for the relevant package.

This is one step towards fixing #21749

- - - - -
41eb749a by Matthew Pickering at 2022-07-04T17:56:31-04:00
Add nightly job for generating docs suitable for hackage upload

- - - - -
620ee7ed by Matthew Pickering at 2022-07-04T17:57:05-04:00
ghci: Support :set prompt in multi repl

This adds supports for various :set commands apart from `:set <FLAG>` in
multi repl, this includes `:set prompt` and so-on.

Fixes #21796

- - - - -
b151b65e by Matthew Pickering at 2022-07-05T16:32:31-04:00
Vendor filepath inside template-haskell

Adding filepath as a dependency of template-haskell means that it can't
be reinstalled if any build-plan depends on template-haskell.

This is a temporary solution for the 9.4 release.

A longer term solution is to split-up the template-haskell package into
the wired-in part and a non-wired-in part which can be reinstalled. This
was deemed quite risky on the 9.4 release timescale.

Fixes #21738

- - - - -
c9347ecf by John Ericson at 2022-07-05T16:33:07-04:00
Factor fields of `CoreDoSimplify` into separate data type

This avoids some partiality. The work @mmhat is doing cleaning up and
modularizing `Core.Opt` will build on this nicely.

- - - - -
d0e74992 by Eric Lindblad at 2022-07-06T01:35:48-04:00
https urls
- - - - -
803e965c by Eric Lindblad at 2022-07-06T01:35:48-04:00
options and typos
- - - - -
5519baa5 by Eric Lindblad at 2022-07-06T01:35:48-04:00
grammar
- - - - -
4ddc1d3e by Eric Lindblad at 2022-07-06T01:35:48-04:00
sources
- - - - -
c95c2026 by Matthew Pickering at 2022-07-06T01:35:48-04:00
Fix lint warnings in bootstrap.py

- - - - -
86ced2ad by romes at 2022-07-06T01:36:23-04:00
Restore Eq instance of ImportDeclQualifiedStyle

Fixes #21819

- - - - -
3547e264 by romes at 2022-07-06T13:50:27-04:00
Prune L.H.S modules of GHC dependencies

Move around datatypes, functions and instances that are GHC-specific out
of the `Language.Haskell.Syntax.*` modules to reduce the GHC
dependencies in them -- progressing towards #21592

Creates a module `Language.Haskell.Syntax.Basic` to hold basic
definitions required by the other L.H.S modules (and don't belong in any
of them)

- - - - -
e4eea07b by romes at 2022-07-06T13:50:27-04:00
TTG: Move CoreTickish out of LHS.Binds

Remove the `[CoreTickish]` fields from datatype `HsBindLR idL idR` and
move them to the extension point instance, according to the plan
outlined in #21592 to separate the base AST from the GHC specific bits.

- - - - -
acc1816b by romes at 2022-07-06T13:50:27-04:00
TTG for ForeignImport/Export

Add a TTG parameter to both `ForeignImport` and `ForeignExport` and,
according to #21592, move the GHC-specific bits in them and in the other
AST data types related to foreign imports and exports to the TTG
extension point.

- - - - -
371c5ecf by romes at 2022-07-06T13:50:27-04:00
TTG for HsTyLit

Add TTG parameter to `HsTyLit` to move the GHC-specific `SourceText`
fields to the extension point and out of the base AST.

Progress towards #21592

- - - - -
fd379d1b by romes at 2022-07-06T13:50:27-04:00
Remove many GHC dependencies from L.H.S

Continue to prune the `Language.Haskell.Syntax.*` modules out of GHC
imports according to the plan in the linked issue.

Moves more GHC-specific declarations to `GHC.*` and brings more required
GHC-independent declarations to `Language.Haskell.Syntax.*` (extending
e.g. `Language.Haskell.Syntax.Basic`).

Progress towards #21592

Bump haddock submodule for !8308

-------------------------
Metric Decrease:
    hard_hole_fits
-------------------------

- - - - -
c5415bc5 by Alan Zimmerman at 2022-07-06T13:50:27-04:00
Fix exact printing of the HsRule name

Prior to this branch, the HsRule name was

    XRec pass (SourceText,RuleName)

and there is an ExactPrint instance for (SourceText, RuleName).

The SourceText has moved to a different location, so synthesise the
original to trigger the correct instance when printing.

We need both the SourceText and RuleName when exact printing, as it is
possible to have a NoSourceText variant, in which case we fall back to
the FastString.

- - - - -
665fa5a7 by Matthew Pickering at 2022-07-06T13:51:03-04:00
driver: Fix issue with module loops and multiple home units

We were attempting to rehydrate all dependencies of a particular module,
but we actually only needed to rehydrate those of the current package
(as those are the ones participating in the loop).

This fixes loading GHC into a multi-unit session.

Fixes #21814

- - - - -
bbcaba6a by Andreas Klebinger at 2022-07-06T13:51:39-04:00
Remove a bogus #define from ClosureMacros.h

- - - - -
fa59223b by Tamar Christina at 2022-07-07T23:23:57-04:00
winio: make consoleReadNonBlocking not wait for any events at all.

- - - - -
42c917df by Adam Sandberg Ericsson at 2022-07-07T23:24:34-04:00
rts: allow NULL to be used as an invalid StgStablePtr

- - - - -
3739e565 by Andreas Schwab at 2022-07-07T23:25:10-04:00
RTS: Add stack marker to StgCRunAsm.S

Every object file must be properly marked for non-executable stack, even if it
contains no code.

- - - - -
a889bc05 by Ben Gamari at 2022-07-07T23:25:45-04:00
Bump unix submodule

Adds `config.sub` to unix's `.gitignore`, fixing #19574.

- - - - -
3609a478 by Matthew Pickering at 2022-07-09T11:11:58-04:00
ghci: Fix most calls to isLoaded to work in multi-mode

The most egrarious thing this fixes is the report about the total number
of loaded modules after starting a session.

Ticket #20889

- - - - -
fc183c90 by Matthew Pickering at 2022-07-09T11:11:58-04:00
Enable :edit command in ghci multi-mode.

This works after the last change to isLoaded.

Ticket #20888

- - - - -
46050534 by Simon Peyton Jones at 2022-07-09T11:12:34-04:00
Fix a scoping bug in the Specialiser

In the call to `specLookupRule` in `already_covered`, in `specCalls`,
we need an in-scope set that includes the free vars of the arguments.
But we simply were not guaranteeing that: did not include the
`rule_bndrs`.

Easily fixed.  I'm not sure how how this bug has lain for quite
so long without biting us.

Fixes #21828.

- - - - -
6e8d9056 by Simon Peyton Jones at 2022-07-12T13:26:52+00:00
Edit Note [idArity varies independently of dmdTypeDepth]

...and refer to it in GHC.Core.Lint.lintLetBind.

Fixes #21452

- - - - -
89ba4655 by Simon Peyton Jones at 2022-07-12T13:26:52+00:00
Tiny documentation wibbles (comments only)

- - - - -
61a46c6d by Eric Lindblad at 2022-07-13T08:28:29-04:00
fix readme
- - - - -
61babb5e by Eric Lindblad at 2022-07-13T08:28:29-04:00
fix bootstrap
- - - - -
8b417ad5 by Eric Lindblad at 2022-07-13T08:28:29-04:00
tarball
- - - - -
e9d9f078 by Zubin Duggal at 2022-07-13T14:00:18-04:00
hie-files: Fix scopes for deriving clauses and instance signatures (#18425)

- - - - -
c4989131 by Zubin Duggal at 2022-07-13T14:00:18-04:00
hie-files: Record location of filled in default method bindings

This is useful for hie files to reconstruct the evidence that default methods
depend on.

- - - - -
9c52e7fc by Zubin Duggal at 2022-07-13T14:00:18-04:00
testsuite: Factor out common parts from hiefile tests

- - - - -
6a9e4493 by sheaf at 2022-07-13T14:00:56-04:00
Hadrian: update documentation of settings

The documentation for key-value settings was a bit out of date.
This patch updates it to account for `cabal.configure.opts` and
`hsc2hs.run.opts`.

The user-settings document was also re-arranged, to make the key-value
settings more prominent (as it doesn't involve changing the Hadrian
source code, and thus doesn't require any recompilation of Hadrian).

- - - - -
a2f142f8 by Zubin Duggal at 2022-07-13T20:43:32-04:00
Fix potential space leak that arise from ModuleGraphs retaining references
to previous ModuleGraphs, in particular the lazy `mg_non_boot` field.
This manifests in `extendMG`.

Solution: Delete `mg_non_boot` as it is only used for `mgLookupModule`, which
is only called in two places in the compiler, and should only be called at most
once for every home unit:

GHC.Driver.Make:
      mainModuleSrcPath :: Maybe String
      mainModuleSrcPath = do
        ms <- mgLookupModule mod_graph (mainModIs hue)
        ml_hs_file (ms_location ms)

GHCI.UI:
listModuleLine modl line = do
   graph <- GHC.getModuleGraph
   let this = GHC.mgLookupModule graph modl

Instead `mgLookupModule` can be a linear function that looks through the entire
list of `ModuleGraphNodes`

Fixes #21816

- - - - -
dcf8b30a by Ben Gamari at 2022-07-13T20:44:08-04:00
rts: Fix AdjustorPool bitmap manipulation

Previously the implementation of bitmap_first_unset assumed that
`__builtin_clz` would accept `uint8_t` however it apparently rather
extends its argument to `unsigned int`.

To fix this we simply revert to a naive implementation since handling
the various corner cases with `clz` is quite tricky. This should be
fine given that AdjustorPool isn't particularly hot. Ideally we would
have a single, optimised bitmap implementation in the RTS but I'll leave
this for future work.

Fixes #21838.

- - - - -
ad8f3e15 by Luite Stegeman at 2022-07-16T07:20:36-04:00
Change GHCi bytecode return convention for unlifted datatypes.

This changes the bytecode return convention for unlifted
algebraic datatypes to be the same as for lifted
types, i.e. ENTER/PUSH_ALTS instead of
RETURN_UNLIFTED/PUSH_ALTS_UNLIFTED

Fixes #20849

- - - - -
5434d1a3 by Colten Webb at 2022-07-16T07:21:15-04:00
Compute record-dot-syntax types
Ensures type information for record-dot-syntax
is included in HieASTs. See #21797

- - - - -
89d169ec by Colten Webb at 2022-07-16T07:21:15-04:00
Add record-dot-syntax test

- - - - -
4beb9f3c by Ben Gamari at 2022-07-16T07:21:51-04:00
Document RuntimeRep polymorphism limitations of catch#, et al

As noted in #21868, several primops accepting continuations producing
RuntimeRep-polymorphic results aren't nearly as polymorphic as their
types suggest. Document this limitation and adapt the `UnliftedWeakPtr`
test to avoid breaking this limitation in `keepAlive#`.

- - - - -
4ef1c65d by Ben Gamari at 2022-07-16T07:21:51-04:00
Make keepAlive# out-of-line

This is a naive approach to fixing the unsoundness noticed in #21708.
Specifically, we remove the lowering of `keepAlive#` via CorePrep and
instead turn it into an out-of-line primop.
This is simple, inefficient (since the continuation must now be heap
allocated), but good enough for 9.4.1. We will revisit this
(particiularly via #16098) in a future release.

Metric Increase:
    T4978
    T7257
    T9203

- - - - -
1bbff35d by Greg Steuck at 2022-07-16T07:22:29-04:00
Suppress extra output from configure check for c++ libraries

- - - - -
3acbd7ad by Ben Gamari at 2022-07-16T07:23:04-04:00
rel-notes: Drop mention of #21745 fix

Since we have backported the fix to 9.4.1.

- - - - -
b27c2774 by Dominik Peteler at 2022-07-16T07:23:43-04:00
Align the behaviour of `dopt` and `log_dopt`

Before the behaviour of `dopt` and `logHasDumpFlag` (and the underlying
function `log_dopt`) were different as the latter did not take the
verbosity level into account. This led to problems during the
refactoring as we cannot simply replace calls to `dopt` with calls to
`logHasDumpFlag`.

In addition to that a subtle bug in the GHC module was fixed:
`setSessionDynFlags` did not update the logger and as a consequence the
verbosity value of the logger was not set appropriately.

Fixes #21861

- - - - -
28347d71 by Douglas Wilson at 2022-07-16T13:25:06-04:00
rts: forkOn context switches the target capability

Fixes #21824

- - - - -
f1c44991 by Ben Gamari at 2022-07-16T13:25:41-04:00
cmm: Eliminate orphan Outputable instances

Here we reorganize `GHC.Cmm` to eliminate the orphan `Outputable` and
`OutputableP` instances for the Cmm AST. This makes it significantly
easier to use the Cmm pretty-printers in tracing output without
incurring module import cycles.

- - - - -
f2e5e763 by Ben Gamari at 2022-07-16T13:25:41-04:00
cmm: Move toBlockList to GHC.Cmm

- - - - -
fa092745 by Ben Gamari at 2022-07-16T13:25:41-04:00
compiler: Add haddock sections to GHC.Utils.Panic

- - - - -
097759f9 by Ben Gamari at 2022-07-16T13:26:17-04:00
configure: Don't override Windows CXXFLAGS

At some point we used the clang distribution from msys2's `MINGW64`
environment for our Windows toolchain. This defaulted to using libgcc
and libstdc++ for its runtime library. However, we found for a variety
of reasons that compiler-rt, libunwind, and libc++ were more reliable,
consequently we explicitly overrode the CXXFLAGS to use these.

However, since then we have switched to use the `CLANG64` packaging,
which default to these already. Consequently we can drop these
arguments, silencing some redundant argument warnings from clang.

Fixes #21669.

- - - - -
e38a2684 by Ben Gamari at 2022-07-16T23:50:36-04:00
rts/linker/Elf: Check that there are no NULL ctors

- - - - -
616365b0 by Ben Gamari at 2022-07-16T23:50:36-04:00
rts/linker/Elf: Introduce support for invoking finalizers on unload

Addresses #20494.

- - - - -
cdd3be20 by Ben Gamari at 2022-07-16T23:50:36-04:00
testsuite: Add T20494

- - - - -
03c69d8d by Ben Gamari at 2022-07-16T23:50:36-04:00
rts/linker/PEi386: Rename finit field to fini

fini is short for "finalizer", which does not contain a "t".

- - - - -
033580bc by Ben Gamari at 2022-07-16T23:50:36-04:00
rts/linker/PEi386: Refactor handling of oc->info

Previously we would free oc->info after running initializers. However,
we can't do this is we want to also run finalizers.

Moreover, freeing oc->info so early was wrong for another reason:
we will need it in order to unregister the exception tables (see the
call to `RtlDeleteFunctionTable`).

In service of #20494.

- - - - -
f17912e4 by Ben Gamari at 2022-07-16T23:50:36-04:00
rts/linker/PEi386: Add finalization support

This implements #20494 for the PEi386 linker.

Happily, this also appears to fix `T9405`, resolving #21361.

- - - - -
2cd75550 by Ben Gamari at 2022-07-16T23:50:36-04:00
Loader: Implement gnu-style -l:$path syntax

Gnu ld allows `-l` to be passed an absolute file path,
signalled by a `:` prefix. Implement this in the GHC's
loader search logic.

- - - - -
5781a360 by Ben Gamari at 2022-07-16T23:50:36-04:00
Statically-link against libc++ on Windows

Unfortunately on Windows we have no RPATH-like facility, making dynamic
linking extremely fragile. Since we cannot assume that the user will
add their GHC installation to `$PATH` (and therefore their DLL
search path) we cannot assume that the loader will be able to locate our
`libc++.dll`. To avoid this, we instead statically link against `libc++.a` on
Windows.

Fixes #21435.

- - - - -
8e2e883b by Ben Gamari at 2022-07-16T23:50:36-04:00
rts/linker/PEi386: Ensure that all .ctors/.dtors sections are run

It turns out that PE objects may have multiple `.ctors`/`.dtors`
sections but the RTS linker had assumed that there was only one. Fix
this.

Fixes #21618.

- - - - -
fba04387 by Ben Gamari at 2022-07-16T23:50:36-04:00
rts/linker/PEi386: Respect dtor/ctor priority

Previously we would run constructors and destructors in arbitrary order
despite explicit priorities.

Fixes #21847.

- - - - -
1001952f by Ben Gamari at 2022-07-16T23:50:36-04:00
testsuite: Add test for #21618 and #21847

- - - - -
6f3816af by Ben Gamari at 2022-07-16T23:50:36-04:00
rts/linker/PEi386: Fix exception unwind unregistration

RtlDeleteFunctionTable expects a pointer to the .pdata section
yet we passed it the .xdata section.

Happily, this fixes #21354.

- - - - -
d9bff44c by Ben Gamari at 2022-07-16T23:50:36-04:00
rts/linker/MachO: Drop dead code

- - - - -
d161e6bc by Ben Gamari at 2022-07-16T23:50:36-04:00
rts/linker/MachO: Use section flags to identify initializers

- - - - -
fbb17110 by Ben Gamari at 2022-07-16T23:50:36-04:00
rts/linker/MachO: Introduce finalizer support

- - - - -
5b0ed8a8 by Ben Gamari at 2022-07-16T23:50:37-04:00
testsuite: Use system-cxx-std-lib instead of config.stdcxx_impl

- - - - -
6c476e1a by Ben Gamari at 2022-07-16T23:50:37-04:00
rts/linker/Elf: Work around GCC 6 init/fini behavior

It appears that GCC 6t (at least on i386) fails to give
init_array/fini_array sections the correct SHT_INIT_ARRAY/SHT_FINI_ARRAY
section types, instead marking them as SHT_PROGBITS. This caused T20494
to fail on Debian.

- - - - -
5f8203b8 by Ben Gamari at 2022-07-16T23:50:37-04:00
testsuite: Mark T13366Cxx as unbroken on Darwin

- - - - -
1fd2f851 by Ben Gamari at 2022-07-16T23:50:37-04:00
rts/linker: Fix resolution of __dso_handle on Darwin

Darwin expects a leading underscore.

- - - - -
a2dc00f3 by Ben Gamari at 2022-07-16T23:50:37-04:00
rts/linker: Clean up section kinds

- - - - -
aeb1a7c3 by Ben Gamari at 2022-07-16T23:50:37-04:00
rts/linker: Ensure that __cxa_finalize is called on code unload

- - - - -
028f081e by Ben Gamari at 2022-07-16T23:51:12-04:00
testsuite: Fix T11829 on Centos 7

It appears that Centos 7 has a more strict C++ compiler than most
distributions since std::runtime_error is defined in <stdexcept> rather
than <exception>. In T11829 we mistakenly imported the latter.

- - - - -
a10584e8 by Ben Gamari at 2022-07-17T22:30:32-04:00
hadrian: Rename documentation directories for consistency with make

* Rename `docs` to `doc`
* Place pdf documentation in `doc/` instead of `doc/pdfs/`

Fixes #21164.

- - - - -
b27c5947 by Anselm Schüler at 2022-07-17T22:31:11-04:00
Fix incorrect proof of applyWhen’s properties

- - - - -
eb031a5b by Matthew Pickering at 2022-07-18T08:04:47-04:00
hadrian: Add multi:<pkg> and multi targets for starting a multi-repl

This patch adds support to hadrian for starting a multi-repl containing
all the packages which stage0 can build. In particular, there is the new
user-facing command:

```
./hadrian/ghci-multi
```

which when executed will start a multi-repl containing the `ghc` package
and all it's dependencies.

This is implemented by two new hadrian targets:

```
./hadrian/build multi:<pkg>
```

Construct the arguments for a multi-repl session where the top-level
package is <pkg>. For example, `./hadrian/ghci-multi` is implemented
using `multi:ghc` target.

There is also the `multi` command which constructs a repl for everything
in stage0 which we can build.

- - - - -
19e7cac9 by Eric Lindblad at 2022-07-18T08:05:27-04:00
changelog typo
- - - - -
af6731a4 by Eric Lindblad at 2022-07-18T08:05:27-04:00
typos

- - - - -
415468fe by Simon Peyton Jones at 2022-07-18T16:36:54-04:00
Refactor SpecConstr to use treat bindings uniformly

This patch, provoked by #21457, simplifies SpecConstr by treating
top-level and nested bindings uniformly (see the new scBind).

* Eliminates the mysterious scTopBindEnv

* Refactors scBind to handle top-level and nested definitions
  uniformly.

* But, for now at least, continues the status quo of not doing
  SpecConstr for top-level non-recursive bindings.  (In contrast
  we do specialise nested non-recursive bindings, although the
  original paper did not; see Note [Local let bindings].)

  I tried the effect of specialising top-level non-recursive
  bindings (which is now dead easy to switch on, unlike before)
  but found some regressions, so I backed off.  See !8135.

It's a pure refactoring.  I think it'll do a better job in a few
cases, but there is no regression test.

- - - - -
d4d3fe6e by Andreas Klebinger at 2022-07-18T16:37:29-04:00
Rule matching: Don't compute the FVs if we don't look at them.

- - - - -
5f907371 by Simon Peyton Jones at 2022-07-18T16:38:04-04:00
White space only in FamInstEnv

- - - - -
ae3b3b62 by Simon Peyton Jones at 2022-07-18T16:38:04-04:00
Make transferPolyIdInfo work for CPR

I don't know why this hasn't bitten us before, but it was plain wrong.

- - - - -
9bdfdd98 by Simon Peyton Jones at 2022-07-18T16:38:04-04:00
Inline mapAccumLM

This function is called in inner loops in the compiler, and it's
overloaded and higher order.  Best just to inline it.

This popped up when I was looking at something else.  I think
perhaps GHC is delicately balanced on the cusp of inlining this
automatically.

- - - - -
d0b806ff by Simon Peyton Jones at 2022-07-18T16:38:04-04:00
Make SetLevels honour floatConsts

This fix,  in the definition of profitableFloat,
is just for consistency. `floatConsts` should
do what it says!

I don't think it'll affect anything much, though.

- - - - -
d1c25a48 by Simon Peyton Jones at 2022-07-18T16:38:04-04:00
Refactor wantToUnboxArg a bit

* Rename GHC.Core.Opt.WorkWrap.Utils.wantToUnboxArg to canUnboxArg
  and similarly wantToUnboxResult to canUnboxResult.

* Add GHC.Core.Opt.DmdAnal.wantToUnboxArg as a wrapper for
  the (new) GHC.Core.Opt.WorkWrap.Utils.canUnboxArg,
  avoiding some yukky duplication.

  I decided it was clearer to give it a new data type for its
  return type, because I nedeed the FD_RecBox case which was not
  otherwise readiliy expressible.

* Add dcpc_args to WorkWrap.Utils.DataConPatContext for the payload

* Get rid of the Unlift constructor of UnboxingDecision, eliminate
  two panics, and two arguments to canUnboxArg (new name).  Much
  nicer now.

- - - - -
6d8a715e by Teo Camarasu at 2022-07-18T16:38:44-04:00
Allow running memInventory when the concurrent nonmoving gc is enabled

If the nonmoving gc is enabled and we are using a threaded RTS,
we now try to grab the collector mutex to avoid memInventory and
the collection racing.

Before memInventory was disabled.

- - - - -
aa75bbde by Ben Gamari at 2022-07-18T16:39:20-04:00
gitignore: don't ignore all aclocal.m4 files

While GHC's own aclocal.m4 is generated by the aclocal tool, other
packages' aclocal.m4 are committed in the repository. Previously
`.gitignore` included an entry which covered *any* file named
`aclocal.m4`, which lead to quite some confusion (e.g. see #21740).
Fix this by modifying GHC's `.gitignore` to only cover GHC's own
`aclocal.m4`.

- - - - -
4b98c5ce by Boris Lykah at 2022-07-19T02:34:12-04:00
Add mapAccumM, forAccumM to Data.Traversable

Approved by Core Libraries Committee in
https://github.com/haskell/core-libraries-committee/issues/65#issuecomment-1186275433

- - - - -
bd92182c by Ben Gamari at 2022-07-19T02:34:47-04:00
configure: Use AC_PATH_TOOL to detect tools

Previously we used AC_PATH_PROG which, as noted by #21601, does not
look for tools with a target prefix,
breaking cross-compilation.

Fixes #21601.

- - - - -
e8c07aa9 by Matthew Pickering at 2022-07-19T10:07:53-04:00
driver: Fix implementation of -S

We were failing to stop before running the assembler so the object file
was also created.

Fixes #21869

- - - - -
e2f0094c by Ben Gamari at 2022-07-19T10:08:28-04:00
rts/ProfHeap: Ensure new Censuses are zeroed

When growing the Census array ProfHeap previously neglected to
zero the new part of the array. Consequently `freeEra` would attempt to
free random words that often looked suspiciously like pointers.

Fixes #21880.

- - - - -
81d65f7f by sheaf at 2022-07-21T15:37:22+02:00
Make withDict opaque to the specialiser

As pointed out in #21575, it is not sufficient to set withDict to inline
after the typeclass specialiser, because we might inline withDict in one
module and then import it in another, and we run into the same problem.
This means we could still end up with incorrect runtime results because
the typeclass specialiser would assume that distinct typeclass evidence
terms at the same type are equal, when this is not necessarily the case
when using withDict.

Instead, this patch introduces a new magicId, 'nospec', which is only
inlined in CorePrep. We make use of it in the definition of withDict
to ensure that the typeclass specialiser does not common up distinct
typeclass evidence terms.

Fixes #21575

- - - - -
9a3e1f31 by Dominik Peteler at 2022-07-22T08:18:40-04:00
Refactored Simplify pass

 * Removed references to driver from GHC.Core.LateCC, GHC.Core.Simplify
   namespace and GHC.Core.Opt.Stats.
   Also removed services from configuration records.

 * Renamed GHC.Core.Opt.Simplify to GHC.Core.Opt.Simplify.Iteration.

 * Inlined `simplifyPgm` and renamed `simplifyPgmIO` to `simplifyPgm`
   and moved the Simplify driver to GHC.Core.Opt.Simplify.

 * Moved `SimplMode` and `FloatEnable` to GHC.Core.Opt.Simplify.Env.

 * Added a configuration record `TopEnvConfig` for the `SimplTopEnv` environment
   in GHC.Core.Opt.Simplify.Monad.

 * Added `SimplifyOpts` and `SimplifyExprOpts`. Provide initialization functions
   for those in a new module GHC.Driver.Config.Core.Opt.Simplify.
   Also added initialization functions for `SimplMode` to that module.

 * Moved `CoreToDo` and friends to a new module GHC.Core.Pipeline.Types
   and the counting types and functions (`SimplCount` and `Tick`) to new
   module GHC.Core.Opt.Stats.

 * Added getter functions for the fields of `SimplMode`. The pedantic bottoms
   option and the platform are retrieved from the ArityOpts and RuleOpts and the
   getter functions allow us to retrieve values from `SpecEnv` without the
   knowledge where the data is stored exactly.

 * Moved the coercion optimization options from the top environment to
   `SimplMode`. This way the values left in the top environment are those
   dealing with monadic functionality, namely logging, IO related stuff and
   counting. Added a note "The environments of the Simplify pass".

 * Removed `CoreToDo` from GHC.Core.Lint and GHC.CoreToStg.Prep and got rid of
   `CoreDoSimplify`. Pass `SimplifyOpts` in the `CoreToDo` type instead.

 * Prep work before removing `InteractiveContext` from `HscEnv`.

- - - - -
2c5991cc by Simon Peyton Jones at 2022-07-22T08:18:41-04:00
Make the specialiser deal better with specialised methods

This patch fixes #21848, by being more careful to update unfoldings
in the type-class specialiser.

See the new Note [Update unfolding after specialisation]

Now that we are being so much more careful about unfoldings,
it turned out that I could dispense with se_interesting, and
all its tricky corners. Hooray.  This fixes #21368.

- - - - -
ae166635 by Ben Gamari at 2022-07-22T08:18:41-04:00
ghc-boot: Clean up UTF-8 codecs

In preparation for moving the UTF-8 codecs into `base`:

* Move them to GHC.Utils.Encoding.UTF8
* Make names more consistent
* Add some Haddocks

- - - - -
e8ac91db by Ben Gamari at 2022-07-22T08:18:41-04:00
base: Introduce GHC.Encoding.UTF8

Here we copy a subset of the UTF-8 implementation living in `ghc-boot`
into `base`, with the intent of dropping the former in the future. For
this reason, the `ghc-boot` copy is now CPP-guarded on
`MIN_VERSION_base(4,18,0)`.

Naturally, we can't copy *all* of the functions defined by `ghc-boot` as
some depend upon `bytestring`; we rather just copy those which only
depend upon `base` and `ghc-prim`.

Further consolidation?
----------------------

Currently GHC ships with at least five UTF-8 implementations:

* the implementation used by GHC in `ghc-boot:GHC.Utils.Encoding`; this
  can be used at a number of types including `Addr#`, `ByteArray#`,
  `ForeignPtr`, `Ptr`, `ShortByteString`, and `ByteString`. Most of this
  can be removed in GHC 9.6+2, when the copies in `base` will become
  available to `ghc-boot`.
* the copy of the `ghc-boot` definition now exported by
  `base:GHC.Encoding.UTF8`. This can be used at `Addr#`, `Ptr`,
  `ByteArray#`, and `ForeignPtr`
* the decoder used by `unpackCStringUtf8#` in `ghc-prim:GHC.CString`;
  this is specialised at `Addr#`.
* the codec used by the IO subsystem in `base:GHC.IO.Encoding.UTF8`;
  this is specialised at `Addr#` but, unlike the above, supports
  recovery in the presence of partial codepoints (since in IO contexts
  codepoints may be broken across buffers)
* the implementation provided by the `text` library

This does seem a tad silly. On the other hand, these implementations
*do* materially differ from one another (e.g. in the types they support,
the detail in errors they can report, and the ability to recover from
partial codepoints). Consequently, it's quite unclear that further
consolidate would be worthwhile.

- - - - -
f9ad8025 by Ben Gamari at 2022-07-22T08:18:41-04:00
Add a Note summarising GHC's UTF-8 implementations

GHC has a somewhat dizzying array of UTF-8 implementations. This note
describes why this is the case.

- - - - -
72dfad3d by Ben Gamari at 2022-07-22T08:18:42-04:00
upload_ghc_libs: Fix path to documentation

The documentation was moved in a10584e8df9b346cecf700b23187044742ce0b35
but this one occurrence was note updated.

Finally closes #21164.

- - - - -
a8b150e7 by sheaf at 2022-07-22T08:18:44-04:00
Add test for #21871

This adds a test for #21871, which was fixed by the No Skolem Info
rework (MR !7105).

Fixes #21871

- - - - -
6379f942 by sheaf at 2022-07-22T08:18:46-04:00
Add test for #21360

The way record updates are typechecked/desugared changed in MR !7981.
Because we desugar in the typechecker to a simple case expression, the
pattern match checker becomes able to spot the long-distance information
and avoid emitting an incorrect pattern match warning.

Fixes #21360

- - - - -
ce0cd12c by sheaf at 2022-07-22T08:18:47-04:00
Hadrian: don't try to build "unix" on Windows
- - - - -
dc27e15a by Simon Peyton Jones at 2022-07-25T09:42:01-04:00
Implement DeepSubsumption

This MR adds the language extension -XDeepSubsumption, implementing
GHC proposal #511.  This change mitigates the impact of GHC proposal

The changes are highly localised, by design.  See Note [Deep subsumption]
in GHC.Tc.Utils.Unify.

The main changes are:

* Add -XDeepSubsumption, which is on by default in Haskell98 and Haskell2010,
  but off in Haskell2021.

  -XDeepSubsumption largely restores the behaviour before the "simple subsumption" change.
  -XDeepSubsumpition has a similar flavour as -XNoMonoLocalBinds:
  it makes type inference more complicated and less predictable, but it
  may be convenient in practice.

* The main changes are in:
  * GHC.Tc.Utils.Unify.tcSubType, which does deep susumption and eta-expanansion
  * GHC.Tc.Utils.Unify.tcSkolemiseET, which does deep skolemisation
  * In GHC.Tc.Gen.App.tcApp we call tcSubTypeNC to match the result
    type. Without deep subsumption, unifyExpectedType would be sufficent.

  See Note [Deep subsumption] in GHC.Tc.Utils.Unify.

* There are no changes to Quick Look at all.

* The type of `withDict` becomes ambiguous; so add -XAllowAmbiguousTypes to
  GHC.Magic.Dict

* I fixed a small but egregious bug in GHC.Core.FVs.varTypeTyCoFVs, where
  we'd forgotten to take the free vars of the multiplicity of an Id.

* I also had to fix tcSplitNestedSigmaTys

  When I did the shallow-subsumption patch
    commit 2b792facab46f7cdd09d12e79499f4e0dcd4293f
    Date:   Sun Feb 2 18:23:11 2020 +0000
    Simple subsumption

  I changed tcSplitNestedSigmaTys to not look through function arrows
  any more.  But that was actually an un-forced change.  This function
  is used only in

  * Improving error messages in GHC.Tc.Gen.Head.addFunResCtxt
  * Validity checking for default methods: GHC.Tc.TyCl.checkValidClass
  * A couple of calls in the GHCi debugger: GHC.Runtime.Heap.Inspect

  All to do with validity checking and error messages. Acutally its
  fine to look under function arrows here, and quite useful a test
  DeepSubsumption05 (a test motivated by a build failure in the
  `lens` package) shows.

  The fix is easy.  I added Note [tcSplitNestedSigmaTys].

- - - - -
e31ead39 by Matthew Pickering at 2022-07-25T09:42:01-04:00
Add tests that -XHaskell98 and -XHaskell2010 enable DeepSubsumption

- - - - -
67189985 by Matthew Pickering at 2022-07-25T09:42:01-04:00
Add DeepSubsumption08

- - - - -
5e93a952 by Simon Peyton Jones at 2022-07-25T09:42:01-04:00
Fix the interaction of operator sections and deep subsumption

Fixes DeepSubsumption08

- - - - -
918620d9 by Zubin Duggal at 2022-07-25T09:42:01-04:00
Add DeepSubsumption09

- - - - -
2a773259 by Gabriella Gonzalez at 2022-07-25T09:42:40-04:00
Default implementation for mempty/(<>)

Approved by: https://github.com/haskell/core-libraries-committee/issues/61

This adds a default implementation for `mempty` and `(<>)` along
with a matching `MINIMAL` pragma so that `Semigroup` and `Monoid`
instances can be defined in terms of `sconcat` / `mconcat`.

The description for each class has also been updated to include the
equivalent set of laws for the `sconcat`-only / `mconcat`-only
instances.

- - - - -
73836fc8 by Bryan Richter at 2022-07-25T09:43:16-04:00
ci: Disable (broken) perf-nofib

See #21859

- - - - -
c24ca5c3 by sheaf at 2022-07-25T09:43:58-04:00
Docs: clarify ConstraintKinds infelicity

GHC doesn't consistently require the ConstraintKinds extension to
be enabled, as it allows programs such as type families returning
a constraint without this extension.

MR !7784 fixes this infelicity, but breaking user programs was deemed
to not be worth it, so we document it instead.

Fixes #21061.

- - - - -
5f2fbd5e by Simon Peyton Jones at 2022-07-25T09:44:34-04:00
More improvements to worker/wrapper

This patch fixes #21888, and simplifies finaliseArgBoxities
by eliminating the (recently introduced) data type FinalDecision.

A delicate interaction meant that this patch
   commit d1c25a48154236861a413e058ea38d1b8320273f
   Date:   Tue Jul 12 16:33:46 2022 +0100
   Refactor wantToUnboxArg a bit

make worker/wrapper go into an infinite loop.  This patch
fixes it by narrowing the handling of case (B) of
Note [Boxity for bottoming functions], to deal only the
arguemnts that are type variables.  Only then do we drop
the trimBoxity call, which is what caused the bug.

I also
* Added documentation of case (B), which was previously
  completely un-mentioned.  And a regression test,
  T21888a, to test it.

* Made unboxDeeplyDmd stop at lazy demands.  It's rare anyway
  for a bottoming function to have a lazy argument (mainly when
  the data type is recursive and then we don't want to unbox
  deeply).  Plus there is Note [No lazy, Unboxed demands in
  demand signature]

* Refactored the Case equation for dmdAnal a bit, to do less
  redundant pattern matching.

- - - - -
b77d95f8 by Simon Peyton Jones at 2022-07-25T09:45:09-04:00
Fix a small buglet in tryEtaReduce

Gergo points out (#21801) that GHC.Core.Opt.Arity.tryEtaReduce was
making an ill-formed cast.  It didn't matter, because the subsequent
guard discarded it; but still worth fixing.  Spurious warnings are
distracting.

- - - - -
3bbde957 by Zubin Duggal at 2022-07-25T09:45:45-04:00
Fix #21889, GHCi misbehaves with Ctrl-C on Windows

On Windows, we create multiple levels of wrappers for GHCi which ultimately
execute ghc --interactive. In order to handle console events properly, each of
these wrappers must call FreeConsole() in order to hand off event processing to
the child process. See #14150.

In addition to this, FreeConsole must only be called from interactive processes (#13411).

This commit makes two changes to fix this situation:

1. The hadrian wrappers generated using `hadrian/bindist/cwrappers/version-wrapper.c` call `FreeConsole`
   if the CPP flag INTERACTIVE_PROCESS is set, which is set when we are generating a wrapper for GHCi.
2. The GHCi wrapper in `driver/ghci/` calls the `ghc-$VER.exe` executable which is not wrapped rather
   than calling `ghc.exe` is is wrapped on windows (and usually non-interactive, so can't call `FreeConsole`:

   Before:
   ghci-$VER.exe calls ghci.exe which calls ghc.exe which calls ghc-$VER.exe

   After:
   ghci-$VER.exe calls ghci.exe which calls ghc-$VER.exe

- - - - -
79f1b021 by Simon Jakobi at 2022-07-25T09:46:21-04:00
docs: Fix documentation of \cases

Fixes #21902.

- - - - -
e4bf9592 by sternenseemann at 2022-07-25T09:47:01-04:00
ghc-cabal: allow Cabal 3.8 to unbreak make build

When bootstrapping GHC 9.4.*, the build will fail when configuring
ghc-cabal as part of the make based build system due to this upper
bound, as Cabal has been updated to a 3.8 release.

Reference #21914, see especially
https://gitlab.haskell.org/ghc/ghc/-/issues/21914#note_444699

- - - - -
726d938e by Simon Peyton Jones at 2022-07-25T14:38:14-04:00
Fix isEvaldUnfolding and isValueUnfolding

This fixes (1) in #21831.  Easy, obviously correct.

- - - - -
5d26c321 by Simon Peyton Jones at 2022-07-25T14:38:14-04:00
Switch off eta-expansion in rules and unfoldings

I think this change will make little difference except to reduce
clutter.  But that's it -- if it causes problems we can switch it
on again.

- - - - -
d4fe2f4e by Simon Peyton Jones at 2022-07-25T14:38:14-04:00
Teach SpecConstr about typeDeterminesValue

This patch addresses #21831, point 2.  See
Note [generaliseDictPats] in SpecConstr

I took the opportunity to refactor the construction of specialisation
rules a bit, so that the rule name says what type we are specialising
at.

Surprisingly, there's a 20% decrease in compile time for test
perf/compiler/T18223. I took a look at it, and the code size seems the
same throughout. I did a quick ticky profile which seemed to show a
bit less substitution going on.  Hmm.  Maybe it's the "don't do
eta-expansion in stable unfoldings" patch, which is part of the
same MR as this patch.

Anyway, since it's a move in the right direction, I didn't think it
was worth looking into further.

Metric Decrease:
    T18223

- - - - -
65f7838a by Simon Peyton Jones at 2022-07-25T14:38:14-04:00
Add a 'notes' file in testsuite/tests/perf/compiler

This file is just a place to accumlate notes about particular
benchmarks, so that I don't keep re-inventing the wheel.

- - - - -
61faff40 by Simon Peyton Jones at 2022-07-25T14:38:50-04:00
Get the in-scope set right in FamInstEnv.injectiveBranches

There was an assert error, as Gergo pointed out in #21896.

I fixed this by adding an InScopeSet argument to tcUnifyTyWithTFs.
And also to GHC.Core.Unify.niFixTCvSubst.

I also took the opportunity to get a couple more InScopeSets right,
and to change some substTyUnchecked into substTy.

This MR touches a lot of other files, but only because I also took the
opportunity to introduce mkInScopeSetList, and use it.

- - - - -
4a7256a7 by Cheng Shao at 2022-07-25T20:41:55+00:00
Add location to cc phase

- - - - -
96811ba4 by Cheng Shao at 2022-07-25T20:41:55+00:00
Avoid as pipeline when compiling c

- - - - -
2869b66d by Cheng Shao at 2022-07-25T20:42:20+00:00
testsuite: Skip test cases involving -S when testing unregisterised GHC

We no longer generate .s files anyway.

Metric Decrease:
    MultiLayerModules
    T10421
    T13035
    T13701
    T14697
    T16875
    T18140
    T18304
    T18923
    T9198

- - - - -
82a0991a by Ben Gamari at 2022-07-25T23:32:05-04:00
testsuite: introduce nonmoving_thread_sanity way

(cherry picked from commit 19f8fce3659de3d72046bea9c61d1a82904bc4ae)

- - - - -
4b087973 by Ben Gamari at 2022-07-25T23:32:06-04:00
rts/nonmoving: Track segment state

It can often be useful during debugging to be able to determine the
state of a nonmoving segment. Introduce some state, enabled by DEBUG, to
track this.

(cherry picked from commit 40e797ef591ae3122ccc98ab0cc3cfcf9d17bd7f)

- - - - -
54a5c32d by Ben Gamari at 2022-07-25T23:32:06-04:00
rts/nonmoving: Don't scavenge objects which weren't evacuated

This fixes a rather subtle bug in the logic responsible for scavenging
objects evacuated to the non-moving generation. In particular, objects
can be allocated into the non-moving generation by two ways:

 a. evacuation out of from-space by the garbage collector
 b. direct allocation by the mutator

Like all evacuation, objects moved by (a) must be scavenged, since they
may contain references to other objects located in from-space. To
accomplish this we have the following scheme:

 * each nonmoving segment's block descriptor has a scan pointer which
   points to the first object which has yet to be scavenged

 * the GC tracks a set of "todo" segments which have pending scavenging
   work

 * to scavenge a segment, we scavenge each of the unmarked blocks
   between the scan pointer and segment's `next_free` pointer.

   We skip marked blocks since we know the allocator wouldn't have
   allocated into marked blocks (since they contain presumably live
   data).

   We can stop at `next_free` since, by
   definition, the GC could not have evacuated any objects to blocks
   above `next_free` (otherwise `next_free wouldn't be the first free
   block).

However, this neglected to consider objects allocated by path (b).
In short, the problem is that objects directly allocated by the mutator
may become unreachable (but not swept, since the containing segment is
not yet full), at which point they may contain references to swept objects.
Specifically, we observed this in #21885 in the following way:

1. the mutator (specifically in #21885, a `lockCAF`) allocates an object
   (specifically a blackhole, which here we will call `blkh`; see Note
   [Static objects under the nonmoving collector] for the reason why) on
   the non-moving heap. The bitmap of the allocated block remains 0
   (since allocation doesn't affect the bitmap) and the containing
   segment's (which we will call `blkh_seg`) `next_free` is advanced.
2. We enter the blackhole, evaluating the blackhole to produce a result
   (specificaly a cons cell) in the nursery
3. The blackhole gets updated into an indirection pointing to the cons
   cell; it is pushed to the generational remembered set
4. we perform a GC, the cons cell is evacuated into the nonmoving heap
   (into segment `cons_seg`)
5. the cons cell is marked
6. the GC concludes
7. the CAF and blackhole become unreachable
8. `cons_seg` is filled
9. we start another GC; the cons cell is swept
10. we start a new GC
11. something is evacuated into `blkh_seg`, adding it to the "todo" list
12. we attempt to scavenge `blkh_seg` (namely, all unmarked blocks
    between `scan` and `next_free`, which includes `blkh`). We attempt to
    evacuate `blkh`'s indirectee, which is the previously-swept cons cell.
    This is unsafe, since the indirectee is no longer a valid heap
    object.

The problem here was that the scavenging logic *assumed* that (a) was
the only source of allocations into the non-moving heap and therefore
*all* unmarked blocks between `scan` and `next_free` were evacuated.
However, due to (b) this is not true.

The solution is to ensure that that the scanned region only encompasses
the region of objects allocated during evacuation. We do this by
updating `scan` as we push the segment to the todo-segment list to
point to the block which was evacuated into.

Doing this required changing the nonmoving scavenging implementation's
update of the `scan` pointer to bump it *once*, instead of after
scavenging each block as was done previously. This is because we may end
up evacuating into the segment being scavenged as we scavenge it. This
was quite tricky to discover but the result is quite simple,
demonstrating yet again that global mutable state should be used
exceedingly sparingly.

Fixes #21885

(cherry picked from commit 0b27ea23efcb08639309293faf13fdfef03f1060)

- - - - -
25c24535 by Ben Gamari at 2022-07-25T23:32:06-04:00
testsuite: Skip a few tests as in the nonmoving collector

Residency monitoring under the non-moving collector is quite
conservative (e.g. the reported value is larger than reality) since
otherwise we would need to block on concurrent collection. Skip a few
tests that are sensitive to residency.

(cherry picked from commit 6880e4fbf728c04e8ce83e725bfc028fcb18cd70)

- - - - -
42147534 by sternenseemann at 2022-07-26T16:26:53-04:00
hadrian: add flag disabling selftest rules which require QuickCheck

The hadrian executable depends on QuickCheck for building, meaning this
library (and its dependencies) will need to be built for bootstrapping
GHC in the future. Building QuickCheck, however, can require
TemplateHaskell. When building a statically linking GHC toolchain,
TemplateHaskell can be tricky to get to work, and cross-compiling
TemplateHaskell doesn't work at all without -fexternal-interpreter,
so QuickCheck introduces an element of fragility to GHC's bootstrap.

Since the selftest rules are the only part of hadrian that need
QuickCheck, we can easily eliminate this bootstrap dependency when
required by introducing a `selftest` flag guarding the rules' inclusion.

Closes #8699.

- - - - -
9ea29d47 by Simon Peyton Jones at 2022-07-26T16:27:28-04:00
Regression test for #21848

- - - - -
ef30e215 by Matthew Pickering at 2022-07-28T13:56:59-04:00
driver: Don't create LinkNodes when -no-link is enabled

Fixes #21866

- - - - -
fc23b5ed by sheaf at 2022-07-28T13:57:38-04:00
Docs: fix mistaken claim about kind signatures

This patch fixes #21806 by rectifying an incorrect claim about
the usage of kind variables in the header of a data declaration with
a standalone kind signature.

It also adds some clarifications about the number of parameters expected
in GADT declarations and in type family declarations.

- - - - -
2df92ee1 by Matthew Pickering at 2022-08-02T05:20:01-04:00
testsuite: Correctly set withNativeCodeGen

Fixes #21918

- - - - -
f2912143 by Matthew Pickering at 2022-08-02T05:20:45-04:00
Fix since annotations in GHC.Stack.CloneStack

Fixes #21894

- - - - -
aeb8497d by Andreas Klebinger at 2022-08-02T19:26:51-04:00
Add -dsuppress-coercion-types to make coercions even smaller.

Instead of `` `cast` <Co:11> :: (Some -> Really -> Large Type)``
simply print `` `cast` <Co:11> :: ... ``

- - - - -
97655ad8 by sheaf at 2022-08-02T19:27:29-04:00
User's guide: fix typo in hasfield.rst

Fixes #21950

- - - - -
35aef18d by Yiyun Liu at 2022-08-04T02:55:07-04:00
Remove TCvSubst and use Subst for both term and type-level subst

This patch removes the TCvSubst data type and instead uses Subst as
the environment for both term and type level substitution. This
change is partially motivated by the existential type proposal,
which will introduce types that contain expressions and therefore
forces us to carry around an "IdSubstEnv" even when substituting for
types. It also reduces the amount of code because "Subst" and
"TCvSubst" share a lot of common operations. There isn't any
noticeable impact on performance (geo. mean for ghc/alloc is around
0.0% but we have -94 loc and one less data type to worry abount).

Currently, the "TCvSubst" data type for substitution on types is
identical to the "Subst" data type except the former doesn't store
"IdSubstEnv". Using "Subst" for type-level substitution means there
will be a redundant field stored in the data type. However, in cases
where the substitution starts from the expression, using "Subst" for
type-level substitution saves us from having to project "Subst" into a
"TCvSubst". This probably explains why the allocation is mostly even
despite the redundant field.

The patch deletes "TCvSubst" and moves "Subst" and its relevant
functions from "GHC.Core.Subst" into "GHC.Core.TyCo.Subst".
Substitution on expressions is still defined in "GHC.Core.Subst" so we
don't have to expose the definition of "Expr" in the hs-boot file that
"GHC.Core.TyCo.Subst" must import to refer to "IdSubstEnv" (whose
codomain is "CoreExpr"). Most functions named fooTCvSubst are renamed
into fooSubst with a few exceptions (e.g. "isEmptyTCvSubst" is a
distinct function from "isEmptySubst"; the former ignores the
emptiness of "IdSubstEnv"). These exceptions mainly exist for
performance reasons and will go away when "Expr" and "Type" are
mutually recursively defined (we won't be able to take those
shortcuts if we can't make the assumption that expressions don't
appear in types).

- - - - -
b99819bd by Krzysztof Gogolewski at 2022-08-04T02:55:43-04:00
Fix TH + defer-type-errors interaction (#21920)

Previously, we had to disable defer-type-errors in splices because of #7276.
But this fix is no longer necessary, the test T7276 no longer segfaults
and is now correctly deferred.

- - - - -
fb529cae by Andreas Klebinger at 2022-08-04T13:57:25-04:00
Add a note about about W/W for unlifting strict arguments

This fixes #21236.

- - - - -
fffc75a9 by Matthew Pickering at 2022-08-04T13:58:01-04:00
Force safeInferred to avoid retaining extra copy of DynFlags

This will only have a (very) modest impact on memory but we don't want
to retain old copies of DynFlags hanging around so best to force this
value.

- - - - -
0f43837f by Matthew Pickering at 2022-08-04T13:58:01-04:00
Force name selectors to ensure no reference to Ids enter the NameCache

I observed some unforced thunks in the NameCache which were retaining a
whole Id, which ends up retaining a Type.. which ends up retaining old
copies of HscEnv containing stale HomeModInfo.

- - - - -
0b1f5fd1 by Matthew Pickering at 2022-08-04T13:58:01-04:00
Fix leaks in --make mode when there are module loops

This patch fixes quite a tricky leak where we would end up retaining
stale ModDetails due to rehydrating modules against non-finalised
interfaces.

== Loops with multiple boot files

It is possible for a module graph to have a loop (SCC, when ignoring boot files)
which requires multiple boot files to break. In this case we must perform the
necessary hydration steps before and after compiling modules which have boot files
which are described above for corectness but also perform an additional hydration step
at the end of the SCC to remove space leaks.

Consider the following example:

┌───────┐   ┌───────┐
│       │   │       │
│   A   │   │   B   │
│       │   │       │
└─────┬─┘   └───┬───┘
      │         │
 ┌────▼─────────▼──┐
 │                 │
 │        C        │
 └────┬─────────┬──┘
      │         │
 ┌────▼──┐  ┌───▼───┐
 │       │  │       │
 │ A-boot│  │ B-boot│
 │       │  │       │
 └───────┘  └───────┘

 A, B and C live together in a SCC. Say we compile the modules in order
 A-boot, B-boot, C, A, B then when we compile A we will perform the hydration steps
 (because A has a boot file). Therefore C will be hydrated relative to A, and the
 ModDetails for A will reference C/A. Then when B is compiled C will be rehydrated again,
 and so B will reference C/A,B, its interface will be hydrated relative to both A and B.
 Now there is a space leak because say C is a very big module, there are now two different copies of
 ModDetails kept alive by modules A and B.

The way to avoid this space leak is to rehydrate an entire SCC together at the
end of compilation so that all the ModDetails point to interfaces for .hs files.
In this example, when we hydrate A, B and C together then both A and B will refer to
C/A,B.

See #21900 for some more discussion.

-------------------------------------------------------

In addition to this simple case, there is also the potential for a leak
during parallel upsweep which is also fixed by this patch. Transcibed is
Note [ModuleNameSet, efficiency and space leaks]

Note [ModuleNameSet, efficiency and space leaks]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

During unsweep the results of compiling modules are placed into a MVar, to find
the environment the module needs to compile itself in the MVar is consulted and
the HomeUnitGraph is set accordingly. The reason we do this is that precisely tracking
module dependencies and recreating the HUG from scratch each time is very expensive.

In serial mode (-j1), this all works out fine because a module can only be compiled after
its dependencies have finished compiling and not interleaved with compiling module loops.
Therefore when we create the finalised or no loop interfaces, the HUG only contains
finalised interfaces.

In parallel mode, we have to be more careful because the HUG variable can contain
non-finalised interfaces which have been started by another thread. In order to avoid
a space leak where a finalised interface is compiled against a HPT which contains a
non-finalised interface we have to restrict the HUG to only the visible modules.

The visible modules is recording in the ModuleNameSet, this is propagated upwards
whilst compiling and explains which transitive modules are visible from a certain point.
This set is then used to restrict the HUG before the module is compiled to only
the visible modules and thus avoiding this tricky space leak.

Efficiency of the ModuleNameSet is of utmost importance because a union occurs for
each edge in the module graph. Therefore the set is represented directly as an IntSet
which provides suitable performance, even using a UniqSet (which is backed by an IntMap) is
too slow. The crucial test of performance here is the time taken to a do a no-op build in --make mode.

See test "jspace" for an example which used to trigger this problem.

Fixes #21900

- - - - -
1d94a59f by Matthew Pickering at 2022-08-04T13:58:01-04:00
Store interfaces in ModIfaceCache more directly

I realised hydration was completely irrelavant for this cache because
the ModDetails are pruned from the result. So now it simplifies things a
lot to just store the ModIface and Linkable, which we can put into the
cache straight away rather than wait for the final version of a
HomeModInfo to appear.

- - - - -
6c7cd50f by Cheng Shao at 2022-08-04T23:01:45-04:00
cmm: Remove unused ReadOnlyData16

We don't actually emit rodata16 sections anywhere.

- - - - -
16333ad7 by Andreas Klebinger at 2022-08-04T23:02:20-04:00
findExternalRules: Don't needlessly traverse the list of rules.

- - - - -
52c15674 by Krzysztof Gogolewski at 2022-08-05T12:47:05-04:00
Remove backported items from 9.6 release notes

They have been backported to 9.4 in commits 5423d84bd9a28f,
13c81cb6be95c5, 67ccbd6b2d4b9b.

- - - - -
78d232f5 by Matthew Pickering at 2022-08-05T12:47:40-04:00
ci: Fix pages job

The job has been failing because we don't bundle haddock docs anymore in
the docs dist created by hadrian.

Fixes #21789

- - - - -
037bc9c9 by Ben Gamari at 2022-08-05T22:00:29-04:00
codeGen/X86: Don't clobber switch variable in switch generation

Previously ce8745952f99174ad9d3bdc7697fd086b47cdfb5 assumed that it was
safe to clobber the switch variable when generating code for a jump
table since we were at the end of a block. However, this assumption is
wrong; the register could be live in the jump target.

Fixes #21968.

- - - - -
50c8e1c5 by Matthew Pickering at 2022-08-05T22:01:04-04:00
Fix equality operator in jspace test

- - - - -
e9c77a22 by Andreas Klebinger at 2022-08-06T06:13:17-04:00
Improve BUILD_PAP comments

- - - - -
41234147 by Andreas Klebinger at 2022-08-06T06:13:17-04:00
Make dropTail comment a haddock comment

- - - - -
ff11d579 by Andreas Klebinger at 2022-08-06T06:13:17-04:00
Add one more sanity check in stg_restore_cccs

- - - - -
1f6c56ae by Andreas Klebinger at 2022-08-06T06:13:17-04:00
StgToCmm: Fix isSimpleScrut when profiling is enabled.

When profiling is enabled we must enter functions that might represent
thunks in order for their sccs to show up in the profile.

We might allocate even if the function is already evaluated in this
case. So we can't consider any potential function thunk to be a simple
scrut when profiling.

Not doing so caused profiled binaries to segfault.

- - - - -
fab0ee93 by Andreas Klebinger at 2022-08-06T06:13:17-04:00
Change `-fprof-late` to insert cost centres after unfolding creation.

The former behaviour of adding cost centres after optimization but
before unfoldings are created is not available via the flag
`prof-late-inline` instead.

I also reduced the overhead of -fprof-late* by pushing the cost centres
into lambdas. This means the cost centres will only account for
execution of functions and not their partial application.

Further I made LATE_CC cost centres it's own CC flavour so they now
won't clash with user defined ones if a user uses the same string for
a custom scc.

LateCC: Don't put cost centres inside constructor workers.

With -fprof-late they are rarely useful as the worker is usually
inlined. Even if the worker is not inlined or we use -fprof-late-linline
they are generally not helpful but bloat compile and run time
significantly. So we just don't add sccs inside constructor workers.

-------------------------
Metric Decrease:
    T13701
-------------------------

- - - - -
f8bec4e3 by Ben Gamari at 2022-08-06T06:13:53-04:00
gitlab-ci: Fix hadrian bootstrapping of release pipelines

Previously we would attempt to test hadrian bootstrapping in the
`validate` build flavour. However, `ci.sh` refuses to run validation
builds during release pipelines, resulting in job failures. Fix this by
testing bootstrapping in the `release` flavour during release pipelines.

We also attempted to record perf notes for these builds, which is
redundant work and undesirable now since we no longer build in a
consistent flavour.

- - - - -
c0348865 by Ben Gamari at 2022-08-06T11:45:17-04:00
compiler: Eliminate two uses of foldr in favor of foldl'

These two uses constructed maps, which is a case where foldl' is
generally more efficient since we avoid constructing an intermediate
O(n)-depth stack.

- - - - -
d2e4e123 by Ben Gamari at 2022-08-06T11:45:17-04:00
rts: Fix code style

- - - - -
57f530d3 by Ben Gamari at 2022-08-06T11:45:17-04:00
genprimopcode: Drop ArrayArray# references

As ArrayArray# no longer exists

- - - - -
7267cd52 by Ben Gamari at 2022-08-06T11:45:17-04:00
base: Organize Haddocks in GHC.Conc.Sync

- - - - -
aa818a9f by Ben Gamari at 2022-08-06T11:48:50-04:00
Add primop to list threads

A user came to #ghc yesterday wondering how best to check whether they
were leaking threads. We ended up using the eventlog but it seems to me
like it would be generally useful if Haskell programs could query their
own threads.

- - - - -
6d1700b6 by Ben Gamari at 2022-08-06T11:51:35-04:00
rts: Move thread labels into TSO

This eliminates the thread label HashTable and instead tracks this
information in the TSO, allowing us to use proper StgArrBytes arrays for
backing the label and greatly simplifying management of object lifetimes
when we expose them to the user with the coming `threadLabel#` primop.

- - - - -
1472044b by Ben Gamari at 2022-08-06T11:54:52-04:00
Add a primop to query the label of a thread

- - - - -
43f2b271 by Ben Gamari at 2022-08-06T11:55:14-04:00
base: Share finalization thread label

For efficiency's sake we float the thread label assigned to the
finalization thread to the top-level, ensuring that we only need to
encode the label once.

- - - - -
1d63b4fb by Ben Gamari at 2022-08-06T11:57:11-04:00
users-guide: Add release notes entry for thread introspection support

- - - - -
09bca1de by Ben Gamari at 2022-08-07T01:19:35-04:00
hadrian: Fix binary distribution install attributes

Previously we would use plain `cp` to install various parts of the
binary distribution. However, `cp`'s behavior w.r.t. file attributes is
quite unclear; for this reason it is much better to rather use
`install`.

Fixes #21965.

- - - - -
2b8ea16d by Ben Gamari at 2022-08-07T01:19:35-04:00
hadrian: Fix installation of system-cxx-std-lib package conf

- - - - -
7b514848 by Ben Gamari at 2022-08-07T01:20:10-04:00
gitlab-ci: Bump Docker images

To give the ARMv7 job access to lld, fixing #21875.

- - - - -
afa584a3 by Ben Gamari at 2022-08-07T05:08:52-04:00
hadrian: Don't use mk/config.mk.in

Ultimately we want to drop mk/config.mk so here I extract the bits
needed by the Hadrian bindist installation logic into a Hadrian-specific
file. While doing this I fixed binary distribution installation, #21901.

- - - - -
b9bb45d7 by Ben Gamari at 2022-08-07T05:08:52-04:00
hadrian: Fix naming of cross-compiler wrappers

- - - - -
78d04cfa by Ben Gamari at 2022-08-07T11:44:58-04:00
hadrian: Extend xattr Darwin hack to cover /lib

As noted in #21506, it is now necessary to remove extended attributes
from `/lib` as well as `/bin` to avoid SIP issues on Darwin.

Fixes #21506.

- - - - -
20457d77 by Andreas Klebinger at 2022-08-08T14:42:26+02:00
NCG(x86): Compile add+shift as lea if possible.

- - - - -
742292e4 by Andreas Klebinger at 2022-08-08T16:46:37-04:00
dataToTag#: Skip runtime tag check if argument is infered tagged

This addresses one part of #21710.

- - - - -
1504a93e by Cheng Shao at 2022-08-08T16:47:14-04:00
rts: remove redundant stg_traceCcszh

This out-of-line primop has no Haskell wrapper and hasn't been used
anywhere in the tree. Furthermore, the code gets in the way of !7632, so
it should be garbage collected.

- - - - -
a52de3cb by Andreas Klebinger at 2022-08-08T16:47:50-04:00
Document a divergence from the report in parsing function lhss.

GHC is happy to parse `(f) x y = x + y` when it should be a parse error
based on the Haskell report. Seems harmless enough so we won't fix it
but it's documented now.

Fixes #19788

- - - - -
5765e133 by Ben Gamari at 2022-08-08T16:48:25-04:00
gitlab-ci: Add release job for aarch64/debian 11

- - - - -
5b26f324 by Ben Gamari at 2022-08-08T19:39:20-04:00
gitlab-ci: Introduce validation job for aarch64 cross-compilation

Begins to address #11958.

- - - - -
e866625c by Ben Gamari at 2022-08-08T19:39:20-04:00
Bump process submodule

- - - - -
ae707762 by Ben Gamari at 2022-08-08T19:39:20-04:00
gitlab-ci: Add basic support for cross-compiler testiing

Here we add a simple qemu-based test for cross-compilers.

- - - - -
50912d68 by Ben Gamari at 2022-08-08T19:39:57-04:00
rts: Ensure that Array# card arrays are initialized

In #19143 I noticed that newArray# failed to initialize the card table
of newly-allocated arrays. However, embarrassingly, I then only fixed
the issue in newArrayArray# and, in so doing, introduced the potential
for an integer underflow on zero-length arrays (#21962).

Here I fix the issue in newArray#, this time ensuring that we do not
underflow in pathological cases.

Fixes #19143.

- - - - -
e5ceff56 by Ben Gamari at 2022-08-08T19:39:57-04:00
testsuite: Add test for #21962

- - - - -
c1c08bd8 by Ben Gamari at 2022-08-09T02:31:14-04:00
gitlab-ci: Don't use coreutils on Darwin

In general we want to ensure that the tested environment is as similar
as possible to the environment the user will use. In the case of Darwin,
this means we want to use the system's BSD command-line utilities, not
coreutils.

This would have caught #21974.

- - - - -
1c582f44 by Ben Gamari at 2022-08-09T02:31:14-04:00
hadrian: Fix bindist installation on Darwin

It turns out that `cp -P` on Darwin does not always copy a symlink as
a symlink. In order to get these semantics one must pass `-RP`. It's not
entirely clear whether this is valid under POSIX, but it is nevertheless
what Apple does.

- - - - -
681aa076 by Ben Gamari at 2022-08-09T02:31:49-04:00
hadrian: Fix access mode of installed package registration files

Previously hadrian's bindist Makefile would modify package
registrations placed by `install` via a shell pipeline and `mv`.
However, the use of `mv` means that if umask is set then the user may
otherwise end up with package registrations which are inaccessible.
Fix this by ensuring that the mode is 0644.

- - - - -
e9dfd26a by Krzysztof Gogolewski at 2022-08-09T02:32:24-04:00
Cleanups around pretty-printing

* Remove hack when printing OccNames. No longer needed since e3dcc0d5
* Remove unused `pprCmms` and `instance Outputable Instr`
* Simplify `pprCLabel` (no need to pass platform)
* Remove evil `Show`/`Eq` instances for `SDoc`. They were needed by
  ImmLit, but that can take just a String instead.
* Remove instance `Outputable CLabel` - proper output of labels
  needs a platform, and is done by the `OutputableP` instance

- - - - -
66d2e927 by Ben Gamari at 2022-08-09T13:46:48-04:00
rts/linker: Resolve iconv_* on FreeBSD

FreeBSD's libiconv includes an implementation of the
iconv_* functions in libc. Unfortunately these can
only be resolved using dlvsym, which is how the RTS linker
usually resolves such functions. To fix this we include an ad-hoc
special case for iconv_*.

Fixes #20354.

- - - - -
5d66a0ce by Ben Gamari at 2022-08-09T13:46:48-04:00
system-cxx-std-lib: Add support for FreeBSD libcxxrt

- - - - -
ea90e61d by Ben Gamari at 2022-08-09T13:46:48-04:00
gitlab-ci: Bump to use freebsd13 runners

- - - - -
d71a2051 by sheaf at 2022-08-09T13:47:28-04:00
Fix size_up_alloc to account for UnliftedDatatypes

The size_up_alloc function mistakenly considered any type that isn't
lifted to not allocate anything, which is wrong. What we want instead
is to check the type isn't boxed. This accounts for (BoxedRep Unlifted).

Fixes #21939

- - - - -
76b52cf0 by Douglas Wilson at 2022-08-10T06:01:53-04:00
testsuite: 21651 add test for closeFdWith + setNumCapabilities

This bug does not affect windows, which does not use the
base module GHC.Event.Thread.

- - - - -
7589ee72 by Douglas Wilson at 2022-08-10T06:01:53-04:00
base: Fix races in IOManager (setNumCapabilities,closeFdWith)

Fix for #21651

Fixes three bugs:

- writes to eventManager should be atomic. It is accessed concurrently by ioManagerCapabilitiesChanged and closeFdWith.
- The race in closeFdWith described in the ticket.
- A race in getSystemEventManager where it accesses the 'IOArray' in
  'eventManager' before 'ioManagerCapabilitiesChanged' has written to
  'eventManager', causing an Array Index exception. The fix here is to
  'yield' and retry.

- - - - -
dc76439d by Trevis Elser at 2022-08-10T06:02:28-04:00
Updates language extension documentation

Adding a 'Status' field with a few values:
- Deprecated
- Experimental
- InternalUseOnly
- Noting if included in 'GHC2021', 'Haskell2010' or 'Haskell98'

Those values are pulled from the existing descriptions or elsewhere in
the documentation.

While at it, include the :implied by: where appropriate, to provide
more detail.

Fixes #21475

- - - - -
823fe5b5 by Jens Petersen at 2022-08-10T06:03:07-04:00
hadrian RunRest: add type signature for stageNumber

avoids warning seen on 9.4.1:

src/Settings/Builders/RunTest.hs:264:53: warning: [-Wtype-defaults]
    • Defaulting the following constraints to type ‘Integer’
        (Show a0)
          arising from a use of ‘show’
          at src/Settings/Builders/RunTest.hs:264:53-84
        (Num a0)
          arising from a use of ‘stageNumber’
          at src/Settings/Builders/RunTest.hs:264:59-83
    • In the second argument of ‘(++)’, namely
        ‘show (stageNumber (C.stage ctx))’
      In the second argument of ‘($)’, namely
        ‘"config.stage=" ++ show (stageNumber (C.stage ctx))’
      In the expression:
        arg $ "config.stage=" ++ show (stageNumber (C.stage ctx))
    |
264 |             , arg "-e", arg $ "config.stage="    ++ show (stageNumber (C.stage ctx))
    |                                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

compilation tested locally

- - - - -
f95bbdca by Sylvain Henry at 2022-08-10T09:44:46-04:00
Add support for external static plugins (#20964)

This patch adds a new command-line flag:

  -fplugin-library=<file-path>;<unit-id>;<module>;<args>

used like this:

  -fplugin-library=path/to/plugin.so;package-123;Plugin.Module;["Argument","List"]

It allows a plugin to be loaded directly from a shared library. With
this approach, GHC doesn't compile anything for the plugin and doesn't
load any .hi file for the plugin and its dependencies. As such GHC
doesn't need to support two environments (one for plugins, one for
target code), which was the more ambitious approach tracked in #14335.

Fix #20964

Co-authored-by: Josh Meredith <joshmeredith2008 at gmail.com>

- - - - -
5bc489ca by Ben Gamari at 2022-08-10T09:45:22-04:00
gitlab-ci: Fix ARMv7 build

It appears that the CI refactoring carried out in
5ff690b8474c74e9c968ef31e568c1ad0fe719a1 failed to carry over some
critical configuration: setting the build/host/target platforms and
forcing use of a non-broken linker.

- - - - -
596db9a5 by Ben Gamari at 2022-08-10T09:45:22-04:00
gitlab-ci: Run ARMv7 jobs when ~ARM label is used

- - - - -
7cabea7c by Ben Gamari at 2022-08-10T15:37:58-04:00
hadrian: Don't attempt to install documentation if doc/ doesn't exist

Previously we would attempt to install documentation even if the `doc`
directory doesn't exist (e.g. due to `--docs=none`). This would result
in the surprising side-effect of the entire contents of the bindist
being installed in the destination documentation directory. Fix this.

Fixes #21976.

- - - - -
67575f20 by normalcoder at 2022-08-10T15:38:34-04:00
ncg/aarch64: Don't use x18 register on AArch64/Darwin

Apple's ABI documentation [1] says: "The platforms reserve register x18.
Don’t use this register." While this wasn't problematic in previous
Darwin releases, macOS 13 appears to start zeroing this register
periodically. See #21964.

[1] https://developer.apple.com/documentation/xcode/writing-arm64-code-for-apple-platforms

- - - - -
45eb4cbe by Andreas Klebinger at 2022-08-10T22:41:12-04:00
Note [Trimming auto-rules]: State that this improves compiler perf.

- - - - -
5c24b1b3 by Bodigrim at 2022-08-10T22:41:50-04:00
Document that threadDelay / timeout are susceptible to overflows on 32-bit machines

- - - - -
ff67c79e by Alan Zimmerman at 2022-08-11T16:19:57-04:00
EPA: DotFieldOcc does not have exact print annotations

For the code

    {-# LANGUAGE OverloadedRecordUpdate #-}

    operatorUpdate f = f{(+) = 1}

There are no exact print annotations for the parens around the +
symbol, nor does normal ppr print them.

This MR fixes that.

Closes #21805

Updates haddock submodule

- - - - -
dca43a04 by Matthew Pickering at 2022-08-11T16:20:33-04:00
Revert "gitlab-ci: Add release job for aarch64/debian 11"

This reverts commit 5765e13370634979eb6a0d9f67aa9afa797bee46.

The job was not tested before being merged and fails CI
(https://gitlab.haskell.org/ghc/ghc/-/jobs/1139392)

Ticket #22005

- - - - -
ffc9116e by Eric Lindblad at 2022-08-16T09:01:26-04:00
typo
- - - - -
cd6f5bfd by Ben Gamari at 2022-08-16T09:02:02-04:00
CmmToLlvm: Don't aliasify builtin LLVM variables

Our aliasification logic would previously turn builtin LLVM variables
into aliases, which apparently confuses LLVM. This manifested in
initializers failing to be emitted, resulting in many profiling failures
with the LLVM backend.

Fixes #22019.

- - - - -
dc7da356 by Bryan Richter at 2022-08-16T09:02:38-04:00
run_ci: remove monoidal-containers

Fixes #21492

MonoidalMap is inlined and used to implement Variables, as before.

The top-level value "jobs" is reimplemented as a regular Map, since it
doesn't use the monoidal union anyway.

- - - - -
64110544 by Cheng Shao at 2022-08-16T09:03:15-04:00
CmmToAsm/AArch64: correct a typo

- - - - -
f6a5524a by Andreas Klebinger at 2022-08-16T14:34:11-04:00
Fix #21979 - compact-share failing with -O

I don't have good reason to believe the optimization level should affect
if sharing works or not here. So limit the test to the normal way.

- - - - -
68154a9d by Ben Gamari at 2022-08-16T14:34:47-04:00
users-guide: Fix reference to dead llvm-version substitution

Fixes #22052.

- - - - -
28c60d26 by Ben Gamari at 2022-08-16T14:34:47-04:00
users-guide: Fix incorrect reference to `:extension: role

- - - - -
71102c8f by Ben Gamari at 2022-08-16T14:34:47-04:00
users-guide: Add :ghc-flag: reference

- - - - -
385f420b by Ben Gamari at 2022-08-16T14:34:47-04:00
hadrian: Place manpage in docroot

This relocates it from docs/ to doc/

- - - - -
84598f2e by Ben Gamari at 2022-08-16T14:34:47-04:00
Bump haddock submodule

Includes merge of `main` into `ghc-head` as well as some Haddock users
guide fixes.

- - - - -
59ce787c by Ben Gamari at 2022-08-16T14:34:47-04:00
base: Add changelog entries from ghc-9.2

Closes #21922.

- - - - -
a14e6ae3 by Ben Gamari at 2022-08-16T14:34:47-04:00
relnotes: Add "included libraries" section

As noted in #21988, some users rely on this.

- - - - -
a4212edc by Ben Gamari at 2022-08-16T14:34:47-04:00
users-guide: Rephrase the rewrite rule documentation

Previously the wording was a tad unclear. Fix this.

Closes #21114.

- - - - -
3e493dfd by Peter Becich at 2022-08-17T08:43:21+01:00
Implement Response File support for HPC

This is an improvement to HPC authored by Richard Wallace
(https://github.com/purefn) and myself. I have received permission from
him to attempt to upstream it. This improvement was originally
implemented as a patch to HPC via input-output-hk/haskell.nix:
https://github.com/input-output-hk/haskell.nix/pull/1464

Paraphrasing Richard, HPC currently requires all inputs as command line arguments.
With large projects this can result in an argument list too long error.
I have only seen this error in Nix, but I assume it can occur is a plain Unix environment.

This MR adds the standard response file syntax support to HPC. For
example you can now pass a file to the command line which contains the
arguments.

```
hpc @response_file_1 @response_file_2 ...

The contents of a Response File must have this format:
COMMAND ...

example:
report my_library.tix --include=ModuleA --include=ModuleB
```

Updates hpc submodule

Co-authored-by:  Richard Wallace <rwallace at thewallacepack.net>

Fixes #22050

- - - - -
436867d6 by Matthew Pickering at 2022-08-18T09:24:08-04:00
ghc-heap: Fix decoding of TSO closures

An extra field was added to the TSO structure in 6d1700b6 but the
decoding logic in ghc-heap was not updated for this new field.

Fixes #22046

- - - - -
a740a4c5 by Matthew Pickering at 2022-08-18T09:24:44-04:00
driver: Honour -x option

The -x option is used to manually specify which phase a file should be
started to be compiled from (even if it lacks the correct extension). I
just failed to implement this when refactoring the driver.

In particular Cabal calls GHC with `-E -cpp -x hs Foo.cpphs` to
preprocess source files using GHC.

I added a test to exercise this case.

Fixes #22044

- - - - -
e293029d by Simon Peyton Jones at 2022-08-18T09:25:19-04:00
Be more careful in chooseInferredQuantifiers

This fixes #22065. We were failing to retain a quantifier that
was mentioned in the kind of another retained quantifier.

Easy to fix.

- - - - -
714c936f by Bryan Richter at 2022-08-18T18:37:21-04:00
testsuite: Add test for #21583

- - - - -
989b844d by Ben Gamari at 2022-08-18T18:37:57-04:00
compiler: Drop --build-id=none hack

Since 2011 the object-joining implementation has had a hack to pass
`--build-id=none` to `ld` when supported, seemingly to work around a
linker bug. This hack is now unnecessary and may break downstream users
who expect objects to have valid build-ids. Remove it.

Closes #22060.

- - - - -
519c712e by Matthew Pickering at 2022-08-19T00:09:11-04:00
Make ru_fn field strict to avoid retaining Ids

It's better to perform this projection from Id to Name strictly so we
don't retain an old Id (hence IdInfo, hence Unfolding, hence everything
etc)

- - - - -
7dda04b0 by Matthew Pickering at 2022-08-19T00:09:11-04:00
Force `getOccFS bndr` to avoid retaining reference to Bndr.

This is another symptom of #19619

- - - - -
4303acba by Matthew Pickering at 2022-08-19T00:09:11-04:00
Force unfoldings when they are cleaned-up in Tidy and CorePrep

If these thunks are not forced then the entire unfolding for the binding
is live throughout the whole of CodeGen despite the fact it should have
been discarded.

Fixes #22071

- - - - -
2361b3bc by Matthew Pickering at 2022-08-19T00:09:47-04:00
haddock docs: Fix links from identifiers to dependent packages

When implementing the base_url changes I made the pretty bad mistake of
zipping together two lists which were in different orders. The simpler
thing to do is just modify `haddockDependencies` to also return the
package identifier so that everything stays in sync.

Fixes #22001

- - - - -
9a7e2ea1 by Matthew Pickering at 2022-08-19T00:10:23-04:00
Revert "Refactor SpecConstr to use treat bindings uniformly"

This reverts commit 415468fef8a3e9181b7eca86de0e05c0cce31729.

This refactoring introduced quite a severe residency regression (900MB
live from 650MB live when compiling mmark), see #21993 for a reproducer
and more discussion.

Ticket #21993

- - - - -
9789e845 by Zachary Wood at 2022-08-19T14:17:28-04:00
tc: warn about lazy annotations on unlifted arguments (fixes #21951)

- - - - -
e5567289 by Andreas Klebinger at 2022-08-19T14:18:03-04:00
Fix #22048 where we failed to drop rules for -fomit-interface-pragmas.

Now we also filter the local rules (again) which fixes the issue.

- - - - -
51ffd009 by Swann Moreau at 2022-08-19T18:29:21-04:00
Print constraints in quotes (#21167)

This patch improves the uniformity of error message formatting by
printing constraints in quotes, as we do for types.

Fix #21167

- - - - -
ab3e0f5a by Sasha Bogicevic at 2022-08-19T18:29:57-04:00
19217 Implicitly quantify type variables in :kind command

- - - - -
9939e95f by MorrowM at 2022-08-21T16:51:38-04:00
Recognize file-header pragmas in GHCi (#21507)

- - - - -
fb7c2d99 by Matthew Pickering at 2022-08-21T16:52:13-04:00
hadrian: Fix bootstrapping with ghc-9.4

The error was that we were trying to link together

    containers from boot package library (which depends template-haskell in boot package library)
    template-haskell from in-tree package database

So the fix is to build containers in stage0 (and link against template-haskell built in stage0).

Fixes #21981

- - - - -
b946232c by Mario Blažević at 2022-08-22T22:06:21-04:00
Added pprType with precedence argument, as a prerequisite to fix issues #21723 and #21942.

* refines the precedence levels, adding `qualPrec` and `funPrec` to better control parenthesization
* `pprParendType`, `pprFunArgType`, and `instance Ppr Type` all just call `pprType` with proper precedence
* `ParensT` constructor is now always printed parenthesized
* adds the precedence argument to `pprTyApp` as well, as it needs to keep track and pass it down
* using `>=` instead of former `>` to match the Core type printing logic
* some test outputs have changed, losing extraneous parentheses

- - - - -
fe4ff0f7 by Mario Blažević at 2022-08-22T22:06:21-04:00
Fix and test for issue #21723

- - - - -
33968354 by Mario Blažević at 2022-08-22T22:06:21-04:00
Test for issue #21942

- - - - -
c9655251 by Mario Blažević at 2022-08-22T22:06:21-04:00
Updated the changelog

- - - - -
80102356 by Ben Gamari at 2022-08-22T22:06:57-04:00
hadrian: Don't duplicate binaries on installation

Previously we used `install` on symbolic links, which ended up
copying the target file rather than installing a symbolic link.

Fixes #22062.

- - - - -
b929063e by M Farkas-Dyck at 2022-08-24T02:37:01-04:00
Unbreak Haddock comments in `GHC.Core.Opt.WorkWrap.Utils`.

Closes #22092.

- - - - -
112e4f9c by Cheng Shao at 2022-08-24T02:37:38-04:00
driver: don't actually merge objects when ar -L works

- - - - -
a9f0e68e by Ben Gamari at 2022-08-24T02:38:13-04:00
rts: Consistently use MiB in stats output

Previously we would say `MB` even where we
meant `MiB`.
- - - - -
a90298cc by Simon Peyton Jones at 2022-08-25T08:38:16+01:00
Fix arityType: -fpedantic-bottoms, join points, etc

This MR fixes #21694, #21755.  It also makes sure that #21948 and
fix to #21694.

* For #21694 the underlying problem was that we were calling arityType
  on an expression that had free join points.  This is a Bad Bad Idea.
  See Note [No free join points in arityType].

* To make "no free join points in arityType" work out I had to avoid
  trying to use eta-expansion for runRW#. This entailed a few changes
  in the Simplifier's treatment of runRW#.  See
  GHC.Core.Opt.Simplify.Iteration Note [No eta-expansion in runRW#]

* I also made andArityType work correctly with -fpedantic-bottoms;
  see Note [Combining case branches: andWithTail].

* Rewrote Note [Combining case branches: optimistic one-shot-ness]

* arityType previously treated join points differently to other
  let-bindings. This patch makes them unform; arityType analyses
  the RHS of all bindings to get its ArityType, and extends am_sigs.

  I realised that, now we have am_sigs giving the ArityType for
  let-bound Ids, we don't need the (pre-dating) special code in
  arityType for join points. But instead we need to extend the env for
  Rec bindings, which weren't doing before.  More uniform now.  See
  Note [arityType for let-bindings].

  This meant we could get rid of ae_joins, and in fact get rid of
  EtaExpandArity altogether.  Simpler.

* And finally, it was the strange treatment of join-point Ids in
  arityType (involving a fake ABot type) that led to a serious bug:
  #21755.  Fixed by this refactoring, which treats them uniformly;
  but without breaking #18328.

  In fact, the arity for recursive join bindings is pretty tricky;
  see the long Note [Arity for recursive join bindings]
  in GHC.Core.Opt.Simplify.Utils.  That led to more refactoring,
  including deciding that an Id could have an Arity that is bigger
  than its JoinArity; see Note [Invariants on join points], item
  2(b) in GHC.Core

* Make sure that the "demand threshold" for join points in DmdAnal
  is no bigger than the join-arity.  In GHC.Core.Opt.DmdAnal see
  Note [Demand signatures are computed for a threshold arity based on idArity]

* I moved GHC.Core.Utils.exprIsDeadEnd into GHC.Core.Opt.Arity,
  where it more properly belongs.

* Remove an old, redundant hack in FloatOut.  The old Note was
  Note [Bottoming floats: eta expansion] in GHC.Core.Opt.SetLevels.

Compile time improves very slightly on average:

Metrics: compile_time/bytes allocated
---------------------------------------------------------------------------------------
  T18223(normal) ghc/alloc    725,808,720    747,839,216  +3.0%  BAD
  T6048(optasm)  ghc/alloc    105,006,104    101,599,472  -3.2% GOOD
  geo. mean                                          -0.2%
  minimum                                            -3.2%
  maximum                                            +3.0%

For some reason Windows was better

   T10421(normal) ghc/alloc    125,888,360    124,129,168  -1.4% GOOD
   T18140(normal) ghc/alloc     85,974,520     83,884,224  -2.4% GOOD
  T18698b(normal) ghc/alloc    236,764,568    234,077,288  -1.1% GOOD
   T18923(normal) ghc/alloc     75,660,528     73,994,512  -2.2% GOOD
    T6048(optasm) ghc/alloc    112,232,512    108,182,520  -3.6% GOOD
  geo. mean                                          -0.6%

I had a quick look at T18223 but it is knee deep in coercions and
the size of everything looks similar before and after.  I decided
to accept that 3% increase in exchange for goodness elsewhere.

Metric Decrease:
    T10421
    T18140
    T18698b
    T18923
    T6048

Metric Increase:
    T18223

- - - - -
909edcfc by Ben Gamari at 2022-08-25T10:03:34-04:00
upload_ghc_libs: Add means of passing Hackage credentials

- - - - -
28402eed by M Farkas-Dyck at 2022-08-25T10:04:17-04:00
Scrub some partiality in `CommonBlockElim`.

- - - - -
54affbfa by Ben Gamari at 2022-08-25T20:05:31-04:00
hadrian: Fix whitespace

Previously this region of Settings.Packages was incorrectly indented.

- - - - -
c4bba0f0 by Ben Gamari at 2022-08-25T20:05:31-04:00
validate: Drop --legacy flag

In preparation for removal of the legacy `make`-based build system.

- - - - -
822b0302 by Ben Gamari at 2022-08-25T20:05:31-04:00
gitlab-ci: Drop make build validation jobs

In preparation for removal of the `make`-based build system

- - - - -
6fd9b0a1 by Ben Gamari at 2022-08-25T20:05:31-04:00
Drop make build system

Here we at long last remove the `make`-based build system, it having
been replaced with the Shake-based Hadrian build system. Users are
encouraged to refer to the documentation in `hadrian/doc` and this [1]
blog post for details on using Hadrian.

Closes #17527.

[1] https://www.haskell.org/ghc/blog/20220805-make-to-hadrian.html

- - - - -
dbb004b0 by Ben Gamari at 2022-08-25T20:05:31-04:00
Remove testsuite/tests/perf/haddock/.gitignore

As noted in #16802, this is no longer needed.

Closes #16802.

- - - - -
fe9d824d by Ben Gamari at 2022-08-25T20:05:31-04:00
Drop hc-build script

This has not worked for many, many years and relied on the now-removed
`make`-based build system.

- - - - -
659502bc by Ben Gamari at 2022-08-25T20:05:31-04:00
Drop mkdirhier

This is only used by nofib's dead `dist` target

- - - - -
4a426924 by Ben Gamari at 2022-08-25T20:05:31-04:00
Drop mk/{build,install,config}.mk.in

- - - - -
46924b75 by Ben Gamari at 2022-08-25T20:05:31-04:00
compiler: Drop comment references to make

- - - - -
d387f687 by Harry Garrood at 2022-08-25T20:06:10-04:00
Add inits1 and tails1 to Data.List.NonEmpty

See https://github.com/haskell/core-libraries-committee/issues/67

- - - - -
8603c921 by Harry Garrood at 2022-08-25T20:06:10-04:00
Add since annotations and changelog entries

- - - - -
6b47aa1c by Krzysztof Gogolewski at 2022-08-25T20:06:46-04:00
Fix redundant import

This fixes a build error on x86_64-linux-alpine3_12-validate.
See the function 'loadExternalPlugins' defined in this file.

- - - - -
4786acf7 by sheaf at 2022-08-26T15:05:23-04:00
Pmc: consider any 2 dicts of the same type equal

This patch massages the keys used in the `TmOracle` `CoreMap` to ensure
that dictionaries of coherent classes give the same key.
That is, whenever we have an expression we want to insert or lookup in
the `TmOracle` `CoreMap`, we first replace any dictionary
`$dict_abcd :: ct` with a value of the form `error @ct`.

This allows us to common-up view pattern functions with required
constraints whose arguments differed only in the uniques of the
dictionaries they were provided, thus fixing #21662.

This is a rather ad-hoc change to the keys used in the
`TmOracle` `CoreMap`. In the long run, we would probably want to use
a different representation for the keys instead of simply using
`CoreExpr` as-is. This more ambitious plan is outlined in #19272.

Fixes #21662
Updates unix submodule

- - - - -
f5e0f086 by Krzysztof Gogolewski at 2022-08-26T15:06:01-04:00
Remove label style from printing context

Previously, the SDocContext used for code generation contained
information whether the labels should use Asm or C style.
However, at every individual call site, this is known statically.
This removes the parameter to 'PprCode' and replaces every 'pdoc'
used to print a label in code style with 'pprCLabel' or 'pprAsmLabel'.
The OutputableP instance is now used only for dumps.

The output of T15155 changes, it now uses the Asm style
(which is faithful to what actually happens).

- - - - -
1007829b by Cheng Shao at 2022-08-26T15:06:40-04:00
boot: cleanup legacy args

Cleanup legacy boot script args, following removal of the legacy make
build system.

- - - - -
95fe09da by Simon Peyton Jones at 2022-08-27T00:29:02-04:00
Improve SpecConstr for evals

As #21763 showed, we were over-specialising in some cases, when
the function involved was doing a simple 'eval', but not taking
the value apart, or branching on it.

This MR fixes the problem.  See Note [Do not specialise evals].

Nofib barely budges, except that spectral/cichelli allocates about
3% less.

Compiler bytes-allocated improves a bit
   geo. mean                                          -0.1%
   minimum                                            -0.5%
   maximum                                            +0.0%

The -0.5% is on T11303b, for what it's worth.

- - - - -
565a8ec8 by Matthew Pickering at 2022-08-27T00:29:39-04:00
Revert "Revert "Refactor SpecConstr to use treat bindings uniformly""

This reverts commit 851d8dd89a7955864b66a3da8b25f1dd88a503f8.

This commit was originally reverted due to an increase in space usage.
This was diagnosed as because the SCE increased in size and that was
being retained by another leak. See #22102

- - - - -
82ce1654 by Matthew Pickering at 2022-08-27T00:29:39-04:00
Avoid retaining bindings via ModGuts held on the stack

It's better to overwrite the bindings fields of the ModGuts before
starting an iteration as then all the old bindings can be collected as
soon as the simplifier has processed them. Otherwise we end up with the
old bindings being alive until right at the end of the simplifier pass
as the mg_binds field is only modified right at the end.

- - - - -
64779dcd by Matthew Pickering at 2022-08-27T00:29:39-04:00
Force imposs_deflt_cons in filterAlts

This fixes a pretty serious space leak as the forced thunk would retain
`Alt b` values which would then contain reference to a lot of old
bindings and other simplifier gunk.

The OtherCon unfolding was not forced on subsequent simplifier runs so
more and more old stuff would be retained until the end of
simplification.

Fixing this has a drastic effect on maximum residency for the mmark
package which goes from

```
  45,005,401,056 bytes allocated in the heap
  17,227,721,856 bytes copied during GC
     818,281,720 bytes maximum residency (33 sample(s))
       9,659,144 bytes maximum slop
            2245 MiB total memory in use (0 MB lost due to fragmentation)
```

to

```
  45,039,453,304 bytes allocated in the heap
  13,128,181,400 bytes copied during GC
     331,546,608 bytes maximum residency (40 sample(s))
       7,471,120 bytes maximum slop
             916 MiB total memory in use (0 MB lost due to fragmentation)
```

See #21993 for some more discussion.

- - - - -
a3b23a33 by Matthew Pickering at 2022-08-27T00:29:39-04:00
Use Solo to avoid retaining the SCE but to avoid performing the substitution

The use of Solo here allows us to force the selection into the SCE to obtain
the Subst but without forcing the substitution to be applied. The resulting thunk
is placed into a lazy field which is rarely forced, so forcing it regresses
peformance.

- - - - -
161a6f1f by Simon Peyton Jones at 2022-08-27T00:30:14-04:00
Fix a nasty loop in Tidy

As the remarkably-simple #22112 showed, we were making a black hole
in the unfolding of a self-recursive binding.  Boo!

It's a bit tricky.  Documented in GHC.Iface.Tidy,
   Note [tidyTopUnfolding: avoiding black holes]

- - - - -
68e6786f by Giles Anderson at 2022-08-29T00:01:35+02:00
Use TcRnDiagnostic in GHC.Tc.TyCl.Class (#20117)

The following `TcRnDiagnostic` messages have been introduced:

TcRnIllegalHsigDefaultMethods
TcRnBadGenericMethod
TcRnWarningMinimalDefIncomplete
TcRnDefaultMethodForPragmaLacksBinding
TcRnIgnoreSpecialisePragmaOnDefMethod
TcRnBadMethodErr
TcRnNoExplicitAssocTypeOrDefaultDeclaration

- - - - -
cbe51ac5 by Simon Peyton Jones at 2022-08-29T04:18:57-04:00
Fix a bug in anyInRnEnvR

This bug was a subtle error in anyInRnEnvR, introduced by

    commit d4d3fe6e02c0eb2117dbbc9df72ae394edf50f06
    Author: Andreas Klebinger <klebinger.andreas at gmx.at>
    Date:   Sat Jul 9 01:19:52 2022 +0200

    Rule matching: Don't compute the FVs if we don't look at them.

The net result was #22028, where a rewrite rule would wrongly
match on a lambda.

The fix to that function is easy.

- - - - -
0154bc80 by sheaf at 2022-08-30T06:05:41-04:00
Various Hadrian bootstrapping fixes

  - Don't always produce a distribution archive (#21629)
  - Use correct executable names for ghc-pkg and hsc2hs on windows
    (we were missing the .exe file extension)
  - Fix a bug where we weren't using the right archive format on Windows
    when unpacking the bootstrap sources.

Fixes #21629

- - - - -
451b1d90 by Matthew Pickering at 2022-08-30T06:06:16-04:00
ci: Attempt using normal submodule cloning strategy

We do not use any recursively cloned submodules, and this protects us
from flaky upstream remotes.

Fixes #22121

- - - - -
9d5ad7c4 by Pi Delport at 2022-08-30T22:40:46+00:00
Fix typo in Any docs: stray "--"

- - - - -
3a002632 by Pi Delport at 2022-08-30T22:40:46+00:00
Fix typo in Any docs: syntatic -> syntactic

- - - - -
7f490b13 by Simon Peyton Jones at 2022-08-31T03:53:54-04:00
Add a missing trimArityType

This buglet was exposed by #22114, a consequence of my earlier
refactoring of arity for join points.

- - - - -
e6fc820f by Ben Gamari at 2022-08-31T13:16:01+01:00
Bump binary submodule to 0.8.9.1

- - - - -
4c1e7b22 by Ben Gamari at 2022-08-31T13:16:01+01:00
Bump stm submodule to 2.5.1.0

- - - - -
837472b4 by Ben Gamari at 2022-08-31T13:16:01+01:00
users-guide: Document system-cxx-std-lib

- - - - -
f7a9947a by Douglas Wilson at 2022-08-31T13:16:01+01:00
Update submodule containers to 0.6.6

- - - - -
4ab1c2ca by Douglas Wilson at 2022-08-31T13:16:02+01:00
Update submodule process to 1.6.15.0

- - - - -
1309ea1e by Ben Gamari at 2022-08-31T13:16:02+01:00
Bump directory submodule to 1.3.7.1

- - - - -
7962a33a by Douglas Wilson at 2022-08-31T13:16:02+01:00
Bump text submodule to 2.0.1

- - - - -
fd8d80c3 by Ben Gamari at 2022-08-31T13:26:52+01:00
Bump deepseq submodule to 1.4.8.0

- - - - -
a9baafac by Ben Gamari at 2022-08-31T13:26:52+01:00
Add dates to base, ghc-prim changelogs

- - - - -
2cee323c by Ben Gamari at 2022-08-31T13:26:52+01:00
Update autoconf scripts

Scripts taken from autoconf 02ba26b218d3d3db6c56e014655faf463cefa983

- - - - -
e62705ff by Ben Gamari at 2022-08-31T13:26:53+01:00
Bump bytestring submodule to 0.11.3.1

- - - - -
f7b4dcbd by Douglas Wilson at 2022-08-31T13:26:53+01:00
Update submodule Cabal to tag Cabal-v3.8.1.0

closes #21931

- - - - -
e8eaf807 by Matthew Pickering at 2022-08-31T18:27:57-04:00
Refine in-tree compiler args for --test-compiler=stage1

Some of the logic to calculate in-tree arguments was not correct for the
stage1 compiler. Namely we were not correctly reporting whether we were
building static or dynamic executables and whether debug assertions were
enabled.

Fixes #22096

- - - - -
6b2f7ffe by Matthew Pickering at 2022-08-31T18:27:57-04:00
Make ghcDebugAssertions into a Stage predicate (Stage -> Bool)

We also care whether we have debug assertions enabled for a stage one
compiler, but the way which we turned on the assertions was quite
different from the stage2 compiler. This makes the logic for turning on
consistent across both and has the advantage of being able to correct
determine in in-tree args whether a flavour enables assertions or not.

Ticket #22096

- - - - -
15111af6 by Zubin Duggal at 2022-09-01T01:18:50-04:00
Add regression test for #21550

This was fixed by ca90ffa321a31842a32be1b5b6e26743cd677ec5
"Use local instances with least superclass depth"

- - - - -
7d3a055d by Krzysztof Gogolewski at 2022-09-01T01:19:26-04:00
Minor cleanup

- Remove mkHeteroCoercionType, sdocImpredicativeTypes, isStateType (unused),
  isCoVar_maybe (duplicated by getCoVar_maybe)
- Replace a few occurrences of voidPrimId with (# #).
  void# is a deprecated synonym for the unboxed tuple.
- Use showSDoc in :show linker.
  This makes it consistent with the other :show commands

- - - - -
31a8989a by Tommy Bidne at 2022-09-01T12:01:20-04:00
Change Ord defaults per CLC proposal

Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/24#issuecomment-1233331267

- - - - -
7f527f01 by Matthew Pickering at 2022-09-01T12:01:56-04:00
Fix bootstrap with ghc-9.0

It turns out Solo is a very recent addition to base, so for older GHC
versions we just defined it inline here the one place we use it in the
compiler.

- - - - -
d2be80fd by Sebastian Graf at 2022-09-05T23:12:14-04:00
DmdAnal: Don't panic in addCaseBndrDmd (#22039)

Rather conservatively return Top.
See Note [Untyped demand on case-alternative binders].

I also factored `addCaseBndrDmd` into two separate functions `scrutSubDmd` and
`fieldBndrDmds`.

Fixes #22039.

- - - - -
25f68ace by Ben Gamari at 2022-09-05T23:12:50-04:00
gitlab-ci: Ensure that ghc derivation is in scope

Previously the lint-ci job attempted to use cabal-install (specifically
`cabal update`) without a GHC in PATH. However, cabal-install-3.8
appears to want GHC, even for `cabal update`.

- - - - -
f37b621f by sheaf at 2022-09-06T11:51:53+00:00
Update instances.rst, clarifying InstanceSigs

Fixes #22103

- - - - -
d4f908f7 by Jan Hrček at 2022-09-06T15:36:58-04:00
Fix :add docs in user guide

- - - - -
808bb793 by Cheng Shao at 2022-09-06T15:37:35-04:00
ci: remove unused build_make/test_make in ci script

- - - - -
d0a2efb2 by Eric Lindblad at 2022-09-07T16:42:45-04:00
typo
- - - - -
fac0098b by Eric Lindblad at 2022-09-07T16:42:45-04:00
typos

- - - - -
a581186f by Eric Lindblad at 2022-09-07T16:42:45-04:00
whitespace

- - - - -
04a738cb by Cheng Shao at 2022-09-07T16:43:22-04:00
CmmToAsm: remove unused ModLocation from NatM_State

- - - - -
ee1cfaa9 by Krzysztof Gogolewski at 2022-09-07T16:43:58-04:00
Minor SDoc cleanup

Change calls to renderWithContext with showSDocOneLine; it's more
efficient and explanatory.

Remove polyPatSig (unused)

- - - - -
7918265d by Krzysztof Gogolewski at 2022-09-07T16:43:58-04:00
Remove Outputable Char instance

Use 'text' instead of 'ppr'.
Using 'ppr' on the list "hello" rendered as "h,e,l,l,o".

- - - - -
77209ab3 by Georgi Lyubenov at 2022-09-08T17:14:36+03:00
Export liftA2 from Prelude

Changes:
In order to be warning free and compatible, we hide Applicative(..)
from Prelude in a few places and instead import it directly from
Control.Applicative.
Please see the migration guide at
https://github.com/haskell/core-libraries-committee/blob/main/guides/export-lifta2-prelude.md
for more details.

This means that Applicative is now exported in its entirety from
Prelude.

Motivation:

This change is motivated by a few things:
* liftA2 is an often used function, even more so than (<*>) for some
  people.
* When implementing Applicative, the compiler will prompt you for either
  an implementation of (<*>) or of liftA2, but trying to use the latter
  ends with an error, without further imports. This could be confusing
  for newbies.
* For teaching, it is often times easier to introduce liftA2 first,
  as it is a natural generalisation of fmap.
* This change seems to have been unanimously and enthusiastically
  accepted by the CLC members, possibly indicating a lot of love for it.
* This change causes very limited breakage, see the linked issue below
  for an investigation on this.

See https://github.com/haskell/core-libraries-committee/issues/50
for the surrounding discussion and more details.

- - - - -
442a94e8 by Georgi Lyubenov at 2022-09-08T17:14:36+03:00
Add changelog entry for liftA2 export from Prelude

- - - - -
fb968680 by Georgi Lyubenov at 2022-09-08T17:14:36+03:00
Bump submodule containers to one with liftA2 warnings fixed

- - - - -
f54ff818 by Georgi Lyubenov at 2022-09-08T17:14:36+03:00
Bump submodule Cabal to one with liftA2 warnings fixed

- - - - -
a4b34808 by Georgi Lyubenov at 2022-09-08T17:14:36+03:00
Isolate some Applicative hidings to GHC.Prelude

By reexporting the entirety of Applicative from GHC.Prelude, we can save
ourselves some `hiding` and importing of `Applicative` in consumers of GHC.Prelude.
This also has the benefit of isolating this type of change to
GHC.Prelude, so that people in the future don't have to think about it.

- - - - -
9c4ea90c by Cheng Shao at 2022-09-08T17:49:47-04:00
CmmToC: enable 64-bit CallishMachOp on 32-bit targets

Normally, the unregisterised builds avoid generating 64-bit
CallishMachOp in StgToCmm, so CmmToC doesn't support these. However,
there do exist cases where we'd like to invoke cmmToC for other cmm
inputs which may contain such CallishMachOps, and it's a rather low
effort to add support for these since they only require calling into
existing ghc-prim cbits.

- - - - -
04062510 by Alexis King at 2022-09-11T11:30:32+02:00
Add native delimited continuations to the RTS

This patch implements GHC proposal 313, "Delimited continuation
primops", by adding native support for delimited continuations to the
GHC RTS.

All things considered, the patch is relatively small. It almost
exclusively consists of changes to the RTS; the compiler itself is
essentially unaffected. The primops come with fairly extensive Haddock
documentation, and an overview of the implementation strategy is given
in the Notes in rts/Continuation.c.

This first stab at the implementation prioritizes simplicity over
performance. Most notably, every continuation is always stored as a
single, contiguous chunk of stack. If one of these chunks is
particularly large, it can result in poor performance, as the current
implementation does not attempt to cleverly squeeze a subset of the
stack frames into the existing stack: it must fit all at once. If this
proves to be a performance issue in practice, a cleverer strategy would
be a worthwhile target for future improvements.

- - - - -
ee471dfb by Cheng Shao at 2022-09-12T07:07:33-04:00
rts: fix missing dirty_MVAR argument in stg_writeIOPortzh

- - - - -
a5f9c35f by Cheng Shao at 2022-09-12T13:29:05-04:00
ci: enable parallel compression for xz

- - - - -
3a815f30 by Ryan Scott at 2022-09-12T13:29:41-04:00
Windows: Always define _UCRT when compiling C code

As seen in #22159, this is required to ensure correct behavior when MinGW-w64
headers are in the `C_INCLUDE_PATH`.

Fixes #22159.

- - - - -
65a0bd69 by sheaf at 2022-09-13T10:27:52-04:00
Add diagnostic codes

This MR adds diagnostic codes, assigning unique numeric codes to
error and warnings, e.g.

  error: [GHC-53633]
  Pattern match is redundant

This is achieved as follows:

  - a type family GhcDiagnosticCode that gives the diagnostic code
    for each diagnostic constructor,
  - a type family ConRecursInto that specifies whether to recur into
    an argument of the constructor to obtain a more fine-grained code
    (e.g. different error codes for different 'deriving' errors),
  - generics machinery to generate the value-level function assigning
    each diagnostic its error code; see Note [Diagnostic codes using generics]
    in GHC.Types.Error.Codes.

The upshot is that, to add a new diagnostic code, contributors only need
to modify the two type families mentioned above. All logic relating to
diagnostic codes is thus contained to the GHC.Types.Error.Codes module,
with no code duplication.

This MR also refactors error message datatypes a bit, ensuring we can
derive Generic for them, and cleans up the logic around constraint
solver reports by splitting up 'TcSolverReportInfo' into separate
datatypes (see #20772).

Fixes #21684

- - - - -
362cca13 by sheaf at 2022-09-13T10:27:53-04:00
Diagnostic codes: acccept test changes

The testsuite output now contains diagnostic codes, so many tests need
to be updated at once.
We decided it was best to keep the diagnostic codes in the testsuite
output, so that contributors don't inadvertently make changes to the
diagnostic codes.

- - - - -
08f6730c by Adam Gundry at 2022-09-13T10:28:29-04:00
Allow imports to reference multiple fields with the same name (#21625)

If a module `M` exports two fields `f` (using DuplicateRecordFields), we can
still accept

    import M (f)
    import M hiding (f)

and treat `f` as referencing both of them.  This was accepted in GHC 9.0, but gave
rise to an ambiguity error in GHC 9.2.  See #21625.

This patch also documents this behaviour in the user's guide, and updates the
test for #16745 which is now treated differently.

- - - - -
c14370d7 by Cheng Shao at 2022-09-13T10:29:07-04:00
ci: remove unused appveyor config

- - - - -
dc6af9ed by Cheng Shao at 2022-09-13T10:29:45-04:00
compiler: remove unused lazy state monad

- - - - -
646d15ad by Eric Lindblad at 2022-09-14T03:13:56-04:00
Fix typos

This fixes various typos and spelling mistakes
in the compiler.

Fixes #21891

- - - - -
7d7e71b0 by Matthew Pickering at 2022-09-14T03:14:32-04:00
hadrian: Bump index state

This bumps the index state so a build plan can also be found when
booting with 9.4.

Fixes #22165

- - - - -
98b62871 by Matthew Pickering at 2022-09-14T17:17:04-04:00
hadrian: Use a stamp file to record when a package is built in a certain way

Before this patch which library ways we had built wasn't recorded
directly. So you would run into issues if you build the .conf file with
some library ways before switching the library ways which you wanted to
build.

Now there is one stamp file for each way, so in order to build a
specific way you can need that specific stamp file rather than going
indirectly via the .conf file.

- - - - -
b42cedbe by Matthew Pickering at 2022-09-14T17:17:04-04:00
hadrian: Inplace/Final package databases

There are now two different package databases per stage. An inplace
package database contains .conf files which point directly into the
build directories. The final package database contains .conf files which
point into the installed locations. The inplace .conf files are created
before any building happens and have fake ABI hash values. The final
.conf files are created after a package finished building and contains
the proper ABI has.

The motivation for this is to make the dependency structure more
fine-grained when building modules. Now a module depends just depends
directly on M.o from package p rather than the .conf file depend on the
.conf file for package p. So when all of a modules direct dependencies
have finished building we can start building it rather than waiting for
the whole package to finish.

The secondary motivation is that the multi-repl doesn't need to build
everything before starting the multi-repl session. We can just configure
the inplace package-db and use that in order to start the repl.

- - - - -
6515c32b by Matthew Pickering at 2022-09-14T17:17:04-04:00
hadrian: Add some more packages to multi-cradle

The main improvement here is to pass `-this-unit-id` for executables so
that they can be added to the multi-cradle if desired as well as normal
library packages.

- - - - -
e470e91f by Matthew Pickering at 2022-09-14T17:17:04-04:00
hadrian: Need builders needed by Cabal Configure in parallel

Because of the use of withStaged (which needs the necessary builder)
when configuring a package, the builds of stage1:exe:ghc-bin and
stage1:exe:ghc-pkg where being linearised when building a specific
target like `binary-dist-dir`.

Thankfully the fix is quite local, to supply all the `withStaged`
arguments together so the needs can be batched together and hence
performed in parallel.

Fixes #22093

- - - - -
c4438347 by Matthew Pickering at 2022-09-14T17:17:04-04:00
Remove stage1:exe:ghc-bin pre-build from CI script

CI builds stage1:exe:ghc-bin before the binary-dist target which
introduces some quite bad linearisation (see #22093) because we don't
build stage1 compiler in parallel with anything. Then when the
binary-dist target is started we have to build stage1:exe:ghc-pkg before
doing anything.

Fixes #22094

- - - - -
71d8db86 by Matthew Pickering at 2022-09-14T17:17:04-04:00
hadrian: Add extra implicit dependencies from DeriveLift

ghc -M should know that modules which use DeriveLift (or
TemplateHaskellQuotes) need TH.Lib.Internal but until it does, we have
to add these extra edges manually or the modules will be compiled before
TH.Lib.Internal is compiled which leads to a desugarer error.

- - - - -
43e574f0 by Greg Steuck at 2022-09-14T17:17:43-04:00
Repair c++ probing on OpenBSD

Failure without this change:
```
checking C++ standard library flavour... libc++
checking for linkage against 'c++ c++abi'... failed
checking for linkage against 'c++ cxxrt'... failed
configure: error: Failed to find C++ standard library
```

- - - - -
534b39ee by Douglas Wilson at 2022-09-14T17:18:21-04:00
libraries: template-haskell: vendor filepath differently

Vendoring with ../ in hs-source-dirs prevents upload to hackage.

(cherry picked from commit 1446be7586ba70f9136496f9b67f792955447842)

- - - - -
bdd61cd6 by M Farkas-Dyck at 2022-09-14T22:39:34-04:00
Unbreak Hadrian with Cabal 3.8.

- - - - -
df04d6ec by Krzysztof Gogolewski at 2022-09-14T22:40:09-04:00
Fix typos

- - - - -
d6ea8356 by Andreas Klebinger at 2022-09-15T10:12:41+02:00
Tag inference: Fix #21954 by retaining tagsigs of vars in function position.

For an expression like:

    case x of y
      Con z -> z

If we also retain the tag sig for z we can generate code to immediately return
it rather than calling out to stg_ap_0_fast.

- - - - -
7cce7007 by Andreas Klebinger at 2022-09-15T10:12:42+02:00
Stg.InferTags.Rewrite - Avoid some thunks.

- - - - -
88c4cbdb by Cheng Shao at 2022-09-16T13:57:56-04:00
hadrian: enable -fprof-late only for profiling ways

- - - - -
d7235831 by Cheng Shao at 2022-09-16T13:57:56-04:00
hadrian: add late_ccs flavour transformer

- - - - -
ce203753 by Cheng Shao at 2022-09-16T13:58:34-04:00
configure: remove unused program checks

- - - - -
9b4c1056 by Pierre Le Marre at 2022-09-16T13:59:16-04:00
Update to Unicode 15.0

- - - - -
c6e9b89a by Bodigrim at 2022-09-16T13:59:55-04:00
Avoid partial head and tail in ghc-heap; replace with total pattern-matching

- - - - -
616afde3 by Cheng Shao at 2022-09-16T14:00:33-04:00
hadrian: relax Cabal upper bound to allow building with Cabal-3.8

A follow up of !8910.

- - - - -
df35d994 by Alexis King at 2022-09-16T14:01:11-04:00
Add links to the continuations haddocks in the docs for each primop

fixes #22176

- - - - -
383f7549 by Matthew Pickering at 2022-09-16T21:42:10-04:00
-Wunused-pattern-binds: Recurse into patterns to check whether there's a splice

See the examples in #22057 which show we have to traverse deeply into a
pattern to determine whether it contains a splice or not. The original
implementation pointed this out but deemed this very shallow traversal
"too expensive".

Fixes #22057

I also fixed an oversight in !7821 which meant we lost a warning which
was present in 9.2.2.

Fixes #22067

- - - - -
5031bf49 by sheaf at 2022-09-16T21:42:49-04:00
Hadrian: Don't try to build terminfo on Windows

Commit b42cedbe introduced a dependency on terminfo on Windows,
but that package isn't available on Windows.

- - - - -
c9afe221 by M Farkas-Dyck at 2022-09-17T06:44:47-04:00
Clean up some. In particular:
• Delete some dead code, largely under `GHC.Utils`.
• Clean up a few definitions in `GHC.Utils.(Misc, Monad)`.
• Clean up `GHC.Types.SrcLoc`.
• Derive stock `Functor, Foldable, Traversable` for more types.
• Derive more instances for newtypes.

Bump haddock submodule.

- - - - -
85431ac3 by Cheng Shao at 2022-09-17T06:45:25-04:00
driver: pass original Cmm filename in ModLocation

When compiling Cmm, the ml_hs_file field is used to indicate Cmm
filename when later generating DWARF information. We should pass the
original filename here, otherwise for preprocessed Cmm files, the
filename will be a temporary filename which is confusing.

- - - - -
63aa0069 by Cheng Shao at 2022-09-17T06:46:04-04:00
rts: remove legacy logging cabal flag

- - - - -
bd0f4184 by Cheng Shao at 2022-09-17T06:46:04-04:00
rts: make threaded ways optional

For certain targets (e.g. wasm32-wasi), the threaded rts is known not to
work. This patch adds a "threaded" cabal flag to rts to make threaded
rts ways optional. Hadrian enables this flag iff the flavour rtsWays
contains threaded ways.

- - - - -
8a666ad2 by Ryan Scott at 2022-09-18T08:00:44-04:00
DeriveFunctor: Check for last type variables using dataConUnivTyVars

Previously, derived instances of `Functor` (as well as the related classes
`Foldable`, `Traversable`, and `Generic1`) would determine which constraints to
infer by checking for fields that contain the last type variable. The problem
was that this last type variable was taken from `tyConTyVars`. For GADTs, the
type variables in each data constructor are _not_ the same type variables as
in `tyConTyVars`, leading to #22167.

This fixes the issue by instead checking for the last type variable using
`dataConUnivTyVars`. (This is very similar in spirit to the fix for #21185,
which also replaced an errant use of `tyConTyVars` with type variables from
each data constructor.)

Fixes #22167.

- - - - -
78037167 by Vladislav Zavialov at 2022-09-18T08:01:20-04:00
Lexer: pass updated buffer to actions (#22201)

In the lexer, predicates have the following type:
	{ ... } :: user       -- predicate state
		-> AlexInput  -- input stream before the token
		-> Int        -- length of the token
		-> AlexInput  -- input stream after the token
		-> Bool       -- True <=> accept the token
This is documented in the Alex manual.

There is access to the input stream both before and after the token.
But when the time comes to construct the token, GHC passes only the
initial string buffer to the lexer action. This patch fixes it:

	- type Action = PsSpan -> StringBuffer -> Int ->                 P (PsLocated Token)
	+ type Action = PsSpan -> StringBuffer -> Int -> StringBuffer -> P (PsLocated Token)

Now lexer actions have access to the string buffer both before and after
the token, just like the predicates. It's just a matter of passing an
additional function parameter throughout the lexer.

- - - - -
75746594 by Vladislav Zavialov at 2022-09-18T08:01:20-04:00
Lexer: define varsym without predicates (#22201)

Before this patch, the varsym lexing rules were defined as follows:

	<0> {
	  @varsym / { precededByClosingToken `alexAndPred` followedByOpeningToken } { varsym_tight_infix }
	  @varsym / { followedByOpeningToken }  { varsym_prefix }
	  @varsym / { precededByClosingToken }  { varsym_suffix }
	  @varsym                               { varsym_loose_infix }
	}

Unfortunately, this meant that the predicates 'precededByClosingToken' and
'followedByOpeningToken' were recomputed several times before we could figure
out the whitespace context.

With this patch, we check for whitespace context directly in the lexer
action:

	<0> {
	  @varsym { with_op_ws varsym }
	}

The checking for opening/closing tokens happens in 'with_op_ws' now,
which is part of the lexer action rather than the lexer predicate.

- - - - -
c1f81b38 by M Farkas-Dyck at 2022-09-19T09:07:05-04:00
Scrub partiality about `NewOrData`.

Rather than a list of constructors and a `NewOrData` flag, we define `data DataDefnCons a = NewTypeCon a | DataTypeCons [a]`, which enforces a newtype to have exactly one constructor.

Closes #22070.

Bump haddock submodule.

- - - - -
1e1ed8c5 by Cheng Shao at 2022-09-19T09:07:43-04:00
CmmToC: emit __builtin_unreachable() after noreturn ccalls

Emit a __builtin_unreachable() call after a foreign call marked as
CmmNeverReturns. This is crucial to generate correctly typed code for
wasm; as for other archs, this is also beneficial for the C compiler
optimizations.

- - - - -
19f45a25 by Jan Hrček at 2022-09-20T03:49:29-04:00
Document :unadd GHCi command in user guide

- - - - -
545ff490 by sheaf at 2022-09-20T03:50:06-04:00
Hadrian: merge archives even in stage 0

We now always merge .a archives when ar supports -L.
This change is necessary in order to bootstrap GHC using GHC 9.4
on Windows, as nested archives aren't supported.
Not doing so triggered bug #21990 when trying to use the Win32
package, with errors such as:

  Not a x86_64 PE+ file.
  Unknown COFF 4 type in getHeaderInfo.

  ld.lld: error: undefined symbol: Win32zm2zi12zi0zi0_SystemziWin32ziConsoleziCtrlHandler_withConsoleCtrlHandler1_info

We have to be careful about which ar is meant: in stage 0, the check
should be done on the system ar (system-ar in system.config).

- - - - -
59fe128c by Vladislav Zavialov at 2022-09-20T03:50:42-04:00
Fix -Woperator-whitespace for consym (part of #19372)

Due to an oversight, the initial specification and implementation of
-Woperator-whitespace focused on varsym exclusively and completely
ignored consym.

This meant that expressions such as "x+ y" would produce a warning,
while "x:+ y" would not.

The specification was corrected in ghc-proposals pull request #404,
and this patch updates the implementation accordingly.

Regression test included.

- - - - -
c4c2cca0 by John Ericson at 2022-09-20T13:11:49-04:00
Add `Eq` and `Ord` instances for `Generically1`

These are needed so the subsequent commit overhauling the `*1` classes
type-checks.

- - - - -
7beb356e by John Ericson at 2022-09-20T13:11:50-04:00
Relax instances for Functor combinators; put superclass on Class1 and Class2 to make non-breaking

This change is approved by the Core Libraries commitee in
https://github.com/haskell/core-libraries-committee/issues/10

The first change makes the `Eq`, `Ord`, `Show`, and `Read` instances for
`Sum`, `Product`, and `Compose` match those for `:+:`, `:*:`, and `:.:`.
These have the proper flexible contexts that are exactly what the
instance needs:

For example, instead of
```haskell
instance (Eq1 f, Eq1 g, Eq a) => Eq (Compose f g a) where
  (==) = eq1
```
we do
```haskell
deriving instance Eq (f (g a)) => Eq (Compose f g a)
```

But, that change alone is rather breaking, because until now `Eq (f a)`
and `Eq1 f` (and respectively the other classes and their `*1`
equivalents too) are *incomparable* constraints. This has always been an
annoyance of working with the `*1` classes, and now it would rear it's
head one last time as an pesky migration.

Instead, we give the `*1` classes superclasses, like so:
```haskell
(forall a. Eq a => Eq (f a)) => Eq1 f
```
along with some laws that canonicity is preserved, like:
```haskell
liftEq (==) = (==)
```

and likewise for `*2` classes:
```haskell
(forall a. Eq a => Eq1 (f a)) => Eq2 f
```
and laws:
```haskell
liftEq2 (==) = liftEq1
```

The `*1` classes also have default methods using the `*2` classes where
possible.

What this means, as explained in the docs, is that `*1` classes really
are generations of the regular classes, indicating that the methods can
be split into a canonical lifting combined with a canonical inner, with
the super class "witnessing" the laws[1] in a fashion.

Circling back to the pragmatics of migrating, note that the superclass
means evidence for the old `Sum`, `Product`, and `Compose` instances is
(more than) sufficient, so breakage is less likely --- as long no
instances are "missing", existing polymorphic code will continue to
work.

Breakage can occur when a datatype implements the `*1` class but not the
corresponding regular class, but this is almost certainly an oversight.
For example, containers made that mistake for `Tree` and `Ord`, which I
fixed in https://github.com/haskell/containers/pull/761, but fixing the
issue by adding `Ord1` was extremely *un*controversial.

`Generically1` was also missing `Eq`, `Ord`, `Read,` and `Show`
instances. It is unlikely this would have been caught without
implementing this change.

-----

[1]: In fact, someday, when the laws are part of the language and not
only documentation, we might be able to drop the superclass field of the
dictionary by using the laws to recover the superclass in an
instance-agnostic manner, e.g. with a *non*-overloaded function with
type:

```haskell
DictEq1 f -> DictEq a -> DictEq (f a)
```

But I don't wish to get into optomizations now, just demonstrate the
close relationship between the law and the superclass.

Bump haddock submodule because of test output changing.

- - - - -
6a8c6b5e by Tom Ellis at 2022-09-20T13:12:27-04:00
Add notes to ghc-prim Haddocks that users should not import it

- - - - -
ee9d0f5c by matoro at 2022-09-20T13:13:06-04:00
docs: clarify that LLVM codegen is not available in unregisterised mode

The current docs are misleading and suggest that it is possible to use
LLVM codegen from an unregisterised build.  This is not the case;
attempting to pass `-fllvm` to an unregisterised build warns:

```
when making flags consistent: warning:
    Target platform uses unregisterised ABI, so compiling via C
```

and uses the C codegen anyway.

- - - - -
854224ed by Nicolas Trangez at 2022-09-20T20:14:29-04:00
rts: remove copy-paste error from `cabal.rts.in`

This was, likely accidentally, introduced in 4bf542bf1c.

See: 4bf542bf1cdf2fa468457fc0af21333478293476

- - - - -
c8ae3add by Matthew Pickering at 2022-09-20T20:15:04-04:00
hadrian: Add extra_dependencies edges for all different ways

The hack to add extra dependencies needed by DeriveLift extension missed
the cases for profiles and dynamic ways. For the profiled way this leads
to errors like:

```
GHC error in desugarer lookup in Data.IntSet.Internal:
  Failed to load interface for ‘Language.Haskell.TH.Lib.Internal’
  Perhaps you haven't installed the profiling libraries for package ‘template-haskell’?
  Use -v (or `:set -v` in ghci) to see a list of the files searched for.
ghc: panic! (the 'impossible' happened)
  GHC version 9.5.20220916:
        initDs
```

Therefore the fix is to add these extra edges in.

Fixes #22197

- - - - -
a971657d by Mon Aaraj at 2022-09-21T06:41:24+03:00
users-guide: fix incorrect ghcappdata folder for unix and windows

- - - - -
06ccad0d by sheaf at 2022-09-21T08:28:49-04:00
Don't use isUnliftedType in isTagged

The function GHC.Stg.InferTags.Rewrite.isTagged can be given
the Id of a join point, which might be representation polymorphic.
This would cause the call to isUnliftedType to crash. It's better
to use typeLevity_maybe instead.

Fixes #22212

- - - - -
c0ba775d by Teo Camarasu at 2022-09-21T14:30:37-04:00
Add fragmentation statistic to GHC.Stats

Implements #21537

- - - - -
2463df2f by Torsten Schmits at 2022-09-21T14:31:24-04:00
Rename Solo[constructor] to MkSolo

Part of proposal 475 (https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0475-tuple-syntax.rst)

Moves all tuples to GHC.Tuple.Prim
Updates ghc-prim version (and bumps bounds in dependents)

updates haddock submodule
updates deepseq submodule
updates text submodule

- - - - -
9034fada by Matthew Pickering at 2022-09-22T09:25:29-04:00
Update filepath to filepath-1.4.100.0

Updates submodule

* Always rely on vendored filepath
* filepath must be built as stage0 dependency because it uses
  template-haskell.

Towards #22098

- - - - -
615e2278 by Krzysztof Gogolewski at 2022-09-22T09:26:05-04:00
Minor refactor around Outputable

* Replace 'text . show' and 'ppr' with 'int'.
* Remove Outputable.hs-boot, no longer needed
* Use pprWithCommas
* Factor out instructions in AArch64 codegen

- - - - -
aeafdba5 by Sebastian Graf at 2022-09-27T15:14:54+02:00
Demand: Clear distinction between Call SubDmd and eval Dmd (#21717)

In #21717 we saw a reportedly unsound strictness signature due to an unsound
definition of plusSubDmd on Calls. This patch contains a description and the fix
to the unsoundness as outlined in `Note [Call SubDemand vs. evaluation Demand]`.

This fix means we also get rid of the special handling of `-fpedantic-bottoms`
in eta-reduction. Thanks to less strict and actually sound strictness results,
we will no longer eta-reduce the problematic cases in the first place, even
without `-fpedantic-bottoms`.

So fixing the unsoundness also makes our eta-reduction code simpler with less
hacks to explain. But there is another, more unfortunate side-effect:
We *unfix* #21085, but fortunately we have a new fix ready:
See `Note [mkCall and plusSubDmd]`.

There's another change:
I decided to make `Note [SubDemand denotes at least one evaluation]` a lot
simpler by using `plusSubDmd` (instead of `lubPlusSubDmd`) even if both argument
demands are lazy. That leads to less precise results, but in turn rids ourselves
from the need for 4 different `OpMode`s and the complication of
`Note [Manual specialisation of lub*Dmd/plus*Dmd]`. The result is simpler code
that is in line with the paper draft on Demand Analysis.

I left the abandoned idea in `Note [Unrealised opportunity in plusDmd]` for
posterity. The fallout in terms of regressions is negligible, as the testsuite
and NoFib shows.

```
        Program         Allocs    Instrs
--------------------------------------------------------------------------------
         hidden          +0.2%     -0.2%
         linear          -0.0%     -0.7%
--------------------------------------------------------------------------------
            Min          -0.0%     -0.7%
            Max          +0.2%     +0.0%
 Geometric Mean          +0.0%     -0.0%
```

Fixes #21717.

- - - - -
9b1595c8 by Ross Paterson at 2022-09-27T14:12:01-04:00
implement proposal 106 (Define Kinds Without Promotion) (fixes #6024)

includes corresponding changes to haddock submodule

- - - - -
c2d73cb4 by Andreas Klebinger at 2022-09-28T15:07:30-04:00
Apply some tricks to speed up core lint.

Below are the noteworthy changes and if given their impact on compiler
allocations for a type heavy module:

* Use the oneShot trick on LintM
* Use a unboxed tuple for the result of LintM: ~6% reduction
* Avoid a thunk for the result of typeKind in lintType: ~5% reduction
* lint_app: Don't allocate the error msg in the hot code path: ~4%
  reduction
* lint_app: Eagerly force the in scope set: ~4%
* nonDetCmpType: Try to short cut using reallyUnsafePtrEquality#: ~2%
* lintM: Use a unboxed maybe for the `a` result: ~12%
* lint_app: make go_app tail recursive to avoid allocating the go function
            as heap closure: ~7%
* expandSynTyCon_maybe: Use a specialized data type

For a less type heavy module like nofib/spectral/simple compiled with
-O -dcore-lint allocations went down by ~24% and compile time by ~9%.

-------------------------
Metric Decrease:
    T1969
-------------------------

- - - - -
b74b6191 by sheaf at 2022-09-28T15:08:10-04:00
matchLocalInst: do domination analysis

When multiple Given quantified constraints match a Wanted, and there is
a quantified constraint that dominates all others, we now pick it
to solve the Wanted.

See Note [Use only the best matching quantified constraint].

For example:

  [G] d1: forall a b. ( Eq a, Num b, C a b  ) => D a b
  [G] d2: forall a  .                C a Int  => D a Int
  [W] {w}: D a Int

When solving the Wanted, we find that both Givens match, but we pick
the second, because it has a weaker precondition, C a Int, compared
to (Eq a, Num Int, C a Int). We thus say that d2 dominates d1;
see Note [When does a quantified instance dominate another?].

This domination test is done purely in terms of superclass expansion,
in the function GHC.Tc.Solver.Interact.impliedBySCs. We don't attempt
to do a full round of constraint solving; this simple check suffices
for now.

Fixes #22216 and #22223

- - - - -
2a53ac18 by Simon Peyton Jones at 2022-09-28T17:49:09-04:00
Improve aggressive specialisation

This patch fixes #21286, by not unboxing dictionaries in
worker/wrapper (ever). The main payload is tiny:

* In `GHC.Core.Opt.DmdAnal.finaliseArgBoxities`, do not unbox
  dictionaries in `get_dmd`.  See Note [Do not unbox class dictionaries]
  in that module

* I also found that imported wrappers were being fruitlessly
  specialised, so I fixed that too, in canSpecImport.
  See Note [Specialising imported functions] point (2).

In doing due diligence in the testsuite I fixed a number of
other things:

* Improve Note [Specialising unfoldings] in GHC.Core.Unfold.Make,
  and Note [Inline specialisations] in GHC.Core.Opt.Specialise,
  and remove duplication between the two. The new Note describes
  how we specialise functions with an INLINABLE pragma.

  And simplify the defn of `spec_unf` in `GHC.Core.Opt.Specialise.specCalls`.

* Improve Note [Worker/wrapper for INLINABLE functions] in
  GHC.Core.Opt.WorkWrap.

  And (critially) make an actual change which is to propagate the
  user-written pragma from the original function to the wrapper; see
  `mkStrWrapperInlinePrag`.

* Write new Note [Specialising imported functions] in
  GHC.Core.Opt.Specialise

All this has a big effect on some compile times. This is
compiler/perf, showing only changes over 1%:

Metrics: compile_time/bytes allocated
-------------------------------------
                LargeRecord(normal)  -50.2% GOOD
           ManyConstructors(normal)   +1.0%
MultiLayerModulesTH_OneShot(normal)   +2.6%
                  PmSeriesG(normal)   -1.1%
                     T10547(normal)   -1.2%
                     T11195(normal)   -1.2%
                     T11276(normal)   -1.0%
                    T11303b(normal)   -1.6%
                     T11545(normal)   -1.4%
                     T11822(normal)   -1.3%
                     T12150(optasm)   -1.0%
                     T12234(optasm)   -1.2%
                     T13056(optasm)   -9.3% GOOD
                     T13253(normal)   -3.8% GOOD
                     T15164(normal)   -3.6% GOOD
                     T16190(normal)   -2.1%
                     T16577(normal)   -2.8% GOOD
                     T16875(normal)   -1.6%
                     T17836(normal)   +2.2%
                    T17977b(normal)   -1.0%
                     T18223(normal)  -33.3% GOOD
                     T18282(normal)   -3.4% GOOD
                     T18304(normal)   -1.4%
                    T18698a(normal)   -1.4% GOOD
                    T18698b(normal)   -1.3% GOOD
                     T19695(normal)   -2.5% GOOD
                      T5837(normal)   -2.3%
                      T9630(normal)  -33.0% GOOD
                      WWRec(normal)   -9.7% GOOD
             hard_hole_fits(normal)   -2.1% GOOD
                     hie002(normal)   +1.6%

                          geo. mean   -2.2%
                          minimum    -50.2%
                          maximum     +2.6%

I diligently investigated some of the big drops.

* Caused by not doing w/w for dictionaries:
    T13056, T15164, WWRec, T18223

* Caused by not fruitlessly specialising wrappers
    LargeRecord, T9630

For runtimes, here is perf/should+_run:

Metrics: runtime/bytes allocated
--------------------------------
               T12990(normal)   -3.8%
                T5205(normal)   -1.3%
                T9203(normal)  -10.7% GOOD
        haddock.Cabal(normal)   +0.1%
         haddock.base(normal)   -1.1%
     haddock.compiler(normal)   -0.3%
        lazy-bs-alloc(normal)   -0.2%
------------------------------------------
                    geo. mean   -0.3%
                    minimum    -10.7%
                    maximum     +0.1%

I did not investigate exactly what happens in T9203.

Nofib is a wash:

+-------------------------------++--+-----------+-----------+
|                               ||  | tsv (rel) | std. err. |
+===============================++==+===========+===========+
|                     real/anna ||  |    -0.13% |      0.0% |
|                      real/fem ||  |    +0.13% |      0.0% |
|                   real/fulsom ||  |    -0.16% |      0.0% |
|                     real/lift ||  |    -1.55% |      0.0% |
|                  real/reptile ||  |    -0.11% |      0.0% |
|                  real/smallpt ||  |    +0.51% |      0.0% |
|          spectral/constraints ||  |    +0.20% |      0.0% |
|               spectral/dom-lt ||  |    +1.80% |      0.0% |
|               spectral/expert ||  |    +0.33% |      0.0% |
+===============================++==+===========+===========+
|                     geom mean ||  |           |           |
+-------------------------------++--+-----------+-----------+

I spent quite some time investigating dom-lt, but it's pretty
complicated.  See my note on !7847.  Conclusion: it's just a delicate
inlining interaction, and we have plenty of those.

Metric Decrease:
    LargeRecord
    T13056
    T13253
    T15164
    T16577
    T18223
    T18282
    T18698a
    T18698b
    T19695
    T9630
    WWRec
    hard_hole_fits
    T9203

- - - - -
addeefc0 by Simon Peyton Jones at 2022-09-28T17:49:09-04:00
Refactor UnfoldingSource and IfaceUnfolding

I finally got tired of the way that IfaceUnfolding reflected
a previous structure of unfoldings, not the current one. This
MR refactors UnfoldingSource and IfaceUnfolding to be simpler
and more consistent.

It's largely just a refactor, but in UnfoldingSource (which moves
to GHC.Types.Basic, since it is now used in IfaceSyn too), I
distinguish between /user-specified/ and /system-generated/ stable
unfoldings.

    data UnfoldingSource
      = VanillaSrc
      | StableUserSrc   -- From a user-specified pragma
      | StableSystemSrc -- From a system-generated unfolding
      | CompulsorySrc

This has a minor effect in CSE (see the use of isisStableUserUnfolding
in GHC.Core.Opt.CSE), which I tripped over when working on
specialisation, but it seems like a Good Thing to know anyway.

- - - - -
7be6f9a4 by Simon Peyton Jones at 2022-09-28T17:49:09-04:00
INLINE/INLINEABLE pragmas in Foreign.Marshal.Array

Foreign.Marshal.Array contains many small functions, all of which are
overloaded, and which are critical for performance. Yet none of them
had pragmas, so it was a fluke whether or not they got inlined.

This patch makes them all either INLINE (small ones) or
INLINEABLE and hence specialisable (larger ones).

See Note [Specialising array operations] in that module.

- - - - -
b0c89dfa by Jade Lovelace at 2022-09-28T17:49:49-04:00
Export OnOff from GHC.Driver.Session

I was working on fixing an issue where HLS was trying to pass its
DynFlags to HLint, but didn't pass any of the disabled language
extensions, which HLint would then assume are on because of their
default values.

Currently it's not possible to get any of the "No" flags because the
`DynFlags.extensions` field can't really be used since it is [OnOff
Extension] and OnOff is not exported.

So let's export it.

- - - - -
2f050687 by Bodigrim at 2022-09-28T17:50:28-04:00
Avoid Data.List.group; prefer Data.List.NonEmpty.group

This allows to avoid further partiality, e. g., map head . group is
replaced by map NE.head . NE.group, and there are less panic calls.

- - - - -
bc0020fa by M Farkas-Dyck at 2022-09-28T22:51:59-04:00
Clean up `findWiredInUnit`. In particular, avoid `head`.

- - - - -
6a2eec98 by Bodigrim at 2022-09-28T22:52:38-04:00
Eliminate headFS, use unconsFS instead

A small step towards #22185 to avoid partial functions + safe implementation
of `startsWithUnderscore`.

- - - - -
5a535172 by Sebastian Graf at 2022-09-29T17:04:20+02:00
Demand: Format Call SubDemands `Cn(sd)` as `C(n,sd)` (#22231)

Justification in #22231. Short form: In a demand like `1C1(C1(L))`
it was too easy to confuse which `1` belongs to which `C`. Now
that should be more obvious.

Fixes #22231

- - - - -
ea0083bf by Bryan Richter at 2022-09-29T15:48:38-04:00
Revert "ci: enable parallel compression for xz"

Combined wxth XZ_OPT=9, this blew the memory capacity of CI runners.

This reverts commit a5f9c35f5831ef5108e87813a96eac62803852ab.

- - - - -
f5e8f493 by Sebastian Graf at 2022-09-30T18:42:13+02:00
Boxity: Don't update Boxity unless worker/wrapper follows (#21754)

A small refactoring in our Core Opt pipeline and some new functions for
transfering argument boxities from one signature to another to facilitate
`Note [Don't change boxity without worker/wrapper]`.

Fixes #21754.

- - - - -
4baf7b1c by M Farkas-Dyck at 2022-09-30T17:45:47-04:00
Scrub various partiality involving empty lists.

Avoids some uses of `head` and `tail`, and some panics when an argument is null.

- - - - -
95ead839 by Alexis King at 2022-10-01T00:37:43-04:00
Fix a bug in continuation capture across multiple stack chunks

- - - - -
22096652 by Bodigrim at 2022-10-01T00:38:22-04:00
Enforce internal invariant of OrdList and fix bugs in viewCons / viewSnoc

`viewCons` used to ignore `Many` constructor completely, returning `VNothing`.
`viewSnoc` violated internal invariant of `Many` being a non-empty list.

- - - - -
48ab9ca5 by Nicolas Trangez at 2022-10-04T20:34:10-04:00
chore: extend `.editorconfig` for C files

- - - - -
b8df5c72 by Brandon Chinn at 2022-10-04T20:34:46-04:00
Fix docs for pattern synonyms
- - - - -
463ffe02 by Oleg Grenrus at 2022-10-04T20:35:24-04:00
Use sameByteArray# in sameByteArray

- - - - -
fbe1e86e by Pierre Le Marre at 2022-10-05T15:58:43+02:00
Minor fixes following Unicode 15.0.0 update

- Fix changelog for Unicode 15.0.0
- Fix the checksums of the downloaded Unicode files, in base's tool: "ucd2haskell".

- - - - -
8a31d02e by Cheng Shao at 2022-10-05T20:40:41-04:00
rts: don't enforce aligned((8)) on 32-bit targets

We simply need to align to the word size for pointer tagging to work. On
32-bit targets, aligned((8)) is wasteful.

- - - - -
532de368 by Ryan Scott at 2022-10-06T07:45:46-04:00
Export symbolSing, SSymbol, and friends (CLC#85)

This implements this Core Libraries Proposal:
https://github.com/haskell/core-libraries-committee/issues/85

In particular, it:

1. Exposes the `symbolSing` method of `KnownSymbol`,
2. Exports the abstract `SSymbol` type used in `symbolSing`, and
3. Defines an API for interacting with `SSymbol`.

This also makes corresponding changes for `natSing`/`KnownNat`/`SNat` and
`charSing`/`KnownChar`/`SChar`. This fixes #15183 and addresses part (2)
of #21568.

- - - - -
d83a92e6 by sheaf at 2022-10-07T07:36:30-04:00
Remove mention of make from README.md

- - - - -
945e8e49 by Bodigrim at 2022-10-10T17:13:31-04:00
Add a newline before since pragma in Data.Array.Byte

- - - - -
44fcdb04 by Vladislav Zavialov at 2022-10-10T17:14:06-04:00
Parser/PostProcess: rename failOp* functions

There are three functions named failOp* in the parser:
	failOpNotEnabledImportQualifiedPost
	failOpImportQualifiedTwice
	failOpFewArgs
Only the last one has anything to do with operators. The other two
were named this way either by mistake or due to a misunderstanding of
what "op" stands for. This small patch corrects this.

- - - - -
96d32ff2 by Simon Peyton Jones at 2022-10-10T22:30:21+01:00
Make rewrite rules "win" over inlining

If a rewrite rule and a rewrite rule compete in the simplifier, this
patch makes sure that the rewrite rule "win".  That is, in general
a bit fragile, but it's a huge help when making specialisation work
reliably, as #21851 and #22097 showed.

The change is fairly straightforwad, and documented in
   Note [Rewrite rules and inlining]
in GHC.Core.Opt.Simplify.Iteration.

Compile-times change, up and down a bit -- in some cases because
we get better specialisation.  But the payoff (more reliable
specialisation) is large.

Metrics: compile_time/bytes allocated
-----------------------------------------------
    T10421(normal)   +3.7% BAD
   T10421a(normal)   +5.5%
    T13253(normal)   +1.3%
      T14052(ghci)   +1.8%
    T15304(normal)   -1.4%
    T16577(normal)   +3.1% BAD
    T17516(normal)   +2.3%
    T17836(normal)   -1.9%
    T18223(normal)   -1.8%
     T8095(normal)   -1.3%
     T9961(normal)   +2.5% BAD

         geo. mean   +0.0%
         minimum     -1.9%
         maximum     +5.5%

Nofib results are (bytes allocated)

+-------------------------------++----------+
|                               ||tsv (rel) |
+===============================++==========+
|           imaginary/paraffins ||   +0.27% |
|                imaginary/rfib ||   -0.04% |
|                     real/anna ||   +0.02% |
|                      real/fem ||   -0.04% |
|                    real/fluid ||   +1.68% |
|                   real/gamteb ||   -0.34% |
|                       real/gg ||   +1.54% |
|                   real/hidden ||   -0.01% |
|                      real/hpg ||   -0.03% |
|                    real/infer ||   -0.03% |
|                   real/prolog ||   +0.02% |
|                  real/veritas ||   -0.47% |
|       shootout/fannkuch-redux ||   -0.03% |
|         shootout/k-nucleotide ||   -0.02% |
|               shootout/n-body ||   -0.06% |
|        shootout/spectral-norm ||   -0.01% |
|         spectral/cryptarithm2 ||   +1.25% |
|             spectral/fibheaps ||  +18.33% |
|           spectral/last-piece ||   -0.34% |
+===============================++==========+
|                     geom mean ||   +0.17% |

There are extensive notes in !8897 about the regressions.
Briefly

* fibheaps: there was a very delicately balanced inlining that
  tipped over the wrong way after this change.

* cryptarithm2 and paraffins are caused by #22274, which is
  a separate issue really.  (I.e. the right fix is *not* to
  make inlining "win" over rules.)

So I'm accepting these changes

Metric Increase:
    T10421
    T16577
    T9961

- - - - -
ed4b5885 by Joachim Breitner at 2022-10-10T23:16:11-04:00
Utils.JSON: do not escapeJsonString in ToJson String instance

as `escapeJsonString` is used in `renderJSON`, so the `JSString`
constructor is meant to carry the unescaped string.

- - - - -
fbb88740 by Matthew Pickering at 2022-10-11T12:48:45-04:00
Tidy implicit binds

We want to put implicit binds into fat interface files, so the easiest
thing to do seems to be to treat them uniformly with other binders.

- - - - -
e058b138 by Matthew Pickering at 2022-10-11T12:48:45-04:00
Interface Files with Core Definitions

This commit adds three new flags

* -fwrite-if-simplified-core: Writes the whole core program into an interface
  file
* -fbyte-code-and-object-code: Generate both byte code and object code
  when compiling a file
* -fprefer-byte-code: Prefer to use byte-code if it's available when
  running TH splices.

The goal for including the core bindings in an interface file is to be able to restart the compiler pipeline
at the point just after simplification and before code generation. Once compilation is
restarted then code can be created for the byte code backend.
This can significantly speed up
start-times for projects in GHCi. HLS already implements its own version of these extended interface
files for this reason.

Preferring to use byte-code means that we can avoid some potentially
expensive code generation steps (see #21700)

* Producing object code is much slower than producing bytecode, and normally you
  need to compile with `-dynamic-too` to produce code in the static and dynamic way, the
  dynamic way just for Template Haskell execution when using a dynamically linked compiler.

* Linking many large object files, which happens once per splice, can be quite
  expensive compared to linking bytecode.

And you can get GHC to compile the necessary byte code so
`-fprefer-byte-code` has access to it by using
`-fbyte-code-and-object-code`.

Fixes #21067

- - - - -
9789ea8e by Matthew Pickering at 2022-10-11T12:48:45-04:00
Teach -fno-code about -fprefer-byte-code

This patch teachs the code generation logic of -fno-code about
-fprefer-byte-code, so that if we need to generate code for a module
which prefers byte code, then we generate byte code rather than object
code.

We keep track separately which modules need object code and which byte
code and then enable the relevant code generation for each. Typically
the option will be enabled globally so one of these sets should be empty
and we will just turn on byte code or object code generation.

We also fix the bug where we would generate code for a module which
enables Template Haskell despite the fact it was unecessary.

Fixes #22016

- - - - -
caced757 by Simon Peyton Jones at 2022-10-11T12:49:21-04:00
Don't keep exit join points so much

We were religiously keeping exit join points throughout, which
had some bad effects (#21148, #22084).

This MR does two things:

* Arranges that exit join points are inhibited from inlining
  only in /one/ Simplifier pass (right after Exitification).

  See Note [Be selective about not-inlining exit join points]
  in GHC.Core.Opt.Exitify

  It's not a big deal, but it shaves 0.1% off compile times.

* Inline used-once non-recursive join points very aggressively
  Given join j x = rhs in
        joinrec k y = ....j x....

  where this is the only occurrence of `j`, we want to inline `j`.
  (Unless sm_keep_exits is on.)

  See Note [Inline used-once non-recursive join points] in
  GHC.Core.Opt.Simplify.Utils

  This is just a tidy-up really.  It doesn't change allocation, but
  getting rid of a binding is always good.

Very effect on nofib -- some up and down.

- - - - -
284cf387 by Simon Peyton Jones at 2022-10-11T12:49:21-04:00
Make SpecConstr bale out less often

When doing performance debugging on #22084 / !8901, I found that the
algorithm in SpecConstr.decreaseSpecCount was so aggressive that if
there were /more/ specialisations available for an outer function,
that could more or less kill off specialisation for an /inner/
function.  (An example was in nofib/spectral/fibheaps.)

This patch makes it a bit more aggressive, by dividing by 2, rather
than by the number of outer specialisations.

This makes the program bigger, temporarily:

   T19695(normal) ghc/alloc   +11.3% BAD

because we get more specialisation.  But lots of other programs
compile a bit faster and the geometric mean in perf/compiler
is 0.0%.

Metric Increase:
    T19695

- - - - -
66af1399 by Cheng Shao at 2022-10-11T12:49:59-04:00
CmmToC: emit explicit tail calls when the C compiler supports it

Clang 13+ supports annotating a return statement using the musttail
attribute, which guarantees that it lowers to a tail call if compilation
succeeds.

This patch takes advantage of that feature for the unregisterised code
generator. The configure script tests availability of the musttail
attribute, if it's available, the Cmm tail calls will become C tail
calls that avoids the mini interpreter trampoline overhead. Nothing is
affected if the musttail attribute is not supported.

Clang documentation:
https://clang.llvm.org/docs/AttributeReference.html#musttail

- - - - -
7f0decd5 by Matthew Pickering at 2022-10-11T12:50:40-04:00
Don't include BufPos in interface files

Ticket #22162 pointed out that the build directory was leaking into the
ABI hash of a module because the BufPos depended on the location of the
build tree.

BufPos is only used in GHC.Parser.PostProcess.Haddock, and the
information doesn't need to be propagated outside the context of a
module.

Fixes #22162

- - - - -
dce9f320 by Cheng Shao at 2022-10-11T12:51:19-04:00
CLabel: fix isInfoTableLabel

isInfoTableLabel does not take Cmm info table into account. This patch is required for data section layout of wasm32 NCG to work.

- - - - -
da679f2e by Bodigrim at 2022-10-11T18:02:59-04:00
Extend documentation for Data.List, mostly wrt infinite lists

- - - - -
9c099387 by jwaldmann at 2022-10-11T18:02:59-04:00
Expand comment for Data.List.permutations
- - - - -
d3863cb7 by Bodigrim at 2022-10-11T18:03:37-04:00
ByteArray# is unlifted, not unboxed

- - - - -
f6260e8b by Ben Gamari at 2022-10-11T23:45:10-04:00
rts: Add missing declaration of stg_noDuplicate

- - - - -
69ccec2c by Ben Gamari at 2022-10-11T23:45:10-04:00
base: Move CString, CStringLen to GHC.Foreign

- - - - -
f6e8feb4 by Ben Gamari at 2022-10-11T23:45:10-04:00
base: Move IPE helpers to GHC.InfoProv

- - - - -
866c736e by Ben Gamari at 2022-10-11T23:45:10-04:00
rts: Refactor IPE tracing support

- - - - -
6b0d2022 by Ben Gamari at 2022-10-11T23:45:10-04:00
Refactor IPE initialization

Here we refactor the representation of info table provenance information
in object code to significantly reduce its size and link-time impact.
Specifically, we deduplicate strings and represent them as 32-bit
offsets into a common string table.

In addition, we rework the registration logic to eliminate allocation
from the registration path, which is run from a static initializer where
things like allocation are technically undefined behavior (although it
did previously seem to work). For similar reasons we eliminate lock
usage from registration path, instead relying on atomic CAS.

Closes #22077.

- - - - -
9b572d54 by Ben Gamari at 2022-10-11T23:45:10-04:00
Separate IPE source file from span

The source file name can very often be shared across many IPE entries
whereas the source coordinates are generally unique. Separate the two to
exploit sharing of the former.

- - - - -
27978ceb by Krzysztof Gogolewski at 2022-10-11T23:45:46-04:00
Make Cmm Lint messages use dump style

Lint errors indicate an internal error in GHC, so it makes sense to use
it instead of the user style. This is consistent with Core Lint and STG Lint:

https://gitlab.haskell.org/ghc/ghc/-/blob/22096652/compiler/GHC/Core/Lint.hs#L429

https://gitlab.haskell.org/ghc/ghc/-/blob/22096652/compiler/GHC/Stg/Lint.hs#L144

Fixes #22218.

- - - - -
64a390d9 by Bryan Richter at 2022-10-12T09:52:51+03:00
Mark T7919 as fragile

On x86_64-linux, T7919 timed out ~30 times during July 2022.

And again ~30 times in September 2022.

- - - - -
481467a5 by Ben Gamari at 2022-10-12T08:08:37-04:00
rts: Don't hint inlining of appendToRunQueue

These hints have resulted in compile-time warnings due to failed
inlinings for quite some time. Moreover, it's quite unlikely that
inlining them is all that beneficial given that they are rather sizeable
functions.

Resolves #22280.

- - - - -
81915089 by Curran McConnell at 2022-10-12T16:32:26-04:00
remove name shadowing

- - - - -
626652f7 by Tamar Christina at 2022-10-12T16:33:13-04:00
winio: do not re-translate input when handle is uncooked

- - - - -
5172789a by Charles Taylor at 2022-10-12T16:33:57-04:00
Unrestricted OverloadedLabels (#11671)

Implements GHC proposal:
https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0170-unrestricted-overloadedlabels.rst

- - - - -
ce293908 by Andreas Klebinger at 2022-10-13T05:58:19-04:00
Add a perf test for the generics code pattern from #21839.

This code showed a strong shift between compile time (got worse) and
run time (got a lot better) recently which is perfectly acceptable.

However it wasn't clear why the compile time regression was happening
initially so I'm adding this test to make it easier to track such changes
in the future.

- - - - -
78ab7afe by Ben Gamari at 2022-10-13T05:58:56-04:00
rts/linker: Consolidate initializer/finalizer handling

Here we extend our treatment of initializer/finalizer priorities to
include ELF and in so doing refactor things to share the implementation
with PEi386. As well, I fix a subtle misconception of the ordering
behavior for `.ctors`.

Fixes #21847.

- - - - -
44692713 by Ben Gamari at 2022-10-13T05:58:56-04:00
rts/linker: Add support for .fini sections

- - - - -
beebf546 by Simon Hengel at 2022-10-13T05:59:37-04:00
Update phases.rst

(the name of the original source file is $1, not $2)
- - - - -
eda6c05e by Finley McIlwaine at 2022-10-13T06:00:17-04:00
Clearer error msg for newtype GADTs with defaulted kind

When a newtype introduces GADT eq_specs due to a defaulted
RuntimeRep, we detect this and print the error message with
explicit kinds.

This also refactors newtype type checking to use the new
diagnostic infra.

Fixes #21447

- - - - -
43ab435a by Pierre Le Marre at 2022-10-14T07:45:43-04:00
Add standard Unicode case predicates isUpperCase and isLowerCase.

These predicates use the standard Unicode case properties and are more intuitive than isUpper and isLower.

Approved by CLC in https://github.com/haskell/core-libraries-committee/issues/90#issuecomment-1276649403.

Fixes #14589

- - - - -
aec5a443 by Bodigrim at 2022-10-14T07:46:21-04:00
Add type signatures in where-clause of Data.List.permutations

The type of interleave' is very much revealing, otherwise it's extremely tough to decipher.

- - - - -
ee0deb80 by Ben Gamari at 2022-10-14T18:29:20-04:00
rts: Use pthread_setname_np correctly on Darwin

As noted in #22206, pthread_setname_np on Darwin only supports
setting the name of the calling thread. Consequently we must introduce
a trampoline which first sets the thread name before entering the thread
entrypoint.
- - - - -
8eff62a4 by Ben Gamari at 2022-10-14T18:29:57-04:00
testsuite: Add test for #22282

This will complement mpickering's more general port of foundation's
numerical testsuite, providing a test for the specific case found
in #22282.

- - - - -
62a55001 by Ben Gamari at 2022-10-14T18:29:57-04:00
ncg/aarch64: Fix sub-word sign extension yet again

In adc7f108141a973b6dcb02a7836eed65d61230e8 we fixed a number of issues
to do with sign extension in the AArch64 NCG found by ghc/test-primops>.
However, this patch made a critical error, assuming that getSomeReg
would allocate a fresh register for the result of its evaluation.
However, this is not the case as `getSomeReg (CmmReg r) == r`.
Consequently, any mutation of the register returned by `getSomeReg` may
have unwanted side-effects on other expressions also mentioning `r`. In
the fix listed above, this manifested as the registers containing the
operands of binary arithmetic operations being incorrectly
sign-extended. This resulted in #22282.

Sadly, the rather simple structure of the tests generated
by `test-primops` meant that this particular case was not exercised.
Even more surprisingly, none of our testsuite caught this case.

Here we fix this by ensuring that intermediate sign extension is
performed in a fresh register.

Fixes #22282.

- - - - -
54e41b16 by Teo Camarasu at 2022-10-15T18:09:24+01:00
rts: ensure we are below maxHeapSize after returning megablocks

When the heap is heavily block fragmented the live byte size might be
low while the memory usage is high. We want to ensure that heap overflow
triggers in these cases.

We do so by checking that we can return enough megablocks to
under maxHeapSize at the end of GC.

- - - - -
29bb90db by Teo Camarasu at 2022-10-15T18:09:24+01:00
rts: trigger a major collection if megablock usage exceeds maxHeapSize

When the heap is suffering from block fragmentation, live bytes might be
low while megablock usage is high.

If megablock usage exceeds maxHeapSize, we want to trigger a major GC to
try to recover some memory otherwise we will die from a heapOverflow at
the end of the GC.

Fixes #21927

- - - - -
4a4641ca by Teo Camarasu at 2022-10-15T18:11:29+01:00
Add realease note for #21927

- - - - -
c1e5719a by Sebastian Graf at 2022-10-17T11:58:46-04:00
DmdAnal: Look through unfoldings of DataCon wrappers (#22241)

Previously, the demand signature we computed upfront for a DataCon wrapper

lacked boxity information and was much less precise than the demand transformer

for the DataCon worker.

In this patch we adopt the solution to look through unfoldings of DataCon

wrappers during Demand Analysis, but still attach a demand signature for other

passes such as the Simplifier.

See `Note [DmdAnal for DataCon wrappers]` for more details.

Fixes #22241.

- - - - -
8c72411d by Gergo ERDI at 2022-10-17T19:20:04-04:00
Add `Enum (Down a)` instance that swaps `succ` and `pred`

See https://github.com/haskell/core-libraries-committee/issues/51 for
discussion. The key points driving the implementation are the following
two ideas:

* For the `Int` type, `comparing (complement @Int)` behaves exactly as
  an order-swapping `compare @Int`.
* `enumFrom @(Down a)` can be implemented in terms of `enumFromThen @a`,
  if only the corner case of starting at the very end is handled specially

- - - - -
d80ad2f4 by Alan Zimmerman at 2022-10-17T19:20:40-04:00
Update the check-exact infrastructure to match ghc-exactprint

GHC tests the exact print annotations using the contents of
utils/check-exact.

The same functionality is provided via
https://github.com/alanz/ghc-exactprint

The latter was updated to ensure it works with all of the files on
hackage when 9.2 was released, as well as updated to ensure users of
the library could work properly (apply-refact, retrie, etc).

This commit brings the changes from ghc-exactprint into
GHC/utils/check-exact, adapting for the changes to master.

Once it lands, it will form the basis for the 9.4 version of
ghc-exactprint.

See also discussion around this process at #21355

- - - - -
08ab5419 by Andreas Klebinger at 2022-10-17T19:21:15-04:00
Avoid allocating intermediate lists for non recursive bindings.

We do so by having an explicit folding function that doesn't need to
allocate intermediate lists first.

Fixes #22196

- - - - -
ff6275ef by Andreas Klebinger at 2022-10-17T19:21:52-04:00
Testsuite: Add a new tables_next_to_code predicate.

And use it to avoid T21710a failing on non-tntc archs.

Fixes #22169

- - - - -
abb82f38 by Eric Lindblad at 2022-10-17T19:22:33-04:00
example rewrite
- - - - -
39beb801 by Eric Lindblad at 2022-10-17T19:22:33-04:00
remove redirect
- - - - -
0d9fb651 by Eric Lindblad at 2022-10-17T19:22:33-04:00
use heredoc
- - - - -
0fa2d185 by Matthew Pickering at 2022-10-17T19:23:10-04:00
testsuite: Fix typo when setting llvm_ways

Since 2014 llvm_ways has been set to [] so none of the tests which use
only_ways(llvm_ways) have worked as expected.

Hopefully the tests still pass with this typo fix!

- - - - -
ced664a2 by Krzysztof Gogolewski at 2022-10-17T19:23:10-04:00
Fix T15155l not getting -fllvm

- - - - -
0ac60423 by Andreas Klebinger at 2022-10-18T03:34:47-04:00
Fix GHCis interaction with tag inference.

I had assumed that wrappers were not inlined in interactive mode.
Meaning we would always execute the compiled wrapper which properly
takes care of upholding the strict field invariant.
This turned out to be wrong. So instead we now run tag inference even
when we generate bytecode. In that case only for correctness not
performance reasons although it will be still beneficial for runtime
in some cases.

I further fixed a bug where GHCi didn't tag nullary constructors
properly when used as arguments. Which caused segfaults when calling
into compiled functions which expect the strict field invariant to
be upheld.

Fixes #22042 and #21083

-------------------------
Metric Increase:
    T4801

Metric Decrease:
    T13035
-------------------------

- - - - -
9ecd1ac0 by M Farkas-Dyck at 2022-10-18T03:35:38-04:00
Make `Functor` a superclass of `TrieMap`, which lets us derive the `map` functions.

- - - - -
f60244d7 by Ben Gamari at 2022-10-18T03:36:15-04:00
configure: Bump minimum bootstrap GHC version

Fixes #22245

- - - - -
ba4bd4a4 by Matthew Pickering at 2022-10-18T03:36:55-04:00
Build System: Remove out-of-date comment about make build system

Both make and hadrian interleave compilation of modules of different
modules and don't respect the package boundaries. Therefore I just
remove this comment which points out this "difference".

Fixes #22253

- - - - -
871419f5 by Ben Gamari at 2022-10-20T11:05:56-04:00
gen-dll: Drop it

Currently it is only used by the make build system, which is soon to be
retired, and it has not built since 41cf758b. We may need to reintroduce
it when dynamic-linking support is introduced on Windows, but we will
cross that bridge once we get there.

Fixes #21753.

- - - - -


30 changed files:

- − .appveyor.sh
- .editorconfig
- .gitignore
- .gitlab-ci.yml
- .gitlab/ci.sh
- .gitlab/darwin/toolchain.nix
- .gitlab/gen_ci.hs
- .gitlab/jobs.yaml
- .gitlab/upload_ghc_libs.py
- CODEOWNERS
- − MAKEHELP.md
- − Makefile
- README.md
- − appveyor.yml
- − bindisttest/ghc.mk
- boot
- compiler/CodeGen.Platform.h
- compiler/GHC.hs
- compiler/GHC/Builtin/Names.hs
- compiler/GHC/Builtin/Names/TH.hs
- compiler/GHC/Builtin/PrimOps.hs
- compiler/GHC/Builtin/Types.hs
- compiler/GHC/Builtin/Types/Prim.hs
- compiler/GHC/Builtin/Uniques.hs
- compiler/GHC/Builtin/primops.txt.pp
- compiler/GHC/ByteCode/Instr.hs
- compiler/GHC/ByteCode/Linker.hs
- compiler/GHC/Cmm.hs
- compiler/GHC/Cmm/CLabel.hs
- compiler/GHC/Cmm/CallConv.hs


The diff was not included because it is too large.


View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ca8eeedb5c9d1acf1e1ea0012af76941a9cf43be...871419f5a79273de5ea2934942263a329bbdc27c

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ca8eeedb5c9d1acf1e1ea0012af76941a9cf43be...871419f5a79273de5ea2934942263a329bbdc27c
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20221020/b89f3a23/attachment-0001.html>


More information about the ghc-commits mailing list