[Git][ghc/ghc][wip/clear-bdescr-free] 939 commits: rts: Specialize hashing at call site rather than in struct.

Ben Gamari gitlab at gitlab.haskell.org
Tue Jun 23 22:43:03 UTC 2020



Ben Gamari pushed to branch wip/clear-bdescr-free at Glasgow Haskell Compiler / GHC


Commits:
f80c4a66 by Crazycolorz5 at 2019-12-11T14:12:17-05:00
rts: Specialize hashing at call site rather than in struct.

Separate word and string hash tables on the type level, and do not store
the hashing function.  Thus when a different hash function is desire it
is provided upon accessing the table. This is worst case the same as
before the change, and in the majority of cases is better. Also mark the
functions for aggressive inlining to improve performance.  {F1686506}

Reviewers: bgamari, erikd, simonmar

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #13165

Differential Revision: https://phabricator.haskell.org/D4889

- - - - -
2d1b9619 by Richard Eisenberg at 2019-12-11T14:12:55-05:00
Warn on inferred polymorphic recursion

Silly users sometimes try to use visible dependent quantification
and polymorphic recursion without a CUSK or SAK. This causes
unexpected errors. So we now adjust expectations with a bit
of helpful messaging.

Closes #17541 and closes #17131.

test cases: dependent/should_fail/T{17541{,b},17131}

- - - - -
4dde485e by Oleg Grenrus at 2019-12-12T02:24:46-05:00
Add --show-unit-ids flag to ghc-pkg

I only added it into --simple-output and ghc-pkg check output;
there are probably other places where it can be adopted.

- - - - -
e6e1ec08 by Ben Gamari at 2019-12-12T02:25:33-05:00
testsuite: Simplify and clarify performance test baseline search

The previous implementation was extremely complicated, seemingly to
allow the local and CI namespaces to be searched incrementally. However,
it's quite unclear why this is needed and moreover the implementation
seems to have had quadratic runtime cost in the search depth(!).

- - - - -
29c4609c by Ben Gamari at 2019-12-12T02:26:19-05:00
testsuite: Add test for #17549

- - - - -
9f0ee253 by Ben Gamari at 2019-12-12T02:26:56-05:00
gitlab-ci: Move -dwarf and -debug jobs to full-build stage

This sacrifices some precision in favor of improving parallelism.

- - - - -
7179b968 by Ben Gamari at 2019-12-12T02:27:34-05:00
Revert "rts: Drop redundant flags for libffi"

This seems to have regressed builds using `--with-system-libffi`
(#17520).

This reverts commit 3ce18700f80a12c48a029b49c6201ad2410071bb.

- - - - -
cc7d5650 by Oleg Grenrus at 2019-12-16T10:20:56+02:00
Having no shake upper bound is irresposible

Given that shake is far from "done" API wise,
and is central component to the build system.

- - - - -
9431f905 by Oleg Grenrus at 2019-12-16T10:55:50+02:00
Add index-state to hadrian/cabal.project

Then one is freer to omit upper bounds, as we won't pick
any new entries on Hackage while building hadrian itself.

- - - - -
3e17a866 by Krzysztof Gogolewski at 2019-12-16T19:31:44-05:00
Remove dataConSig

As suggested in #17291

- - - - -
75355fde by Krzysztof Gogolewski at 2019-12-16T19:31:44-05:00
Use "OrCoVar" functions less

As described in #17291, we'd like to separate coercions and expressions
in a more robust fashion.
This is a small step in this direction.

- `mkLocalId` now panicks on a covar.
  Calls where this was not the case were changed to `mkLocalIdOrCoVar`.
- Don't use "OrCoVar" functions in places where we know the type is
  not a coercion.

- - - - -
f9686e13 by Richard Eisenberg at 2019-12-16T19:32:21-05:00
Do more validity checks for quantified constraints

Close #17583.

Test case: typecheck/should_fail/T17563

- - - - -
af763765 by Ben Gamari at 2019-12-16T19:33:01-05:00
gitlab-ci: Fix Windows artifact collection

Variable interpolation in gitlab-ci.yml apparently doesn't work. Sigh.

- - - - -
e6d4b902 by Ben Gamari at 2019-12-16T19:33:01-05:00
gitlab-ci: Use xz --threads on Debian 10

- - - - -
8ba650e9 by Ben Gamari at 2019-12-16T19:33:01-05:00
gitlab-ci: Allow debian 8 build to fail

The python release shipped with deb8 (3.3) is too old for our testsuite
driver.

- - - - -
ac25a3f6 by Ben Gamari at 2019-12-16T19:33:01-05:00
gitlab-ci: Use xz --threads on Alpine

- - - - -
cc628088 by Ben Gamari at 2019-12-16T19:33:01-05:00
gitlab-ci: Another approach for xz detection

- - - - -
37d788ab by Ben Gamari at 2019-12-16T19:33:01-05:00
gitlab-ci: Re-add release-x86_64-deb9 job

Also eliminate some redundancy.

- - - - -
f8279138 by Ben Gamari at 2019-12-16T19:33:01-05:00
gitlab-ci: Drop redundant release-x86_64-linux-deb9 job

- - - - -
8148ff06 by Ben Gamari at 2019-12-17T07:24:40-05:00
testsuite: Mark cgrun057 as broken on ARMv7

Due to #17554. It's very surprising that this only occurs on ARMv7 but
this is the only place I've seen this failure thusfar.

- - - - -
85e5696d by Ben Gamari at 2019-12-17T07:24:40-05:00
testsuite: Mark prog001 as fragile on ARMv7

Due to #17555.

- - - - -
a5f0aab0 by Ben Gamari at 2019-12-17T07:24:40-05:00
testsuite: Mark T10272 as broken on ARMv7

Due to #17556.

- - - - -
1e6827c6 by Ben Gamari at 2019-12-17T07:24:40-05:00
testsuite: Mark T13825-debugger as broken on ARMv7

Due to #17557.

- - - - -
7cef0b7d by Ben Gamari at 2019-12-17T07:24:40-05:00
testsuite: Mark T14028 as broken on ARMv7

Due to #17558.

- - - - -
6ea4eb4b by Ben Gamari at 2019-12-17T07:24:40-05:00
testsuite: Make ghc_built_by_llvm check more precise

Previously it would hackily look at the flavour name to determine
whether LLVM was used to build stage2 ghc. However, this didn't work at
all with Hadrian and would miss cases like ARM where we use the LLVM
backend by default.

See #16087 for the motivation for why ghc_built_by_llvm is needed at
all. This should catch one of the ARMv7 failures described in #17555.

- - - - -
c3e82bf7 by Ben Gamari at 2019-12-17T07:24:40-05:00
testsuite: Mark T5435_* tests as broken on ARM

`T5435_v_asm_a`, `T5435_v_asm_b`, and `T5435_v_gcc` all fail on ARMv7.
See #17559.

- - - - -
eb2aa851 by Ben Gamari at 2019-12-17T07:24:40-05:00
gitlab-ci: Don't allow armv7 jobs to fail

- - - - -
efc92216 by Ben Gamari at 2019-12-17T07:24:40-05:00
Revert "testsuite: Mark cgrun057 as broken on ARMv7"

This reverts commit 6cfc47ec8a478e1751cb3e7338954da1853c3996.

- - - - -
1d2bb9eb by Ben Gamari at 2019-12-17T07:24:40-05:00
testsuite: Mark print002 as fragile on ARM

Due to #17557.

Also accepting spurious performance change.

Metric Decrease:
    T1969

- - - - -
41f4e4fb by Josh Meredith at 2019-12-17T07:25:17-05:00
Fix ambiguous occurence error when building Hadrian

- - - - -
4374983a by Josh Meredith at 2019-12-17T07:25:17-05:00
Rename SphinxMode constructors

- - - - -
a8f7ecd5 by Josh Meredith at 2019-12-17T07:25:17-05:00
Use *Mode suffix instead of *M

- - - - -
58655b9d by Sylvain Henry at 2019-12-18T13:43:37+01:00
Add GHC-API logging hooks

* Add 'dumpAction' hook to DynFlags.

It allows GHC API users to catch dumped intermediate codes and
information. The format of the dump (Core, Stg, raw text, etc.) is now
reported allowing easier automatic handling.

* Add 'traceAction' hook to DynFlags.

Some dumps go through the trace mechanism (for instance unfoldings that
have been considered for inlining). This is problematic because:
1) dumps aren't written into files even with -ddump-to-file on
2) dumps are written on stdout even with GHC API
3) in this specific case, dumping depends on unsafe globally stored
DynFlags which is bad for GHC API users

We introduce 'traceAction' hook which allows GHC API to catch those
traces and to avoid using globally stored DynFlags.

* Avoid dumping empty logs via dumpAction/traceAction (but still write
empty files to keep the existing behavior)

- - - - -
fad866e0 by Moritz Kiefer at 2019-12-19T11:15:39-05:00
Avoid race condition in hDuplicateTo

In our codebase we have some code along the lines of

```
newStdout <- hDuplicate stdout
stderr `hDuplicateTo` stdout
```

to avoid stray `putStrLn`s from corrupting a protocol (LSP) that is
run over stdout.

On CI we have seen a bunch of issues where `dup2` returned `EBUSY` so
this fails with `ResourceExhausted` in Haskell.

I’ve spent some time looking at the docs for `dup2` and the code in
`base` and afaict the following race condition is being triggered
here:

1. The user calls `hDuplicateTo stderr stdout`.
2. `hDuplicateTo` calls `hClose_help stdout_`, this closes the file
handle for stdout.
3. The file handle for stdout is now free, so another thread
allocating a file might get stdout.
4. If `dup2` is called while `stdout` (now pointing to something
else) is half-open, it returns EBUSY.

I think there might actually be an even worse case where `dup2` is run
after FD 1 is fully open again. In that case, you will end up not just
redirecting the original stdout to stderr but also the whatever
resulted in that file handle being allocated.

As far as I can tell, `dup2` takes care of closing the file handle
itself so there is no reason to do this in `hDuplicateTo`. So this PR
replaces the call to `hClose_help` by the only part of `hClose_help`
that we actually care about, namely, `flushWriteBuffer`.

I tested this on our codebase fairly extensively and haven’t been able
to reproduce the issue with this patch.

- - - - -
0c114c65 by Sylvain Henry at 2019-12-19T11:16:17-05:00
Handle large ARR_WORDS in heap census (fix #17572)

We can do a heap census with a non-profiling RTS. With a non-profiling
RTS we don't zero superfluous bytes of shrunk arrays hence a need to
handle the case specifically to avoid a crash.

Revert part of a586b33f8e8ad60b5c5ef3501c89e9b71794bbed

- - - - -
1a0d1a65 by John Ericson at 2019-12-20T10:50:22-05:00
Deduplicate copied monad failure handler code

- - - - -
70e56b27 by Ryan Scott at 2019-12-20T10:50:57-05:00
lookupBindGroupOcc: recommend names in the same namespace (#17593)

Previously, `lookupBindGroupOcc`'s error message would recommend all
similar names in scope, regardless of whether they were type
constructors, data constructors, or functions, leading to the
confusion witnessed in #17593. This is easily fixed by only
recommending names in the same namespace, using the
`nameSpacesRelated` function.

Fixes #17593.

- - - - -
3c12355e by Stefan Schulze Frielinghaus at 2019-12-24T01:03:44-05:00
Fix endian handling w.r.t. CPP macro WORDS_BIGENDIAN

Include header file `ghcautoconf.h` where the CPP macro
`WORDS_BIGENDIAN` is defined. This finally fixes #17337 (in conjunction
with commit 6c59cc71dc).

- - - - -
11f8eef5 by Stefan Schulze Frielinghaus at 2019-12-24T01:03:44-05:00
fixup! Fix endian handling w.r.t. CPP macro WORDS_BIGENDIAN

- - - - -
40327b03 by Sylvain Henry at 2019-12-24T01:04:24-05:00
Remove outdated comment

- - - - -
aeea92ef by Sylvain Henry at 2019-12-25T19:23:54-05:00
Switch to ReadTheDocs theme for the user-guide

- - - - -
26493eab by Gabor Greif at 2019-12-25T19:24:32-05:00
Fix copy-paste error in comment
- - - - -
776df719 by Gabor Greif at 2019-12-25T19:24:32-05:00
Fix comment about minimal gcc version

to be consistent what FP_GCC_VERSION requires
- - - - -
3b17114d by Ömer Sinan Ağacan at 2019-12-26T14:09:11-05:00
Minor refactor in ghc.cabal.in:

- Remove outdated comments
- Move cutils.c from parser to cbits
- Remove unused cutils.h

- - - - -
334290b6 by Ryan Scott at 2019-12-26T14:09:48-05:00
Replace panic/notHandled with noExtCon in DsMeta

There are many spots in `DsMeta` where `panic` or `notHandled` is
used after pattern-matching on a TTG extension constructor. This is
overkill, however, as using `noExtCon` would work just as well. This
patch switches out these panics for `noExtCon`.

- - - - -
68252aa3 by Ben Gamari at 2019-12-27T15:11:38-05:00
testsuite: Skip T17499 when built against integer-simple

Since it routinely times out in CI.

- - - - -
0c51aeeb by Gabor Greif at 2019-12-27T15:12:17-05:00
suppress popup dialog about missing Xcode at configure

tested with `bash` and `zsh`.

- - - - -
8d76bcc2 by Gabor Greif at 2019-12-27T15:12:17-05:00
while at it rename XCode to the official Xcode

- - - - -
47a68205 by Ben Gamari at 2019-12-27T15:12:55-05:00
testsuite: Mark cgrun057 as fragile on ARM

As reported in #17554. Only marking on ARM for now although there is
evidence to suggest that the issue may occur on other platforms as well.

- - - - -
d03dec8f by Gabor Greif at 2019-12-27T15:13:32-05:00
use shell variable CcLlvmBackend for test

Previously we used `AC_DEFINE`d variable `CC_LLVM_BACKEND` which has an empty shell expansion.
- - - - -
2528e684 by Ben Gamari at 2019-12-30T06:51:32-05:00
driver: Include debug level in the recompilation check hash

Fixes #17586.

- - - - -
f14bb50b by Ben Gamari at 2019-12-30T06:52:09-05:00
rts: Ensure that nonmoving gc isn't used with profiling

- - - - -
b426de37 by Ben Gamari at 2019-12-30T06:52:45-05:00
llvmGen: Ensure that entry labels don't have predecessors

The LLVM IR forbids the entry label of a procedure from having any
predecessors. In the case of a simple looping function the LLVM code
generator broke this invariant, as noted in #17589. Fix this by
moving the function prologue to its own basic block, as suggested by
@kavon in #11649.

Fixes #11649 and #17589.

- - - - -
613f7265 by Ben Gamari at 2019-12-30T06:52:45-05:00
llvmGen: Drop old fix for #11649

This was a hack which is no longer necessary now since we introduce a
dedicated entry block for each procedure.

- - - - -
fdeffa5e by Ben Gamari at 2019-12-30T06:53:23-05:00
rts: Error on invalid --numa flags

Previously things like `+RTS --numa-debug` would enable NUMA support,
despite being an invalid flag.

- - - - -
9ce3ba68 by Ben Gamari at 2019-12-30T06:53:23-05:00
rts: Fix --debug-numa mode under Docker

As noted in #17606, Docker disallows the get_mempolicy syscall by
default. This caused numerous tests to fail under CI in the `debug_numa`
way. Avoid this by disabling the NUMA probing logic when --debug-numa is
in use, instead setting n_numa_nodes in RtsFlags.c.

Fixes #17606.

- - - - -
5baa2a43 by Ben Gamari at 2019-12-30T06:54:01-05:00
testsuite: Disable derefnull when built with LLVM

LLVM does not guarantee any particular semantics when dereferencing null
pointers. Consequently, this test actually passes when built with the
LLVM backend.

- - - - -
bd544d3d by Ben Gamari at 2019-12-30T06:54:38-05:00
hadrian: Track hash of Cabal Setup builder arguments

Lest we fail to rebuild when they change. Fixes #17611.

- - - - -
6e2c495e by Ben Gamari at 2019-12-30T06:55:19-05:00
TcIface: Fix inverted logic in typechecking of source ticks

Previously we would throw away source ticks when the debug level was
non-zero. This is precisely the opposite of what was intended.

Fixes #17616.

Metric Decrease:
    T13056
    T9020
    T9961
    T12425

- - - - -
7fad387d by Ben Gamari at 2019-12-30T06:55:55-05:00
perf_notes: Add --zero-y argument

This makes it easier to see the true magnitude of fluctuations.
Also do some house-keeping in the argument parsing department.

- - - - -
0d42b287 by Ben Gamari at 2019-12-30T06:55:55-05:00
testsuite: Enlarge acceptance window for T1969

As noted in #17624, it's quite unstable, especially, for some reason, on
i386 and armv7 (something about 32-bit platforms perhaps?).

Metric Increase:
    T1969

- - - - -
eb608235 by Sylvain Henry at 2019-12-31T14:22:32-05:00
Module hierarchy (#13009): Stg

- - - - -
d710fd66 by Vladislav Zavialov at 2019-12-31T14:23:10-05:00
Testsuite: update some Haddock tests

Fixed tests:

* haddockA039: added to all.T
* haddockE004: replaced with T17561 (marked as expect_broken)

New tests:

* haddockA040: deriving clause for a data instance
* haddockA041: haddock and CPP #include

- - - - -
859ebdd4 by Kevin Buhr at 2019-12-31T23:44:39-05:00
Add "-Iw" RTS flag for minimum wait between idle GCs (#11134)

- - - - -
dd4b6551 by Kevin Buhr at 2019-12-31T23:44:39-05:00
Add additional Note explaining the -Iw flag

- - - - -
c4279ff1 by Kevin Buhr at 2019-12-31T23:44:39-05:00
Fix some sloppy indentation

- - - - -
b84c09d5 by Ömer Sinan Ağacan at 2019-12-31T23:45:19-05:00
Tweak Cmm dumps to avoid generating sections for empty groups

When dumping Cmm groups check if the group is empty, to avoid generating
empty sections in dump files like

    ==================== Output Cmm ====================
    []

Also fixes a few bad indentation in the code around changes.

- - - - -
b2e0323f by Gabor Greif at 2020-01-03T21:22:36-05:00
Simplify mrStr

- - - - -
3c9dc06b by Brian Wignall at 2020-01-04T15:55:06-05:00
Fix typos, via a Levenshtein-style corrector

- - - - -
d561c8f6 by Sylvain Henry at 2020-01-04T15:55:46-05:00
Add Cmm related hooks

* stgToCmm hook
* cmmToRawCmm hook

These hooks are used by Asterius and could be useful to other clients of
the GHC API.

It increases the Parser dependencies (test CountParserDeps) to 184. It's
still less than 200 which was the initial request (cf
https://mail.haskell.org/pipermail/ghc-devs/2019-September/018122.html)
so I think it's ok to merge this.

- - - - -
ae6b6276 by Oleg Grenrus at 2020-01-04T15:56:22-05:00
Update to Cabal submodule to v3.2.0.0-alpha3

Metric Increase:
    haddock.Cabal

- - - - -
073f7cfd by Vladislav Zavialov at 2020-01-04T15:56:59-05:00
Add lexerDbg to dump the tokens fed to the parser

This a small utility function that comes in handy when debugging the
lexer and the parser.

- - - - -
558d4d4a by Sylvain Henry at 2020-01-04T15:57:38-05:00
Split integerGmpInternals test in several parts

This is to prepare for ghc-bignum which implements some but not all of
gmp functions.

- - - - -
4056b966 by Ben Gamari at 2020-01-04T15:58:15-05:00
testsuite: Mark cgrun057 as fragile on all platforms

I have seen this fail both on x86-64/Debian 9 and armv7/Debian 9

See #17554.

- - - - -
5ffea0c6 by Tamar Christina at 2020-01-06T18:38:37-05:00
Fix overflow.

- - - - -
99a9f51b by Sylvain Henry at 2020-01-06T18:39:22-05:00
Module hierarchy: Iface (cf #13009)

- - - - -
7aa4a061 by Ben Gamari at 2020-01-07T13:11:48-05:00
configure: Only check GCC version if CC is GCC

Also refactor FP_GCC_EXTRA_FLAGS in a few ways:

 * We no longer support compilers which lack support for -fno-builtin
   and -fwrapv so remove the condition on GccVersion
 * These flags are only necessary when using the via-C backend
   so make them conditional on Unregisterised.

Fixes #15742.

- - - - -
0805ed7e by John Ericson at 2020-01-07T13:12:25-05:00
Use non-empty lists to remove partiality in matching code

- - - - -
7844f3a8 by Ben Gamari at 2020-01-07T13:13:02-05:00
testsuite: Mark T17073 as broken on Windows

Due to #17607.

- - - - -
acf40cae by Ben Gamari at 2020-01-07T13:13:02-05:00
gitlab-ci: Disallow Windows from failing

- - - - -
34bc02c7 by Ben Gamari at 2020-01-07T13:13:02-05:00
configure: Find Python3 for testsuite

In addition, we prefer the Mingw64 Python distribution on Windows due
to #17483.

- - - - -
e35fe8d5 by Ben Gamari at 2020-01-07T13:13:02-05:00
testsuite: Fix Windows platform test

Previously we used platform.system() and while this worked fine (e.g.
returned `Windows`, as expected) locally under both msys and MingW64
Python distributions, it inexplicably returned `MINGW64_NT-10.0`
under MingW64 Python on CI. It seems os.name is more reliable so we now
use that instead..

- - - - -
48ef6217 by Ben Gamari at 2020-01-07T13:13:39-05:00
gitlab-ci: Rename push-test-metrics.sh to test-metrics.sh

Refactoring to follow.

- - - - -
2234fa92 by Ben Gamari at 2020-01-07T13:13:39-05:00
gitlab-ci: Pull test metrics before running testsuite

Otherwise the testsuite driver may not have an up-to-date
baseline.

- - - - -
1ca9adbc by Sylvain Henry at 2020-01-07T13:14:18-05:00
Remove `parallel` check from configure.ac

`parallel` is no longer a submodule since 3cb063c805ec841ca33b8371ef8aba9329221b6c

- - - - -
b69a3460 by Ryan Scott at 2020-01-07T13:14:57-05:00
Monomorphize HsModule to GhcPs (#17642)

Analyzing the call sites for `HsModule` reveals that it is only ever
used with parsed code (i.e., `GhcPs`). This simplifies `HsModule` by
concretizing its `pass` parameter to always be `GhcPs`.

Fixes #17642.

- - - - -
d491a679 by Sylvain Henry at 2020-01-08T06:16:31-05:00
Module hierarchy: Renamer (cf #13009)

- - - - -
d589410f by Ben Gamari at 2020-01-08T06:17:09-05:00
Bump haskeline submodule to 0.8.0.1

(cherry picked from commit feb3b955402d53c3875dd7a9a39f322827e5bd69)

- - - - -
923a1272 by Ryan Scott at 2020-01-08T06:17:47-05:00
Print Core type applications with no whitespace after @ (#17643)

This brings the pretty-printer for Core in line with how visible
type applications are normally printed: namely, with no whitespace
after the `@` character (i.e., `f @a` instead of `f @ a`). While I'm
in town, I also give the same treatment to type abstractions (i.e.,
`\(@a)` instead of `\(@ a)`) and coercion applications (i.e.,
`f @~x` instead of `f @~ x`).

Fixes #17643.

- - - - -
49f83a0d by Adam Sandberg Eriksson at 2020-01-12T21:28:09-05:00
improve docs for HeaderInfo.getImports

[skip ci]

- - - - -
9129210f by Matthew Pickering at 2020-01-12T21:28:47-05:00
Overloaded Quotation Brackets (#246)

This patch implements overloaded quotation brackets which generalise the
desugaring of all quotation forms in terms of a new minimal interface.

The main change is that a quotation, for example, [e| 5 |], will now
have type `Quote m => m Exp` rather than `Q Exp`. The `Quote` typeclass
contains a single method for generating new names which is used when
desugaring binding structures.

The return type of functions from the `Lift` type class, `lift` and `liftTyped` have
been restricted to `forall m . Quote m => m Exp` rather than returning a
result in a Q monad.

More details about the feature can be read in the GHC proposal.

https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0246-overloaded-bracket.rst

- - - - -
350e2b78 by Richard Eisenberg at 2020-01-12T21:29:27-05:00
Don't zap to Any; error instead

This changes GHC's treatment of so-called Naughty Quantification
Candidates to issue errors, instead of zapping to Any.

Close #16775.

No new test cases, because existing ones cover this well.

- - - - -
0b5ddc7f by Brian Wignall at 2020-01-12T21:30:08-05:00
Fix more typos, via an improved Levenshtein-style corrector

- - - - -
f732dbec by Ben Gamari at 2020-01-12T21:30:49-05:00
gitlab-ci: Retain bindists used by head.hackage for longer

Previously we would keep them for two weeks. However, on the stable
branches two weeks can easily elapse with no pushes.

- - - - -
c8636da5 by Sylvain Henry at 2020-01-12T21:31:30-05:00
Fix LANG=C for readelf invocation in T14999

The test fails when used with LANG=fr_FR.UTF-8

- - - - -
077a88de by Jean-Baptiste Mazon at 2020-01-12T21:32:08-05:00
users-guide/debug-info: typo “behivior”
- - - - -
61916c5d by Simon Peyton Jones at 2020-01-12T21:32:44-05:00
Add comments about TH levels

- - - - -
1fd766ca by Simon Peyton Jones at 2020-01-12T21:32:44-05:00
Comments about constraint floating

- - - - -
de01427e by Simon Peyton Jones at 2020-01-12T21:32:45-05:00
Minor refactor around quantified constraints

This patch clarifies a dark corner of quantified
constraints.

* See Note [Yukky eq_sel for a HoleDest] in TcSMonad

* Minor refactor, breaking out new function
     TcInteract.doTopReactEqPred

- - - - -
30be3bf1 by Simon Peyton Jones at 2020-01-12T21:32:45-05:00
Comments in TcHsType

- - - - -
c5977d4d by Sebastian Graf at 2020-01-16T05:58:58-05:00
Better documentation for mkEtaWW [skip ci]

So that hopefully I understand it faster next time. Also got rid of the
confusing `orig_expr`, which makes the call site in `etaExpand` look out
of sync with the passed `n` (which is not the original `n`).

- - - - -
22c0bdc3 by John Ericson at 2020-01-16T05:59:37-05:00
Handle TagToEnum in the same big case as the other primops

Before, it was a panic because it was handled above. But there must have
been an error in my reasoning (another caller?) because #17442 reported
the panic was hit.

But, rather than figuring out what happened, I can just make it
impossible by construction. By adding just a bit more bureaucracy in the
return types, I can handle TagToEnum in the same case as all the others,
so the big case is is now total, and the panic is removed.

Fixes #17442

- - - - -
ee5d63f4 by John Ericson at 2020-01-16T05:59:37-05:00
Get rid of OpDest

`OpDest` was basically a defunctionalization. Just turn the code that
cased on it into those functions, and call them directly.

- - - - -
1ff55226 by John Ericson at 2020-01-16T06:00:16-05:00
Remove special case case of bool during STG -> C--

Allow removing the no longer needed cgPrimOp, getting rid of a small a
small layer violation too.

Change which made the special case no longer needed was #6135 /
6579a6c73082387f82b994305011f011d9d8382b, which dates back to 2013,
making me feel better.

- - - - -
f416fe64 by Adam Wespiser at 2020-01-16T06:00:53-05:00
replace dead html link (fixes #17661)

- - - - -
f6bf2ce8 by Sebastian Graf at 2020-01-16T06:01:32-05:00
Revert "`exprOkForSpeculation` for Note [IO hack in the demand analyser]"

This reverts commit ce64b397777408731c6dd3f5c55ea8415f9f565b on the
grounds of the regression it would introduce in a couple of packages.

Fixes #17653.

Also undoes a slight metric increase in #13701 introduced by that commit
that we didn't see prior to !1983.

Metric Decrease:
    T13701

- - - - -
a71323ff by Ben Gamari at 2020-01-17T08:43:16-05:00
gitlab-ci: Don't FORCE_SYMLINKS on Windows

Not all runners have symlink permissions enabled.
- - - - -
0499e3bc by Ömer Sinan Ağacan at 2020-01-20T15:31:33-05:00
Fix +RTS -Z flag documentation

Stack squeezing is done on context switch, not on GC or stack overflow.
Fix the documentation.

Fixes #17685

[ci skip]

- - - - -
a661df91 by Ömer Sinan Ağacan at 2020-01-20T15:32:13-05:00
Document Stg.FVs module

Fixes #17662

[ci skip]

- - - - -
db24e480 by Ben Gamari at 2020-01-20T15:32:52-05:00
llvmGen: Don't trash STG registers

Fixes #13904.

- - - - -
f3d7fdb3 by Ben Gamari at 2020-01-20T15:32:52-05:00
llvmGen: Fix typo in readnone attribute

- - - - -
442751c6 by Ben Gamari at 2020-01-20T15:32:52-05:00
llvmGen: Add lower-expect to the -O0 optimisation set

@kavon says that this will improve block layout for stack checks.

- - - - -
e90ecc93 by Ben Gamari at 2020-01-20T15:32:52-05:00
llvmGen: Fix #14251

Fixes the calling convention for functions passing raw SSE-register
values by adding padding as needed to get the values in the right
registers. This problem cropped up when some args were unused an dropped
from the live list.

This folds together 2e23e1c7de01c92b038e55ce53d11bf9db993dd4 and
73273be476a8cc6c13368660b042b3b0614fd928 previously from @kavon.

Metric Increase:
    T12707
    ManyConstructors

- - - - -
66e511a4 by Ben Gamari at 2020-01-20T15:33:28-05:00
testsuite: Preserve more information in framework failures

Namely print the entire exception in hopes that this will help track
down #17649.

- - - - -
b62b8cea by Ömer Sinan Ağacan at 2020-01-20T15:34:06-05:00
Remove deprecated -smp flag

It was deprecated in 2012 with 46258b40

- - - - -
0c04a86a by Ben Gamari at 2020-01-20T15:34:43-05:00
gitlab-ci: Reenable submodule linter

- - - - -
2bfabd22 by Ben Gamari at 2020-01-20T15:34:43-05:00
gitlab-ci: Allow submodule cleaning to fail on Windows

Currently CI is inexplicably failing with
```
$ git submodule foreach git clean -xdf
fatal: not a git repository: libffi-tarballs/../.git/modules/libffi-tarballs
```
I have no idea how this working tree got into such a state but we do
need to fail more gracefully when it happens. Consequently, we allow the
cleaning step to fail.

- - - - -
14bced99 by Xavier Denis at 2020-01-20T15:35:21-05:00
Put the docs for :instances in alphabetical position

- - - - -
7e0bb82b by Ben Gamari at 2020-01-20T15:35:57-05:00
Add missing Note [Improvement from Ground Wanteds]

Closes #17659.

- - - - -
17e43a7c by Ben Gamari at 2020-01-20T15:36:32-05:00
unregisterised: Fix declaration for stg_NO_FINALIZER

Previously it had a redundant _entry suffix. We never noticed this
previously presumably because we never generated references to it
(however hard to believe this may be). However, it did start failing in
!1304.

- - - - -
3dae006f by PHO at 2020-01-20T15:37:08-05:00
Avoid ./configure failure on NetBSD

- - - - -
738e2912 by Ben Gamari at 2020-01-24T13:42:56-05:00
testsuite: Widen acceptance window of T1969

I have seen >20% fluctuations in this number, leading to spurious
failures.

- - - - -
ad4eb7a7 by Gabor Greif at 2020-01-25T05:19:07-05:00
Document the fact, that openFileBlocking can consume an OS thread indefinitely.

Also state that a deadlock can happen with the non-threaded runtime.
[ci skip]
- - - - -
be910728 by Sebastian Graf at 2020-01-25T05:19:46-05:00
`-ddump-str-signatures` dumps Text, not STG [skip ci]

- - - - -
0e57d8a1 by Ömer Sinan Ağacan at 2020-01-25T05:20:27-05:00
Fix chaining tagged and untagged ptrs in compacting GC

Currently compacting GC has the invariant that in a chain all fields are tagged
the same. However this does not really hold: root pointers are not tagged, so
when we thread a root we initialize a chain without a tag. When the pointed
objects is evaluated and we have more pointers to it from the heap, we then add
*tagged* fields to the chain (because pointers to it from the heap are tagged),
ending up chaining fields with different tags (pointers from roots are NOT
tagged, pointers from heap are). This breaks the invariant and as a result
compacting GC turns tagged pointers into non-tagged.

This later causes problem in the generated code where we do reads assuming that
the pointer is aligned, e.g.

    0x7(%rax) -- assumes that pointer is tagged 1

which causes misaligned reads. This caused #17088.

We fix this using the "pointer tagging for large families" patch (#14373,
!1742):

- With the pointer tagging patch the GC can know what the tagged pointer to a
  CONSTR should be (previously we'd need to know the family size -- large
  families are always tagged 1, small families are tagged depending on the
  constructor).

- Since we now know what the tags should be we no longer need to store the
  pointer tag in the info table pointers when forming chains in the compacting
  GC.

As a result we no longer need to tag pointers in chains with 1/2 depending on
whether the field points to an info table pointer, or to another field: an info
table pointer is always tagged 0, everything else in the chain is tagged 1. The
lost tags in pointers can be retrieved by looking at the info table.

Finally, instead of using tag 1 for fields and tag 0 for info table pointers, we
use two different tags for fields:

- 1 for fields that have untagged pointers
- 2 for fields that have tagged pointers

When unchaining we then look at the pointer to a field, and depending on its tag
we either leave a tagged pointer or an untagged pointer in the field.

This allows chaining untagged and tagged fields together in compacting GC.

Fixes #17088

Nofib results
-------------

Binaries are smaller because of smaller `Compact.c` code.

make mode=fast EXTRA_RUNTEST_OPTS="-cachegrind" EXTRA_HC_OPTS="-with-rtsopts=-c" NoFibRuns=1

    --------------------------------------------------------------------------------
            Program           Size    Allocs    Instrs     Reads    Writes
    --------------------------------------------------------------------------------
                 CS          -0.3%      0.0%     +0.0%     +0.0%     +0.0%
                CSD          -0.3%      0.0%     +0.0%     +0.0%     +0.0%
                 FS          -0.3%      0.0%     +0.0%     -0.0%     -0.0%
                  S          -0.3%      0.0%     +5.4%     +0.8%     +3.9%
                 VS          -0.3%      0.0%     +0.0%     -0.0%     -0.0%
                VSD          -0.3%      0.0%     -0.0%     -0.0%     -0.2%
                VSM          -0.3%      0.0%     +0.0%     +0.0%     +0.0%
               anna          -0.1%      0.0%     +0.0%     +0.0%     +0.0%
               ansi          -0.3%      0.0%     +0.1%     +0.0%     +0.0%
               atom          -0.2%      0.0%     +0.0%     +0.0%     +0.0%
             awards          -0.2%      0.0%     +0.0%      0.0%     -0.0%
             banner          -0.3%      0.0%     +0.0%     +0.0%     +0.0%
         bernouilli          -0.3%      0.0%     +0.1%     +0.0%     +0.0%
       binary-trees          -0.2%      0.0%     +0.0%      0.0%     +0.0%
              boyer          -0.3%      0.0%     +0.2%     +0.0%     +0.0%
             boyer2          -0.2%      0.0%     +0.2%     +0.1%     +0.0%
               bspt          -0.2%      0.0%     +0.0%     +0.0%     +0.0%
          cacheprof          -0.2%      0.0%     +0.0%     +0.0%     +0.0%
           calendar          -0.3%      0.0%     +0.0%     +0.0%     +0.0%
           cichelli          -0.3%      0.0%     +1.1%     +0.2%     +0.5%
            circsim          -0.2%      0.0%     +0.0%     -0.0%     -0.0%
           clausify          -0.3%      0.0%     +0.0%     -0.0%     -0.0%
      comp_lab_zift          -0.2%      0.0%     +0.0%     +0.0%     +0.0%
           compress          -0.3%      0.0%     +0.0%     +0.0%     +0.0%
          compress2          -0.3%      0.0%     +0.0%     -0.0%     -0.0%
        constraints          -0.3%      0.0%     +0.2%     +0.1%     +0.1%
       cryptarithm1          -0.3%      0.0%     +0.0%     -0.0%      0.0%
       cryptarithm2          -0.3%      0.0%     +0.0%     +0.0%     +0.0%
                cse          -0.3%      0.0%     +0.0%     +0.0%     +0.0%
       digits-of-e1          -0.3%      0.0%     +0.0%     +0.0%     +0.0%
       digits-of-e2          -0.3%      0.0%     +0.0%     +0.0%     -0.0%
             dom-lt          -0.2%      0.0%     +0.0%     +0.0%     +0.0%
              eliza          -0.2%      0.0%     +0.0%     +0.0%     +0.0%
              event          -0.3%      0.0%     +0.1%     +0.0%     -0.0%
        exact-reals          -0.2%      0.0%     +0.0%     +0.0%     +0.0%
             exp3_8          -0.3%      0.0%     +0.0%     +0.0%     +0.0%
             expert          -0.2%      0.0%     +0.0%     +0.0%     +0.0%
     fannkuch-redux          -0.3%      0.0%     -0.0%     -0.0%     -0.0%
              fasta          -0.3%      0.0%     +0.0%     +0.0%     +0.0%
                fem          -0.2%      0.0%     +0.1%     +0.0%     +0.0%
                fft          -0.2%      0.0%     +0.0%     -0.0%     -0.0%
               fft2          -0.2%      0.0%     +0.0%     -0.0%     +0.0%
           fibheaps          -0.3%      0.0%     +0.0%     -0.0%     -0.0%
               fish          -0.3%      0.0%     +0.0%     +0.0%     +0.0%
              fluid          -0.2%      0.0%     +0.4%     +0.1%     +0.1%
             fulsom          -0.2%      0.0%     +0.0%     +0.0%     +0.0%
             gamteb          -0.2%      0.0%     +0.1%     +0.0%     +0.0%
                gcd          -0.3%      0.0%     +0.0%     +0.0%     +0.0%
        gen_regexps          -0.3%      0.0%     +0.0%     -0.0%     -0.0%
             genfft          -0.3%      0.0%     +0.0%     +0.0%     +0.0%
                 gg          -0.2%      0.0%     +0.7%     +0.3%     +0.2%
               grep          -0.2%      0.0%     +0.0%     +0.0%     +0.0%
             hidden          -0.2%      0.0%     +0.0%     +0.0%     +0.0%
                hpg          -0.2%      0.0%     +0.1%     +0.0%     +0.0%
                ida          -0.3%      0.0%     +0.0%     +0.0%     +0.0%
              infer          -0.2%      0.0%     +0.0%     -0.0%     -0.0%
            integer          -0.3%      0.0%     +0.0%     +0.0%     +0.0%
          integrate          -0.2%      0.0%     +0.0%     +0.0%     +0.0%
       k-nucleotide          -0.2%      0.0%     +0.0%     +0.0%     -0.0%
              kahan          -0.3%      0.0%     -0.0%     -0.0%     -0.0%
            knights          -0.3%      0.0%     +0.0%     -0.0%     -0.0%
             lambda          -0.3%      0.0%     +0.0%     -0.0%     -0.0%
         last-piece          -0.3%      0.0%     +0.0%     +0.0%     +0.0%
               lcss          -0.3%      0.0%     +0.0%     +0.0%      0.0%
               life          -0.3%      0.0%     +0.0%     -0.0%     -0.0%
               lift          -0.2%      0.0%     +0.0%     +0.0%     +0.0%
             linear          -0.2%      0.0%     +0.0%     +0.0%     +0.0%
          listcompr          -0.3%      0.0%     +0.0%     +0.0%     +0.0%
           listcopy          -0.3%      0.0%     +0.0%     +0.0%     +0.0%
           maillist          -0.3%      0.0%     +0.0%     -0.0%     -0.0%
             mandel          -0.2%      0.0%     +0.0%     +0.0%     +0.0%
            mandel2          -0.3%      0.0%     +0.0%     +0.0%     +0.0%
               mate          -0.2%      0.0%     +0.0%     +0.0%     +0.0%
            minimax          -0.3%      0.0%     +0.0%     +0.0%     +0.0%
            mkhprog          -0.2%      0.0%     +0.0%     +0.0%     +0.0%
         multiplier          -0.3%      0.0%     +0.0%     -0.0%     -0.0%
             n-body          -0.2%      0.0%     -0.0%     -0.0%     -0.0%
           nucleic2          -0.2%      0.0%     +0.0%     +0.0%     +0.0%
               para          -0.2%      0.0%     +0.0%     -0.0%     -0.0%
          paraffins          -0.3%      0.0%     +0.0%     -0.0%     -0.0%
             parser          -0.2%      0.0%     +0.0%     +0.0%     +0.0%
            parstof          -0.2%      0.0%     +0.8%     +0.2%     +0.2%
                pic          -0.2%      0.0%     +0.1%     -0.1%     -0.1%
           pidigits          -0.3%      0.0%     +0.0%     +0.0%     +0.0%
              power          -0.2%      0.0%     +0.0%     -0.0%     -0.0%
             pretty          -0.3%      0.0%     -0.0%     -0.0%     -0.1%
             primes          -0.3%      0.0%     +0.0%     +0.0%     -0.0%
          primetest          -0.2%      0.0%     +0.0%     -0.0%     -0.0%
             prolog          -0.3%      0.0%     +0.0%     -0.0%     -0.0%
             puzzle          -0.3%      0.0%     +0.0%     +0.0%     +0.0%
             queens          -0.3%      0.0%     +0.0%     +0.0%     +0.0%
            reptile          -0.2%      0.0%     +0.2%     +0.1%     +0.0%
    reverse-complem          -0.3%      0.0%     +0.0%     +0.0%     +0.0%
            rewrite          -0.3%      0.0%     +0.0%     -0.0%     -0.0%
               rfib          -0.2%      0.0%     +0.0%     +0.0%     -0.0%
                rsa          -0.2%      0.0%     +0.0%     +0.0%     +0.0%
                scc          -0.3%      0.0%     -0.0%     -0.0%     -0.1%
              sched          -0.3%      0.0%     +0.0%     +0.0%     +0.0%
                scs          -0.2%      0.0%     +0.1%     +0.0%     +0.0%
             simple          -0.2%      0.0%     +3.4%     +1.0%     +1.8%
              solid          -0.2%      0.0%     +0.0%     +0.0%     +0.0%
            sorting          -0.3%      0.0%     +0.0%     +0.0%     +0.0%
      spectral-norm          -0.2%      0.0%     -0.0%     -0.0%     -0.0%
             sphere          -0.2%      0.0%     +0.0%     +0.0%     +0.0%
             symalg          -0.2%      0.0%     +0.0%     +0.0%     +0.0%
                tak          -0.3%      0.0%     +0.0%     +0.0%     -0.0%
          transform          -0.2%      0.0%     +0.2%     +0.1%     +0.1%
           treejoin          -0.3%      0.0%     +0.2%     -0.0%     -0.1%
          typecheck          -0.3%      0.0%     +0.0%     +0.0%     +0.0%
            veritas          -0.1%      0.0%     +0.0%     +0.0%     +0.0%
               wang          -0.2%      0.0%     +0.0%     -0.0%     -0.0%
          wave4main          -0.3%      0.0%     +0.0%     -0.0%     -0.0%
       wheel-sieve1          -0.3%      0.0%     +0.0%     -0.0%     -0.0%
       wheel-sieve2          -0.3%      0.0%     +0.0%     -0.0%     -0.0%
               x2n1          -0.3%      0.0%     +0.0%     +0.0%     +0.0%
    --------------------------------------------------------------------------------
                Min          -0.3%      0.0%     -0.0%     -0.1%     -0.2%
                Max          -0.1%      0.0%     +5.4%     +1.0%     +3.9%
     Geometric Mean          -0.3%     -0.0%     +0.1%     +0.0%     +0.1%

    --------------------------------------------------------------------------------
            Program           Size    Allocs    Instrs     Reads    Writes
    --------------------------------------------------------------------------------
            circsim          -0.2%      0.0%     +1.6%     +0.4%     +0.7%
        constraints          -0.3%      0.0%     +4.3%     +1.5%     +2.3%
           fibheaps          -0.3%      0.0%     +3.5%     +1.2%     +1.3%
             fulsom          -0.2%      0.0%     +3.6%     +1.2%     +1.8%
           gc_bench          -0.3%      0.0%     +4.1%     +1.3%     +2.3%
               hash          -0.3%      0.0%     +6.6%     +2.2%     +3.6%
               lcss          -0.3%      0.0%     +0.7%     +0.2%     +0.7%
          mutstore1          -0.3%      0.0%     +4.8%     +1.4%     +2.8%
          mutstore2          -0.3%      0.0%     +3.4%     +1.0%     +1.7%
              power          -0.2%      0.0%     +2.7%     +0.6%     +1.9%
         spellcheck          -0.3%      0.0%     +1.1%     +0.4%     +0.4%
    --------------------------------------------------------------------------------
                Min          -0.3%      0.0%     +0.7%     +0.2%     +0.4%
                Max          -0.2%      0.0%     +6.6%     +2.2%     +3.6%
     Geometric Mean          -0.3%     +0.0%     +3.3%     +1.0%     +1.8%

Metric changes
--------------

While it sounds ridiculous, this change causes increased allocations in
the following tests. We concluded that this change can't cause a
difference in allocations and decided to land this patch. Fluctuations
in "bytes allocated" metric is tracked in #17686.

Metric Increase:
    Naperian
    T10547
    T12150
    T12234
    T12425
    T13035
    T5837
    T6048

- - - - -
8038cbd9 by Sebastian Graf at 2020-01-25T05:21:05-05:00
PmCheck: Formulate as translation between Clause Trees

We used to check `GrdVec`s arising from multiple clauses and guards in
isolation. That resulted in a split between `pmCheck` and
`pmCheckGuards`, the implementations of which were similar, but subtly
different in detail. Also the throttling mechanism described in
`Note [Countering exponential blowup]` ultimately got quite complicated
because it had to cater for both checking functions.

This patch realises that pattern match checking doesn't just consider
single guarded RHSs, but that it's always a whole set of clauses, each
of which can have multiple guarded RHSs in turn. We do so by
translating a list of `Match`es to a `GrdTree`:

```haskell
data GrdTree
  = Rhs !RhsInfo
  | Guard !PmGrd !GrdTree      -- captures lef-to-right  match semantics
  | Sequence !GrdTree !GrdTree -- captures top-to-bottom match semantics
  | Empty                      -- For -XEmptyCase, neutral element of Sequence
```

Then we have a function `checkGrdTree` that matches a given `GrdTree`
against an incoming set of values, represented by `Deltas`:

```haskell
checkGrdTree :: GrdTree -> Deltas -> CheckResult
...
```

Throttling is isolated to the `Sequence` case and becomes as easy as one
would expect: When the union of uncovered values becomes too big, just
return the original incoming `Deltas` instead (which is always a
superset of the union, thus a sound approximation).

The returned `CheckResult` contains two things:

1. The set of values that were not covered by any of the clauses, for
   exhaustivity warnings.
2. The `AnnotatedTree` that enriches the syntactic structure of the
   input program with divergence and inaccessibility information.

This is `AnnotatedTree`:

```haskell
data AnnotatedTree
  = AccessibleRhs !RhsInfo
  | InaccessibleRhs !RhsInfo
  | MayDiverge !AnnotatedTree
  | SequenceAnn !AnnotatedTree !AnnotatedTree
  | EmptyAnn
```

Crucially, `MayDiverge` asserts that the tree may force diverging
values, so not all of its wrapped clauses can be redundant.

While the set of uncovered values can be used to generate the missing
equations for warning messages, redundant and proper inaccessible
equations can be extracted from `AnnotatedTree` by
`redundantAndInaccessibleRhss`.

For this to work properly, the interface to the Oracle had to change.
There's only `addPmCts` now, which takes a bag of `PmCt`s. There's a
whole bunch of `PmCt` variants to replace the different oracle functions
from before.

The new `AnnotatedTree` structure allows for more accurate warning
reporting (as evidenced by a number of changes spread throughout GHC's
code base), thus we fix #17465.

Fixes #17646 on the go.

Metric Decrease:
    T11822
    T9233
    PmSeriesS
    haddock.compiler

- - - - -
86966d48 by Sebastian Graf at 2020-01-25T05:21:05-05:00
PmCheck: Properly handle constructor-bound type variables

In https://gitlab.haskell.org/ghc/ghc/merge_requests/2192#note_246551
Simon convinced me that ignoring type variables existentially bound by
data constructors have to be the same way as value binders.

Sadly I couldn't think of a regression test, but I'm confident that this
change strictly improves on the status quo.

- - - - -
c3fde723 by Ryan Scott at 2020-01-25T05:21:40-05:00
Handle local fixity declarations in DsMeta properly

`DsMeta.rep_sig` used to skip over `FixSig` entirely, which had the
effect of causing local fixity declarations to be dropped when quoted
in Template Haskell. But there is no good reason for this state of
affairs, as the code in `DsMeta.repFixD` (which handles top-level
fixity declarations) handles local fixity declarations just fine.
This patch factors out the necessary parts of `repFixD` so that they
can be used in `rep_sig` as well.

There was one minor complication: the fixity signatures for class
methods in each `HsGroup` were stored both in `FixSig`s _and_ the
list of `LFixitySig`s for top-level fixity signatures, so I needed
to take action to prevent fixity signatures for class methods being
converted to `Dec`s twice. I tweaked `RnSource.add` to avoid putting
these fixity signatures in two places and added
`Note [Top-level fixity signatures in an HsGroup]` in `GHC.Hs.Decls`
to explain the new design.

Fixes #17608. Bumps the Haddock submodule.

- - - - -
6e2d9ee2 by Sylvain Henry at 2020-01-25T05:22:20-05:00
Module hierarchy: Cmm (cf #13009)

- - - - -
8b726534 by PHO at 2020-01-25T05:23:01-05:00
Fix rts allocateExec() on NetBSD

Similar to SELinux, NetBSD "PaX mprotect" prohibits marking a page
mapping both writable and executable at the same time. Use libffi
which knows how to work around it.

- - - - -
6eb566a0 by Xavier Denis at 2020-01-25T05:23:39-05:00
Add ghc-in-ghci for stack based builds

- - - - -
b1a32170 by Xavier Denis at 2020-01-25T05:23:39-05:00
Create ghci.cabal.sh

- - - - -
0a5e4f5f by Sylvain Henry at 2020-01-25T05:24:19-05:00
Split glasgow_exts into several files (#17316)

- - - - -
b3e5c678 by Ben Gamari at 2020-01-25T05:24:57-05:00
hadrian: Throw error on duplicate-named flavours

Throw an error if the user requests a flavour for which there is more
than one match.

Fixes #17156.

- - - - -
0940b59a by Ryan Scott at 2020-01-25T08:15:05-05:00
Do not bring visible foralls into scope in hsScopedTvs

Previously, `hsScopedTvs` (and its cousin `hsWcScopedTvs`) pretended
that visible dependent quantification could not possibly happen at
the term level, and cemented that assumption with an `ASSERT`:

```hs
    hsScopedTvs (HsForAllTy { hst_fvf = vis_flag, ... }) =
      ASSERT( vis_flag == ForallInvis )
      ...
```

It turns out that this assumption is wrong. You can end up tripping
this `ASSERT` if you stick it to the man and write a type for a term
that uses visible dependent quantification anyway, like in this
example:

```hs
{-# LANGUAGE ScopedTypeVariables #-}

x :: forall a -> a -> a
x = x
```

That won't typecheck, but that's not the point. Before the
typechecker has a chance to reject this, the renamer will try
to use `hsScopedTvs` to bring `a` into scope over the body of `x`,
since `a` is quantified by a `forall`. This, in turn, causes the
`ASSERT` to fail. Bummer.

Instead of walking on this dangerous ground, this patch makes GHC
adopt a more hardline stance by pattern-matching directly on
`ForallInvis` in `hsScopedTvs`:

```hs
    hsScopedTvs (HsForAllTy { hst_fvf = ForallInvis, ... }) = ...
```

Now `a` will not be brought over the body of `x` at all (which is how
it should be), there's no chance of the `ASSERT` failing anymore (as
it's gone), and best of all, the behavior of `hsScopedTvs` does not
change. Everyone wins!

Fixes #17687.

- - - - -
1132602f by Ryan Scott at 2020-01-27T10:03:42-05:00
Use splitLHs{ForAll,Sigma}TyInvis throughout the codebase

Richard points out in #17688 that we use `splitLHsForAllTy` and
`splitLHsSigmaTy` in places that we ought to be using the
corresponding `-Invis` variants instead, identifying two bugs
that are caused by this oversight:

* Certain TH-quoted type signatures, such as those that appear in
  quoted `SPECIALISE` pragmas, silently turn visible `forall`s into
  invisible `forall`s.
* When quoted, the type `forall a -> (a ~ a) => a` will turn into
  `forall a -> a` due to a bug in `DsMeta.repForall` that drops
  contexts that follow visible `forall`s.

These are both ultimately caused by the fact that `splitLHsForAllTy`
and `splitLHsSigmaTy` split apart visible `forall`s in addition to
invisible ones. This patch cleans things up:

* We now use `splitLHsForAllTyInvis` and `splitLHsSigmaTyInvis`
  throughout the codebase. Relatedly, the `splitLHsForAllTy` and
  `splitLHsSigmaTy` have been removed, as they are easy to misuse.
* `DsMeta.repForall` now only handles invisible `forall`s to reduce
  the chance for confusion with visible `forall`s, which need to be
  handled differently. I also renamed it from `repForall` to
  `repForallT` to emphasize that its distinguishing characteristic
  is the fact that it desugars down to `L.H.TH.Syntax.ForallT`.

Fixes #17688.

- - - - -
97d0b0a3 by Matthew Pickering at 2020-01-27T10:04:19-05:00
Make Block.h compile with c++ compilers

- - - - -
4bada77d by Tom Ellis at 2020-01-27T12:30:46-05:00
Disable two warnings for files that trigger them

incomplete-uni-patterns and incomplete-record-updates will be in -Wall at a
future date, so prepare for that by disabling those warnings on files that
trigger them.

- - - - -
0188404a by Tom Ellis at 2020-01-27T12:30:46-05:00
Add two warnings to stage 2 build

- - - - -
acae02c1 by Tom Ellis at 2020-01-27T12:30:46-05:00
Add two warnings to Hadrian

- - - - -
bf38a20e by Sylvain Henry at 2020-01-31T02:46:15-05:00
Call `interpretPackageEnv` from `setSessionDynFlags`

interpretPackageEnv modifies the flags by reading the dreaded package
environments. It is much less surprising to call it from
`setSessionDynFlags` instead of reading package environments as a
side-effect of `initPackages`.

- - - - -
29c701c1 by Sylvain Henry at 2020-01-31T02:46:15-05:00
Refactor package related code

The package terminology is a bit of a mess. Cabal packages contain
components. Instances of these components when built with some
flags/options/dependencies are called units. Units are registered into
package databases and their metadata are called PackageConfig.

GHC only knows about package databases containing units. It is a sad
mismatch not fixed by this patch (we would have to rename parameters
such as `package-id <unit-id>` which would affect users).

This patch however fixes the following internal names:

- Renames PackageConfig into UnitInfo.
- Rename systemPackageConfig into globalPackageDatabase[Path]
- Rename PkgConfXX into PkgDbXX
- Rename pkgIdMap into unitIdMap
- Rename ModuleToPkgDbAll into ModuleNameProvidersMap
- Rename lookupPackage into lookupUnit
- Add comments on DynFlags package related fields

It also introduces a new `PackageDatabase` datatype instead of
explicitly passing the following tuple: `(FilePath,[PackageConfig])`.

The `pkgDatabase` field in `DynFlags` now contains the unit info for
each unit of each package database exactly as they have been read from
disk. Previously the command-line flag `-distrust-all-packages` would
modify these unit info. Now this flag only affects the "dynamic"
consolidated package state found in `pkgState` field. It makes sense
because `initPackages` could be called first with this
`distrust-all-packages` flag set and then again (using ghc-api) without
and it should work (package databases are not read again from disk when
`initPackages` is called the second time).

Bump haddock submodule

- - - - -
942c7148 by Ben Gamari at 2020-01-31T02:46:54-05:00
rename: Eliminate usage of mkVarOccUnique

Replacing it with `newSysName`. Fixes #17061.

- - - - -
41117d71 by Ben Gamari at 2020-01-31T02:47:31-05:00
base: Use one-shot kqueue on macOS

The underlying reason requiring that one-shot usage be disabled (#13903)
has been fixed.

Closes #15768.

- - - - -
01b15b83 by Ben Gamari at 2020-01-31T02:48:08-05:00
testsuite: Don't crash on encoding failure in print

If the user doesn't use a Unicode locale then the testsuite driver would
previously throw framework failures due to encoding failures. We now
rather use the `replace` error-handling strategy.

- - - - -
c846618a by Ömer Sinan Ağacan at 2020-01-31T12:21:10+03:00
Do CafInfo/SRT analysis in Cmm

This patch removes all CafInfo predictions and various hacks to preserve
predicted CafInfos from the compiler and assigns final CafInfos to
interface Ids after code generation. SRT analysis is extended to support
static data, and Cmm generator is modified to allow generating
static_link fields after SRT analysis.

This also fixes `-fcatch-bottoms`, which introduces error calls in case
expressions in CorePrep, which runs *after* CoreTidy (which is where we
decide on CafInfos) and turns previously non-CAFFY things into CAFFY.

Fixes #17648
Fixes #9718

Evaluation
==========

NoFib
-----

Boot with: `make boot mode=fast`
Run: `make mode=fast EXTRA_RUNTEST_OPTS="-cachegrind" NoFibRuns=1`

--------------------------------------------------------------------------------
        Program           Size    Allocs    Instrs     Reads    Writes
--------------------------------------------------------------------------------
             CS          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
            CSD          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
             FS          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
              S          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
             VS          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
            VSD          -0.0%      0.0%     -0.0%     -0.0%     -0.5%
            VSM          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
           anna          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
           ansi          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
           atom          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
         awards          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
         banner          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
     bernouilli          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
   binary-trees          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
          boyer          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
         boyer2          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
           bspt          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
      cacheprof          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
       calendar          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
       cichelli          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
        circsim          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
       clausify          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
  comp_lab_zift          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
       compress          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
      compress2          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
    constraints          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
   cryptarithm1          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
   cryptarithm2          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
            cse          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
   digits-of-e1          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
   digits-of-e2          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
         dom-lt          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
          eliza          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
          event          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
    exact-reals          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
         exp3_8          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
         expert          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
 fannkuch-redux          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
          fasta          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
            fem          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
            fft          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
           fft2          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
       fibheaps          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
           fish          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
          fluid          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
         fulsom          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
         gamteb          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
            gcd          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
    gen_regexps          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
         genfft          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
             gg          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
           grep          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
         hidden          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
            hpg          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
            ida          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
          infer          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
        integer          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
      integrate          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
   k-nucleotide          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
          kahan          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
        knights          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
         lambda          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
     last-piece          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
           lcss          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
           life          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
           lift          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
         linear          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
      listcompr          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
       listcopy          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
       maillist          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
         mandel          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
        mandel2          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
           mate          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
        minimax          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
        mkhprog          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
     multiplier          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
         n-body          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
       nucleic2          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
           para          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
      paraffins          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
         parser          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
        parstof          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
            pic          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
       pidigits          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
          power          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
         pretty          -0.0%      0.0%     -0.3%     -0.4%     -0.4%
         primes          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
      primetest          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
         prolog          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
         puzzle          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
         queens          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
        reptile          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
reverse-complem          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
        rewrite          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
           rfib          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
            rsa          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
            scc          -0.0%      0.0%     -0.3%     -0.5%     -0.4%
          sched          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
            scs          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
         simple          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
          solid          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
        sorting          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
  spectral-norm          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
         sphere          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
         symalg          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
            tak          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
      transform          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
       treejoin          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
      typecheck          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
        veritas          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
           wang          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
      wave4main          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
   wheel-sieve1          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
   wheel-sieve2          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
           x2n1          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
--------------------------------------------------------------------------------
            Min          -0.1%      0.0%     -0.3%     -0.5%     -0.5%
            Max          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
 Geometric Mean          -0.0%     -0.0%     -0.0%     -0.0%     -0.0%

--------------------------------------------------------------------------------
        Program           Size    Allocs    Instrs     Reads    Writes
--------------------------------------------------------------------------------
        circsim          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
    constraints          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
       fibheaps          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
       gc_bench          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
           hash          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
           lcss          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
          power          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
     spellcheck          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
--------------------------------------------------------------------------------
            Min          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
            Max          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
 Geometric Mean          -0.0%     +0.0%     -0.0%     -0.0%     -0.0%

Manual inspection of programs in testsuite/tests/programs
---------------------------------------------------------

I built these programs with a bunch of dump flags and `-O` and compared
STG, Cmm, and Asm dumps and file sizes.

(Below the numbers in parenthesis show number of modules in the program)

These programs have identical compiler (same .hi and .o sizes, STG, and
Cmm and Asm dumps):

- Queens (1), andre_monad (1), cholewo-eval (2), cvh_unboxing (3),
  andy_cherry (7), fun_insts (1), hs-boot (4), fast2haskell (2),
  jl_defaults (1), jq_readsPrec (1), jules_xref (1), jtod_circint (4),
  jules_xref2 (1), lennart_range (1), lex (1), life_space_leak (1),
  bargon-mangler-bug (7), record_upd (1), rittri (1), sanders_array (1),
  strict_anns (1), thurston-module-arith (2), okeefe_neural (1),
  joao-circular (6), 10queens (1)

Programs with different compiler outputs:

- jl_defaults (1): For some reason GHC HEAD marks a lot of top-level
  `[Int]` closures as CAFFY for no reason. With this patch we no longer
  make them CAFFY and generate less SRT entries. For some reason Main.o
  is slightly larger with this patch (1.3%) and the executable sizes are
  the same. (I'd expect both to be smaller)

- launchbury (1): Same as jl_defaults: top-level `[Int]` closures marked
  as CAFFY for no reason. Similarly `Main.o` is 1.4% larger but the
  executable sizes are the same.

- galois_raytrace (13): Differences are in the Parse module. There are a
  lot, but some of the changes are caused by the fact that for some
  reason (I think a bug) GHC HEAD marks the dictionary for `Functor
  Identity` as CAFFY. Parse.o is 0.4% larger, the executable size is the
  same.

- north_array: We now generate less SRT entries because some of array
  primops used in this program like `NewArrayOp` get eliminated during
  Stg-to-Cmm and turn some CAFFY things into non-CAFFY. Main.o gets 24%
  larger (9224 bytes from 9000 bytes), executable sizes are the same.

- seward-space-leak: Difference in this program is better shown by this
  smaller example:

      module Lib where

      data CDS
        = Case [CDS] [(Int, CDS)]
        | Call CDS CDS

      instance Eq CDS where
        Case sels1 rets1 == Case sels2 rets2 =
            sels1 == sels2 && rets1 == rets2
        Call a1 b1 == Call a2 b2 =
            a1 == a2 && b1 == b2
        _ == _ =
            False

   In this program GHC HEAD builds a new SRT for the recursive group of
   `(==)`, `(/=)` and the dictionary closure. Then `/=` points to `==`
   in its SRT field, and `==` uses the SRT object as its SRT. With this
   patch we use the closure for `/=` as the SRT and add `==` there. Then
   `/=` gets an empty SRT field and `==` points to `/=` in its SRT
   field.

   This change looks fine to me.

   Main.o gets 0.07% larger, executable sizes are identical.

head.hackage
------------

head.hackage's CI script builds 428 packages from Hackage using this
patch with no failures.

Compiler performance
--------------------

The compiler perf tests report that the compiler allocates slightly more
(worst case observed so far is 4%). However most programs in the test
suite are small, single file programs. To benchmark compiler performance
on something more realistic I build Cabal (the library, 236 modules)
with different optimisation levels. For the "max residency" row I run
GHC with `+RTS -s -A100k -i0 -h` for more accurate numbers. Other rows
are generated with just `-s`. (This is because `-i0` causes running GC
much more frequently and as a result "bytes copied" gets inflated by
more than 25x in some cases)

* -O0

|                 | GHC HEAD       | This MR        | Diff   |
| --------------- | -------------- | -------------- | ------ |
| Bytes allocated | 54,413,350,872 | 54,701,099,464 | +0.52% |
| Bytes copied    |  4,926,037,184 |  4,990,638,760 | +1.31% |
| Max residency   |    421,225,624 |    424,324,264 | +0.73% |

* -O1

|                 | GHC HEAD        | This MR         | Diff   |
| --------------- | --------------- | --------------- | ------ |
| Bytes allocated | 245,849,209,992 | 246,562,088,672 | +0.28% |
| Bytes copied    |  26,943,452,560 |  27,089,972,296 | +0.54% |
| Max residency   |     982,643,440 |     991,663,432 | +0.91% |

* -O2

|                 | GHC HEAD        | This MR         | Diff   |
| --------------- | --------------- | --------------- | ------ |
| Bytes allocated | 291,044,511,408 | 291,863,910,912 | +0.28% |
| Bytes copied    |  37,044,237,616 |  36,121,690,472 | -2.49% |
| Max residency   |   1,071,600,328 |   1,086,396,256 | +1.38% |

Extra compiler allocations
--------------------------

Runtime allocations of programs are as reported above (NoFib section).

The compiler now allocates more than before. Main source of allocation
in this patch compared to base commit is the new SRT algorithm
(GHC.Cmm.Info.Build). Below is some of the extra work we do with this
patch, numbers generated by profiled stage 2 compiler when building a
pathological case (the test 'ManyConstructors') with '-O2':

- We now sort the final STG for a module, which means traversing the
  entire program, generating free variable set for each top-level
  binding, doing SCC analysis, and re-ordering the program. In
  ManyConstructors this step allocates 97,889,952 bytes.

- We now do SRT analysis on static data, which in a program like
  ManyConstructors causes analysing 10,000 bindings that we would
  previously just skip. This step allocates 70,898,352 bytes.

- We now maintain an SRT map for the entire module as we compile Cmm
  groups:

      data ModuleSRTInfo = ModuleSRTInfo
        { ...
        , moduleSRTMap :: SRTMap
        }

   (SRTMap is just a strict Map from the 'containers' library)

   This map gets an entry for most bindings in a module (exceptions are
   THUNKs and CAFFY static functions). For ManyConstructors this map
   gets 50015 entries.

- Once we're done with code generation we generate a NameSet from SRTMap
  for the non-CAFFY names in the current module. This set gets the same
  number of entries as the SRTMap.

- Finally we update CafInfos in ModDetails for the non-CAFFY Ids, using
  the NameSet generated in the previous step. This usually does the
  least amount of allocation among the work listed here.

Only place with this patch where we do less work in the CAF analysis in
the tidying pass (CoreTidy). However that doesn't save us much, as the
pass still needs to traverse the whole program and update IdInfos for
other reasons. Only thing we don't here do is the `hasCafRefs` pass over
the RHS of bindings, which is a stateless pass that returns a boolean
value, so it doesn't allocate much.

(Metric changes blow are all increased allocations)

Metric changes
--------------

Metric Increase:
    ManyAlternatives
    ManyConstructors
    T13035
    T14683
    T1969
    T9961

- - - - -
2a87a565 by Andreas Klebinger at 2020-01-31T12:21:10+03:00
A few optimizations in STG and Cmm parts:

(Guided by the profiler output)

- Add a few bang patterns, INLINABLE annotations, and a seqList in a few
  places in Cmm and STG parts.

- Do not add external variables as dependencies in STG dependency
  analysis (GHC.Stg.DepAnal).

- - - - -
bef704b6 by Simon Peyton Jones at 2020-02-01T02:28:45-05:00
Improve skolemisation

This patch avoids skolemiseUnboundMetaTyVar making
up a fresh Name when it doesn't need to.

See Note [Skolemising and identity]

Improves error messsages for partial type signatures.

- - - - -
cd110423 by Simon Peyton Jones at 2020-02-01T02:28:45-05:00
Improve pretty-printing for TyConBinders

In particular, show their kinds.

- - - - -
913287a0 by Simon Peyton Jones at 2020-02-01T02:28:45-05:00
Fix scoping of TyCon binders in TcTyClsDecls

This patch fixes #17566 by refactoring the way we decide the final
identity of the tyvars in the TyCons of a possibly-recursive nest
of type and class decls, possibly with associated types.

It's all laid out in
  Note [Swizzling the tyvars before generaliseTcTyCon]

Main changes:

* We have to generalise each decl (with its associated types)
  all at once: TcTyClsDecls.generaliseTyClDecl

* The main new work is done in TcTyClsDecls.swizzleTcTyConBndrs

* The mysterious TcHsSyn.zonkRecTyVarBndrs dies altogether

Other smaller things:

* A little refactoring, moving bindTyClTyVars from tcTyClDecl1
  to tcDataDefn, tcSynRhs, etc.  Clearer, reduces the number of
  parameters

* Reduce the amount of swizzling required.
  Specifically, bindExplicitTKBndrs_Q_Tv doesn't need
    to clone a new Name for the TyVarTv, and not
    cloning means that in the vasly common case,
    swizzleTyConBndrs is a no-op

  In detail:
    Rename newTyVarTyVar --> cloneTyVarTyVar
    Add newTyVarTyTyVar that doesn't clone
    Use the non-cloning newTyVarTyVar in
       bindExplicitTKBndrs_Q_Tv
       Rename newFlexiKindedTyVarTyVar
           --> cloneFlexiKindedTyVarTyVar

* Define new utility function and use it
     HsDecls.familyDeclName ::
        FamilyDecl (GhcPass p) -> IdP (GhcPass p)

Updates haddock submodule.

- - - - -
58ed6c4a by Ben Gamari at 2020-02-01T02:29:23-05:00
rts/M32Alloc: Don't attempt to unmap non-existent pages

The m32 allocator's `pages` list may contain NULLs in the case that the
page was flushed. Some `munmap` implementations (e.g. FreeBSD's) don't
like it if we pass them NULL. Don't do that.

- - - - -
859db7d6 by Ömer Sinan Ağacan at 2020-02-01T14:18:49+03:00
Improve/fix -fcatch-bottoms documentation

Old documentation suggests that -fcatch-bottoms only adds a default
alternative to bottoming case expression, but that's not true. We use a
very simplistic "is exhaustive" check and add default alternatives to
any case expression that does not cover all constructors of the type. In
case of GADTs this simple check assumes all constructors should be
covered, even the ones ruled out by the type of the scrutinee.

Update the documentation to reflect this.

(Originally noticed in #17648)

[ci skip]

- - - - -
54dfa94a by John Ericson at 2020-02-03T21:14:24-05:00
Fix docs for FrontendResult

Other variant was removed in ac1a379363618a6f2f17fff65ce9129164b6ef30
but docs were no changed.

- - - - -
5e63d9c0 by John Ericson at 2020-02-03T21:15:02-05:00
Refactor HscMain.finish

I found the old control flow a bit hard to follow; I rewrote it to first
decide whether to desugar, and then use that choice when computing
whether to simplify / what sort of interface file to write.

I hope eventually we will always write post-tc interface files, which
will make the logic of this function even simpler, and continue the
thrust of this refactor.

- - - - -
e580e5b8 by Stefan Schulze Frielinghaus at 2020-02-04T09:29:00-05:00
Do not build StgCRunAsm.S for unregisterised builds

For unregisterised builds StgRun/StgReturn are implemented via a mini
interpreter in StgCRun.c and therefore would collide with the
implementations in StgCRunAsm.S.

- - - - -
e3b0bd97 by Stefan Schulze Frielinghaus at 2020-02-04T09:29:00-05:00
fixup! fixup! Do not build StgCRunAsm.S for unregisterised builds

- - - - -
eb629fab by John Ericson at 2020-02-04T09:29:38-05:00
Delete some superfluous helper functions in HscMain

The driver code is some of the nastiest in GHC, and I am worried about
being able to untangle all the tech debt. In `HscMain` we have a number
of helpers which are either not-used or little used. I delete them so we
can reduce cognative load, distilling the essential complexity away from
the cruft.

- - - - -
c90eca55 by Sebastian Graf at 2020-02-05T09:21:29-05:00
PmCheck: Record type constraints arising from existentials in `PmCoreCt`s

In #17703 (a follow-up of !2192), we established that contrary to my
belief, type constraints arising from existentials in code like

```hs
data Ex where Ex :: a -> Ex
f _ | let x = Ex @Int 15 = case x of Ex -> ...
```

are in fact useful.

This commit makes a number of refactorings and improvements to comments,
but fundamentally changes `addCoreCt.core_expr` to record the type
constraint `a ~ Int` in addition to `x ~ Ex @a y` and `y ~ 15`.

Fixes #17703.

- - - - -
6d3b5d57 by Ömer Sinan Ağacan at 2020-02-05T09:22:10-05:00
testlib: Extend existing *_opts in extra_*_opts

Previously we'd override the existing {run,hc} opts in
extra_{run,hc}_opts, which caused flakiness in T1969, see #17712.

extra_{run,hc}_opts now extends {run,hc} opts, instead of overriding.

Also we shrank the allocation area for T1969 in order to increase
residency sampling frequency.

Fixes #17712

- - - - -
9c89a48d by Ömer Sinan Ağacan at 2020-02-05T09:22:52-05:00
Remove CafInfo-related code from STG lambda lift pass

After c846618ae0 we don't have accurate CafInfos for Ids in the current
module and we're free to introduce new CAFFY or non-CAFFY bindings or
change CafInfos of existing binders; so no we no longer need to
maintain CafInfos in Core or STG passes.

- - - - -
70ddb8bf by Ryan Scott at 2020-02-05T09:23:30-05:00
Add regression test for #17773

- - - - -
e8004e5d by Ben Gamari at 2020-02-05T13:55:19-05:00
gitlab-ci: Allow Windows builds to fail again

Due to T7702 and the process issues described in #17777.
- - - - -
29b72c00 by Ben Gamari at 2020-02-06T11:55:41-05:00
VarSet: Introduce nonDetFoldVarSet

- - - - -
c4e6b35d by Ben Gamari at 2020-02-06T11:55:41-05:00
Move closeOverKinds and friends to TyCoFVs

- - - - -
ed2f0e5c by Simon Peyton Jones at 2020-02-06T11:55:41-05:00
Reform the free variable finders for types

This patch delivers on (much of) #17509.

* Introduces the shallow vs deep free variable distinction

* Introduce TyCoRep.foldType,
    foldType :: Monoid a => TyCoFolder env a
                         -> env -> Type -> a
  and use it in the free variable finders.

* Substitution in TyCoSubst
   * ASSERTs are on for checkValidSubst
   * checkValidSubst uses shallowTyCoVarsOfTypes etc

Quite a few things still to do

* We could use foldType in lots of other places

* We could use mapType for substitution.  (Check that we get
  good code!)

* Some (but not yet all) clients of substitution can now
  save time by using shallowTyCoVarsOfTypes

* All calls to tyCoVarsOfTypes should be inspected; most of
  them should be shallow.  Maybe.

* Currently shallowTyCoVarsOfTypes still returns
  unification variables, but not CoVarHoles.
  Reason: we need to return unification variables
  in some of the calls in TcSimplify, eg when promoting.

* We should do the same thing for tyCoFVsOfTypes, which is
  currently unchanged.

* tyCoFVsOfTypes returns CoVarHoles, because of the
  use in TcSimplify.mkResidualConstraints.  See
  Note [Emitting the residual implication in simplifyInfer]

* #17509 talks about "relevant" variables too.

- - - - -
01a1f4fb by Simon Peyton Jones at 2020-02-06T11:55:41-05:00
Use foldTyCo for noFreeVarsOfType

- - - - -
0e59afd6 by Simon Peyton Jones at 2020-02-06T11:55:41-05:00
Simplify closeOverKinds

- - - - -
9ca5c88e by Simon Peyton Jones at 2020-02-06T11:55:41-05:00
Use foldTyCo for coVarsOfType

- - - - -
5541b87c by Simon Peyton Jones at 2020-02-06T11:55:41-05:00
Use foldTyCo for exactTyCoVarsOfType

This entailed

* Adding a tcf_view field to TyCoFolder

* Moving exactTyCoVarsOtType to TcType.  It properly belongs
  there, since only the typechecker calls this function. But
  it also means that we can "see" and inline tcView.

Metric Decrease:
  T14683

- - - - -
7c122851 by Simon Peyton Jones at 2020-02-06T11:56:02-05:00
Comments only

- - - - -
588acb99 by Adam Sandberg Eriksson at 2020-02-08T10:15:38-05:00
slightly better named cost-centres for simple pattern bindings #17006

```
main = do
  print $ g [1..100] a
  where g xs x   = map (`mod` x) xs
        a :: Int = 324
```

The above program previously attributed the cost of computing 324 to a cost
centre named `(...)`, with this change the cost is attributed to `a` instead.

This change only affects simple pattern bindings (decorated variables: type
signatures, parens, ~ annotations and ! annotations).

- - - - -
309f8cfd by Richard Eisenberg at 2020-02-08T10:16:33-05:00
Remove unnecessary parentheses

- - - - -
7755ffc2 by Richard Eisenberg at 2020-02-08T10:16:33-05:00
Introduce IsPass; refactor wrappers.

There are two main payloads of this patch:

1. This introduces IsPass, which allows e.g. printing
   code to ask what pass it is running in (Renamed vs
   Typechecked) and thus print extension fields. See
   Note [IsPass] in Hs.Extension

2. This moves the HsWrap constructor into an extension
   field, where it rightly belongs. This is done for
   HsExpr and HsCmd, but not for HsPat, which is left
   as an exercise for the reader.

There is also some refactoring around SyntaxExprs, but this
is really just incidental.

This patch subsumes !1721 (sorry @chreekat).

Along the way, there is a bit of refactoring in GHC.Hs.Extension,
including the removal of NameOrRdrName in favor of NoGhcTc.
This meant that we had no real need for GHC.Hs.PlaceHolder, so
I got rid of it.

Updates haddock submodule.

-------------------------
Metric Decrease:
    haddock.compiler
-------------------------

- - - - -
7d452be4 by Dylan Yudaken at 2020-02-08T10:17:17-05:00
Fix hs_try_putmvar losing track of running cap

If hs_try_putmvar was called through an unsafe import, it would lose track of the running cap causing a deadlock

- - - - -
c2e301ae by Ben Gamari at 2020-02-08T10:17:55-05:00
compiler: Qualify imports of Data.List

- - - - -
aede171a by Ben Gamari at 2020-02-08T10:17:55-05:00
testsuite: Fix -Wcompat-unqualified-imports issues

- - - - -
4435a8e0 by Ben Gamari at 2020-02-08T10:17:55-05:00
Introduce -Wcompat-unqualified-imports

This implements the warning proposed in option (B) of the
Data.List.singleton CLC [discussion][].
This warning, which is included in `-Wcompat` is intended to help users
identify imports of modules that will change incompatibly in future GHC
releases. This currently only includes `Data.List` due to the expected
specialisation and addition of `Data.List.singleton`.

Fixes #17244.

[discussion]: https://groups.google.com/d/msg/haskell-core-libraries/q3zHLmzBa5E/PmlAs_kYAQAJ

- - - - -
28b5349a by Ben Gamari at 2020-02-08T10:17:55-05:00
Bump stm and process submodules

- - - - -
7d04b9f2 by Ben Gamari at 2020-02-08T10:18:31-05:00
hadrian: Allow override of Cabal configuration in hadrian.settings

Fixes #17612 by adding a `cabal.configure.opts` key for
`hadrian.settings`.

- - - - -
88bf81aa by Andreas Klebinger at 2020-02-08T10:19:10-05:00
Optimize unpackCString# to allocate less.

unpackCString# is a recursive function which for each iteration
returns a Cons cell containing the current Char, and a thunk for
unpacking the rest of the string.

In this patch we change from storing addr + offset inside this thunk
to storing only the addr, simply incrementing the address on each
iteration.

This saves one word of allocation per unpacked character.
For a program like "main = print "<largishString>" this amounts
to 2-3% fewer % in bytes allocated.

I also removed the now redundant local unpack definitions.
This removes one call per unpack operation.

- - - - -
bec76733 by Ben Gamari at 2020-02-08T10:19:57-05:00
Fix GhcThreaded setting

This adopts a patch from NetBSD's packaging fixing the `GhcThreaded`
option of the make build system. In addition we introduce a `ghcThreaded`
option in hadrian's `Flavour` type.

Also fix Hadrian's treatment of the `Use Threaded` entry in `settings`.
Previously it would incorrectly claim `Use Threaded = True` if we were
building the `threaded` runtime way. However, this is inconsistent with
the `make` build system, which defines it to be whether the `ghc`
executable is linked against the threaded runtime.

Fixes #17692.

- - - - -
545cf1e1 by Ben Gamari at 2020-02-08T10:20:37-05:00
hadrian: Depend upon libray dependencies when configuring packages

This will hopefully fix #17631.

- - - - -
047d3d75 by Ben Gamari at 2020-02-08T10:21:16-05:00
testsuite: Add test for #15316

This is the full testcase for T15316.

- - - - -
768e5866 by Julien Debon at 2020-02-08T10:22:07-05:00
doc(Data.List): Add some examples to Data.List

- - - - -
3900cb83 by Julien Debon at 2020-02-08T10:22:07-05:00
Apply suggestion to libraries/base/GHC/List.hs
- - - - -
bd666766 by Ben Gamari at 2020-02-08T10:22:45-05:00
users-guide: Clarify that bundled patsyns were introduced in GHC 8.0

Closes #17094.

- - - - -
95741ea1 by Pepe Iborra at 2020-02-08T10:23:23-05:00
Update to hie-bios 0.3.2 style program cradle

- - - - -
fb5c1912 by Sylvain Henry at 2020-02-08T10:24:07-05:00
Remove redundant case

This alternative is redundant and triggers no warning when building with 8.6.5

- - - - -
5d83d948 by Matthew Pickering at 2020-02-08T10:24:43-05:00
Add mkHieFileWithSource which doesn't read the source file from disk

cc/ @pepeiborra

- - - - -
dfdae56d by Andreas Klebinger at 2020-02-08T10:25:20-05:00
Rename ghcAssert to stgAssert in hp2ps/Main.h.

This fixes #17763
- - - - -
658f7ac6 by Ben Gamari at 2020-02-08T10:26:00-05:00
includes: Avoid using single-line comments in HsFFI.h

While single-line comments are supported by C99, dtrace on SmartOS
apparently doesn't support them yet.

- - - - -
c95920a6 by Ömer Sinan Ağacan at 2020-02-08T10:26:42-05:00
Import qualified Prelude in parser

This is in preparation of backwards-incompatible changes in happy.
See https://github.com/simonmar/happy/issues/166

- - - - -
b6dc319a by Ömer Sinan Ağacan at 2020-02-08T10:27:23-05:00
Add regression test for #12760

The bug seems to be fixed in the meantime, make sure it stays fixed.

Closes #12760

- - - - -
b3857b62 by Ben Gamari at 2020-02-08T10:28:03-05:00
base: Drop out-of-date comment

The comment in GHC.Base claimed that ($) couldn't be used in that module
as it was wired-in. However, this is no longer true; ($) is merely known
key and is defined in Haskell (with a RuntimeRep-polymorphic type) in
GHC.Base.

The one piece of magic that ($) retains is that it a special typing
rule to allow type inference with higher-rank types
(e.g. `runST $ blah`; see Note [Typing rule for ($)] in TcExpr).

- - - - -
1183ae94 by Daniel Gröber at 2020-02-08T10:29:00-05:00
rts: Fix Arena blocks accounting for MBlock sized allocations

When requesting more than BLOCKS_PER_MBLOCK blocks allocGroup can return a
different number of blocks than requested. Here we use the number of
requested blocks, however arenaFree will subtract the actual number of
blocks we got from arena_blocks (possibly) resulting in a negative value
and triggering ASSERT(arena_blocks >= 0).

- - - - -
97d59db5 by Daniel Gröber at 2020-02-08T10:29:48-05:00
rts: Fix need_prealloc being reset when retainer profiling is on

- - - - -
1f630025 by Krzysztof Gogolewski at 2020-02-09T02:52:27-05:00
Add a test for #15712

- - - - -
2ac784ab by Ben Gamari at 2020-02-09T02:53:05-05:00
hadrian: Add --test-metrics argument

Allowing the test metric output to be captured to a file, a la
the METRIC_FILE environment variable of the make build system.

- - - - -
f432d8c6 by Ben Gamari at 2020-02-09T02:53:05-05:00
hadrian: Fix --test-summary argument

This appears to be a cut-and-paste error.

- - - - -
a906595f by Arnaud Spiwack at 2020-02-09T02:53:50-05:00
Fix an outdated note link

This link appears to have been forgotten in
0dad81ca5fd1f63bf8a3b6ad09787559e8bd05c0 .

- - - - -
3ae83da1 by Alp Mestanogullari at 2020-02-09T02:54:28-05:00
hadrian: Windows fixes (bindists, CI)

This commit implements a few Windows-specific fixes which get us from a CI
job that can't even get as far as starting the testsuite driver, to a state
where we can run the entire testssuite (but have test failures to fix).

- Don't forget about a potential extension for the haddock program, when
  preparing the bindist.
- Build the timeout program, used by the testsuite driver on Windows in place
  of the Python script used elsewhere, using the boot compiler. We could
  alternatively build it with the compiler that we're going to test but this
  would be a lot more tedious to write.
- Implement a wrapper-script less installation procedure for Windows, in
  `hadrian/bindist/Makefile.
- Make dependencies a bit more accurate in the aforementioned Makefile.
- Update Windows/Hadrian CI job accordingly.

This patch fixes #17486.

- - - - -
82f9be8c by Roland Senn at 2020-02-09T02:55:06-05:00
Fix #14628: Panic (No skolem Info) in GHCi

This patch implements the [sugggestion from Simon (PJ)](https://gitlab.haskell.org/ghc/ghc/issues/14628#note_146559):
- Make `TcErrors.getSkolemInfo` return a `SkolemInfo` rather than an `Implication`.
- If `getSkolemInfo` gets `RuntimeUnk`s, just return a new data constructor in `SkolemInfo`, called `RuntimeUnkSkol`.
- In `TcErrors.pprSkols` print something sensible for a `RuntimeUnkSkol`.

The `getSkolemInfo` function paniced while formating suggestions to add type annotations (subfunction `suggestAddSig`)
to a *"Couldn't match type ‘x’ with ‘y’"* error message.
The `getSkolemInfo` function didn't find any Implication value and paniced.
With this patch the `getSkolemInfo` function does no longer panic, if it finds `RuntimeUnkSkol`s.

As the panic occured while processing an error message, we don't need to implement any new error message!

- - - - -
b2e18e26 by Andreas Klebinger at 2020-02-09T02:55:46-05:00
Fix -ddump-stg-final.

Once again make sure this dumps the STG used for codegen.

- - - - -
414e2f62 by Sylvain Henry at 2020-02-09T02:56:26-05:00
Force -fPIC for intree GMP (fix #17799)

Configure intree GMP with `--with-pic` instead of patching it. Moreover
the correct patching was only done for x86_64/darwin (see #17799).

- - - - -
f0fd72ee by Sebastian Graf at 2020-02-09T17:22:38-05:00
8.10 Release notes for improvements to the pattern-match checker [skip ci]

A little late to the game, but better late than never.

- - - - -
00dc0f7e by Ömer Sinan Ağacan at 2020-02-09T17:23:17-05:00
Add regression test for #13142

Closes #13142

- - - - -
f3e737bb by Sebastian Graf at 2020-02-10T20:04:09-05:00
Fix long distance info for record updates

For record updates where the `record_expr` is a variable, as in #17783:

```hs
data PartialRec = No
                | Yes { a :: Int, b :: Bool }
update No = No
update r@(Yes {}) = r { b = False }
```

We should make use of long distance info in
`-Wincomplete-record-updates` checking. But the call to `matchWrapper`
in the `RecUpd` case didn't specify a scrutinee expression, which would
correspond to the `record_expr` `r` here. That is fixed now.

Fixes #17783.

- - - - -
5670881d by Tamar Christina at 2020-02-10T20:05:04-05:00
Fs: Fix UNC remapping code.

- - - - -
375b3c45 by Oleg Grenrus at 2020-02-11T05:07:30-05:00
Add singleton to Data.OldList

- - - - -
de32beff by Richard Eisenberg at 2020-02-11T05:08:10-05:00
Do not create nested quantified constraints

Previously, we would accidentally make constraints like
forall a. C a => forall b. D b => E a b c as we traversed
superclasses. No longer!

This patch also expands Note [Eagerly expand given superclasses]
to work over quantified constraints; necessary for T16502b.

Close #17202 and #16502.

test cases: typecheck/should_compile/T{17202,16502{,b}}

- - - - -
e319570e by Ben Gamari at 2020-02-11T05:08:47-05:00
rts: Use nanosleep instead of usleep

usleep was removed in POSIX.1-2008.

- - - - -
b75e7486 by Ben Gamari at 2020-02-11T05:09:24-05:00
rts: Remove incorrect assertions around MSG_THROWTO messages

Previously we would assert that threads which are sending a
`MSG_THROWTO` message must have their blocking status be blocked on the
message. In the usual case of a thread throwing to another thread this
is guaranteed by `stg_killThreadzh`.  However, `throwToSelf`, used by
the GC to kill threads which ran out of heap, failed to guarantee this.

Noted while debugging #17785.

- - - - -
aba51b65 by Sylvain Henry at 2020-02-11T05:10:04-05:00
Add arithmetic exception primops (#14664)

- - - - -
b157399f by Ben Gamari at 2020-02-11T05:10:40-05:00
configure: Don't assume Gnu linker on Solaris

Compl Yue noticed that the linker was dumping the link map on SmartOS. This is
because Smartos uses the Solaris linker, which uses the `-64` flag, not
`-m64` like Gnu ld, to indicate that it should link for 64-bits. Fix the
configure script to handle the Solaris linker correctly.

- - - - -
d8d73d77 by Simon Peyton Jones at 2020-02-11T05:11:18-05:00
Notes only: telescopes

This documentation-only patch fixes #17793

- - - - -
58a4ddef by Alp Mestanogullari at 2020-02-11T05:12:17-05:00
hadrian: build (and ship) iserv on Windows

- - - - -
82023524 by Matthew Pickering at 2020-02-11T18:04:17-05:00
TemplateHaskellQuotes: Allow nested splices

There is no issue with nested splices as they do not require any compile
time code execution. All execution is delayed until the top-level
splice.

- - - - -
50e24edd by Ömer Sinan Ağacan at 2020-02-11T18:04:57-05:00
Remove Hadrian's copy of (Data.Functor.<&>)

The function was added to base with base-4.11 (GHC 8.4)

- - - - -
f82a2f90 by Sylvain Henry at 2020-02-12T01:56:46-05:00
Document GMP build [skip ci]

- - - - -
da7f7479 by Sylvain Henry at 2020-02-12T01:57:27-05:00
Module hierarchy: ByteCode and Runtime (cf #13009)

Update haddock submodule

- - - - -
04f51297 by Ömer Sinan Ağacan at 2020-02-12T01:58:11-05:00
Fix naming of tests for #12923

- - - - -
31fc3321 by Ömer Sinan Ağacan at 2020-02-12T01:58:11-05:00
Add regression test for #12926

Closes #12926

- - - - -
f0c0ee7d by Krzysztof Gogolewski at 2020-02-12T01:58:51-05:00
Fix order of arguments in specializer (#17801)

See https://gitlab.haskell.org/ghc/ghc/issues/17801#note_253330

No regression test, as it's hard to trigger.

- - - - -
059c3c9d by Sebastian Graf at 2020-02-12T11:00:58+01:00
Separate CPR analysis from the Demand analyser

The reasons for that can be found in the wiki:
https://gitlab.haskell.org/ghc/ghc/wikis/nested-cpr/split-off-cpr

We now run CPR after demand analysis (except for after the final demand
analysis run just before code gen). CPR got its own dump flags
(`-ddump-cpr-anal`, `-ddump-cpr-signatures`), but not its own flag to
activate/deactivate. It will run with `-fstrictness`/`-fworker-wrapper`.

As explained on the wiki page, this step is necessary for a sane Nested
CPR analysis. And it has quite positive impact on compiler performance:

Metric Decrease:
    T9233
    T9675
    T9961
    T15263

- - - - -
f5ffd8d9 by Ben Gamari at 2020-02-12T17:22:37-05:00
base: Expose GHC.Unicode.unicodeVersion

This exposes a Data.Version.Version representing the version of the
Unicode database used by `base`. This should clear up some confusion I
have seen in tickets regarding with which Unicode versions a given GHC
can be expected to work.

While in town I also regenerated (but did not update) the Unicode
database with database 12.0.0. Strangely, the file cited in the README
no longer existed. Consequently, I used
https://www.unicode.org/Public/12.0.0/ucd/UnicodeData.txt and was
slightly surprised to find that there were a few changes.

- - - - -
6c2585e0 by Ben Gamari at 2020-02-12T17:22:37-05:00
base: Update Unicode database to 12.1.0

Using `curl https://www.unicode.org/Public/12.1.0/ucd/UnicodeData.txt |
libraries/base/cbits/ubconfc 12.1.0`.

- - - - -
df084681 by Krzysztof Gogolewski at 2020-02-12T23:58:52+01:00
Always display inferred variables using braces

We now always show "forall {a}. T" for inferred variables,
previously this was controlled by -fprint-explicit-foralls.

This implements part 1 of https://github.com/ghc-proposals/ghc-proposals/pull/179.

Part of GHC ticket #16320.

Furthermore, when printing a levity restriction error, we now display
the HsWrap of the expression. This lets users see the full elaboration with
-fprint-typechecker-elaboration (see also #17670)

- - - - -
16d643cf by Sylvain Henry at 2020-02-13T09:16:04-05:00
Remove -ddump-srts flag

This flag is deemed not useful.

- - - - -
fa28ae95 by Sylvain Henry at 2020-02-13T09:16:04-05:00
Fix flag documentation (#17826)

- - - - -
1bfd8259 by Sylvain Henry at 2020-02-13T09:16:43-05:00
Ensure that Hadrian is built correctly before using it

When Hadrian failed to build, the script would pick a previously built
Hadrian (if available) instead of failing.

- - - - -
cd6e786a by Ömer Sinan Ağacan at 2020-02-14T05:29:56-05:00
Add test for #17648

- - - - -
9f2c3677 by Sylvain Henry at 2020-02-14T05:30:39-05:00
GMP expects the Target platform as --host parameter

- - - - -
aa6086fd by Oleg Grenrus at 2020-02-14T05:31:16-05:00
Add explicit LANGUAGE Safe to template-haskell


(cherry picked from commit a5e0f376821ca882880b03b07b451aa574e289ec)
- - - - -
af6a0c36 by Ben Gamari at 2020-02-14T05:31:53-05:00
hadrian: Add execution and target architecture to stage-compilation figure

- - - - -
cf739945 by Sylvain Henry at 2020-02-14T05:32:37-05:00
Module hierarchy: HsToCore (cf #13009)

- - - - -
719db318 by Simon Peyton Jones at 2020-02-14T05:33:16-05:00
De-duplicate overlapping Notes

Documentation only.  Fixes #17827

- - - - -
7550417a by Sylvain Henry at 2020-02-14T05:33:56-05:00
Hadrian: drop Sphinx flag checking for PDF documentation (#17825)

It seems that Sphinx produces the ghc-flags.txt in
doc/users_guide/_build rather than pdfRoot. We could copy ghc-flags.txt
into pdfRoot (like happens naturally in the HTML case) but the benefit
is pretty small. Let's just only check the HTML case.

- - - - -
813842f4 by Ben Gamari at 2020-02-14T10:16:36-05:00
make: Be more selective in building windows-extra-src tarball

- - - - -
0725f4bb by Ben Gamari at 2020-02-14T10:16:36-05:00
Rework handling of win32 toolchain tarballs

- - - - -
565ce7ae by Ben Gamari at 2020-02-14T10:16:36-05:00
gitlab-ci: Consolidate CI logic

This moves nearly all of the CI logic to .gitlab/ci.sh. This improves
things in a number of ways:

 * it's harder for inconsistencies to arise between architectures
 * it's easier to share logic between architectures
 * on Windows, it's easier to ensure that all CI steps are executed from
   within a properly initialized mingw session.

While in town I also add a FreeBSD build job and update the Windows job
to use the gitlab-runner PowerShell executor, since cmd.exe will be
deprecated soon (fixing #17699).

- - - - -
9cbace74 by Ben Gamari at 2020-02-14T10:16:36-05:00
gitlab-ci: Deduplicate nightly job configuration

- - - - -
6e837144 by Ben Gamari at 2020-02-14T10:16:36-05:00
integer-gmp: Fix unused command-line argument

-L is only needed during linking.

- - - - -
e5ee07ab by Ben Gamari at 2020-02-14T10:16:36-05:00
testsuite: Don't ask sed to operate in-place on symlinks

Some sed implementations (e.g. FreeBSD) refuse to operate in-place on
symlinks.

- - - - -
71e5e68f by Ben Gamari at 2020-02-14T10:16:36-05:00
testsuite: Disable tests that assume name of libstdc++ on FreeBSD

- - - - -
7b2da0f4 by Ben Gamari at 2020-02-14T10:16:36-05:00
testsuite: Mark T6132 as broken on FreeBSD

- - - - -
8ef7a15a by Ben Gamari at 2020-02-14T10:16:36-05:00
testsuite/T16930: Don't rely on gnu grep specific --include

In BSD grep this flag only affects directory recursion.

- - - - -
6060003e by Ben Gamari at 2020-02-14T10:16:36-05:00
Pass -Wno-unused-command-line-arguments during link on FreeBSD

FreeBSD cc throws a warning if we pass -pthread without actually using
any pthread symbols.

- - - - -
97497bae by Ben Gamari at 2020-02-14T10:16:36-05:00
base: Always clamp reads/writes to 2GB in length

Previously we did this only on Darwin due to #17414. However, even on
other platforms >2GB writes are on shaky ground. POSIX explicitly says
that the result is implementation-specified and Linux will write at most
0x7ffff000, even on 64-bit platforms. Moreover, getting the sign
of the syscall result correct is tricky, as demonstrated by the fact
that T17414 currently fails on FreeBSD.

For simplicity we now just uniformly clamp to 0x7ffff000 on all
platforms.

- - - - -
49be2a3f by Ben Gamari at 2020-02-14T10:16:36-05:00
configure: Fix sphinx version test

The check for the "v" prefix is redundant.

- - - - -
f7f7a556 by Ben Gamari at 2020-02-14T10:16:37-05:00
users-guide: Fix unknown link targets

- - - - -
a204102c by Ben Gamari at 2020-02-14T10:16:37-05:00
docs/compare-flags: Don't use python f-strings

- - - - -
92e15a37 by Ben Gamari at 2020-02-14T10:16:37-05:00
gitlab-ci: Fix various shellcheck warnings

- - - - -
459f7c6e by Ben Gamari at 2020-02-14T10:16:37-05:00
hadrian: Drop empty arguments from target list

Fixes #17748.

- - - - -
c06df28d by Ben Gamari at 2020-02-14T10:16:37-05:00
users-guide: Fix "invalid file" failure

I have no idea how this worked previously. Different Python version?

- - - - -
3fe8444f by Ben Gamari at 2020-02-14T10:16:59-05:00
testsuite: Mark T7702 as fragile on Windows

Due to #16799. There was previously an attempt to mark it as broken but
the `opsys` name was incorrect.

- - - - -
fe02f781 by Ben Gamari at 2020-02-14T10:16:59-05:00
testsuite: Assert the opsys names are known

Previously opsys would take any string. This meant it was very easy for
a typo to silently render the predicate ineffective. Fix this by
checking the given operating system name against a list of known values.

- - - - -
149e2a3a by Ben Gamari at 2020-02-14T10:16:59-05:00
compare-flags: Don't rely on encoding flag of subprocess.check_output

Apparently it isn't supported by some slightly older Python versions.

- - - - -
798d59f6 by Ben Gamari at 2020-02-14T10:16:59-05:00
rts: Add more debug output to failed path in onIOComplete

This will help track down #17035.

- - - - -
e35f3f98 by Ben Gamari at 2020-02-14T10:16:59-05:00
gitlab-ci: Allow i386 Windows builds to fail again

Due to the resistance of #17736 to resolution.

- - - - -
261a3cf8 by Ben Gamari at 2020-02-14T10:17:00-05:00
gitlab-ci: Build integer-simple job in the validate flavour

- - - - -
b613a961 by Ben Gamari at 2020-02-14T10:17:00-05:00
gitlab-ci: Always use mingw64 python on Windows

- - - - -
1bc8c8cd by Ben Gamari at 2020-02-14T10:17:00-05:00
gitlab-ci: Allow Windows build to fail due to #17777

The fact that `exec` isn't POSIX compliant means that things can break
in arbitrarily bad ways. Sometimes things happen to work correctly but
sadly this isn't always the case.

- - - - -
ac63020d by Ben Gamari at 2020-02-14T10:17:00-05:00
gitlab-ci: Drop unnecessary GHC_VERSION check

- - - - -
6926f369 by Ben Gamari at 2020-02-14T10:17:00-05:00
Bump process submodule

Folds in the second part of Phyx's Windows process exit fixes [1],
hopefully finally resolving issue #17480.

[1] https://github.com/haskell/process/pull/160

- - - - -
584eee71 by Tamar Christina at 2020-02-14T10:17:00-05:00
SysTools: Use "process job" when spawning processes on Windows

GHC should make calls using process jobs when calling out to GCC and LD.
The reason is these use the exec () family of posix functions.  Window's
process model doesn't allow replacement of processes so this is emulated
by creating a new process and immediately exiting the old one.  Because
of this when using normal Windows wait functions you would return even
without the child process having finished.  In this case if you are
depending on data from the child you will enter a race condition.

The usual fix for this is to use process jobs and wait for the
termination of all children that have ever been spawn by the process you
called. But also waiting for the freeing of all resources.

- - - - -
ecabfa28 by Tamar Christina at 2020-02-14T10:17:00-05:00
Revert "compiler: Disable atomic renaming on Windows"

The original reason this was disabled should be fixed by the previous
commit.

This reverts commit 1c1b63d63efe8b0f789aa7d5b87cfac3edd213eb.

- - - - -
06d60c66 by Ben Gamari at 2020-02-14T10:17:00-05:00
Bump Cabal submodule

- - - - -
8cabb384 by Ben Gamari at 2020-02-14T10:17:00-05:00
compare-flags: Fix output

- - - - -
8cf646d3 by Ben Gamari at 2020-02-14T10:17:00-05:00
users-guide: Document -ddump-srts

- - - - -
932307a5 by Ben Gamari at 2020-02-14T10:17:00-05:00
users-guide: Fix broken reference

- - - - -
e77818de by Ben Gamari at 2020-02-15T09:26:55-05:00
Accept performance changes

These manifested in the integer-simple job.

Metric Decrease:
    T12227
    T5549
    T14936
    T4830
    Conversions
    T5237
    T8766
    T4801
    T10359

Metric Increase:
    T12234
    T6048
    T3294
    T14683
    T3064
    T9872b
    T9872c
    T783
    T5837
    T10678
    T14697
    T5631
    T9203
    T13719
    T12707
    T13056
    T9630
    T10547
    T9872d
    T1969
    WWRec
    T10370
    T5321FD
    haddock.Cabal
    T5642
    T9872a
    T15263
    T12425
    MultiLayerModules
    T5205
    T9233
    T13379
    haddock.base
    T9020
    T13035
    T12150
    T9961

- - - - -
785008c1 by Ben Gamari at 2020-02-15T09:30:13-05:00
testsuite: Sort test names in expected change output

- - - - -
9e851472 by Ömer Sinan Ağacan at 2020-02-16T10:38:41+03:00
Revert "users-guide: Document -ddump-srts"

This reverts commit 8cf646d36b02b8ea1c289cb52781c9171853b514.

The flag was removed by 16d643cf.

[ci skip]

- - - - -
9792c816 by Ben Gamari at 2020-02-16T09:47:08-05:00
testsuite: Probe whether symlinks are usable on Windows

Closes #17706.

- - - - -
ee1e5342 by Vladislav Zavialov at 2020-02-16T09:47:44-05:00
Fix the "unused terminals: 2" warning in Parser.y

- - - - -
b4a8ce52 by Roland Senn at 2020-02-18T20:14:42-05:00
If a :reload finds syntax errors in the module graph, remove the loaded modules. (Fixes #17549)

The processing in `compiler/main/GhcMake.hs` computes the ModuleGraph. If it finds errors
in the module header or in the import specifications, then the new module graph is
incomplete and should not be used.
The code before #17549 just reported the errors and left the old ModuleGraph in place.
The new code of this MR replaces the old ModuleGraph with an empty one.

- - - - -
d7029cc0 by Sylvain Henry at 2020-02-18T20:15:30-05:00
Hadrian: refactor GMP in-tree build support (#17756)

* Hadrian doesn't use integer-gmp/config.mk file anymore to determine if
  building GMP in-tree is required.

  "config.mk" is created by Cabal when the integer-gmp package is
  configured and this file is still untracked by Hadrian. This led to a
  tricky configure "race" because "config.mk" is built by the
  "setup-config" rule, but this rule is also used to find dependencies,
  in particular the "ghc-gmp.h" header, but the creation of this file
  was depending (without being tracked) on "config.mk".

  Now Hadrian only builds in-tree GMP if `--with-intree-gmp` is passed
  to the top-level configure script.

* in-tree GMP isn't built once for all in a fixed stage (Stage1)
  anymore. It is built per stage which is required if we build a
  cross-compiler

* switching between in-tree and external GMP is now supported without
  having to clean the build directory first.

* "wrappers.c" now includes "ghc-gmp.h" instead of "ghc.h". It
  helps ensuring that the build system generates "ghc-gmp.h".

* build in-tree GMP in "<root>/stageN/gmp/gmpbuild" and produce useful
  artefacts (libgmp.a, gmp.h, objs/*.o) in "<root>/stageN/gmp"

- - - - -
40d917fb by Vladislav Zavialov at 2020-02-18T20:16:07-05:00
Remove the MonadFail P instance

There were two issues with this instance:

* its existence meant that a pattern match failure in the P monad would
  produce a user-visible parse error, but the error message would not be
  helpful to the user

* due to the MFP migration strategy, we had to use CPP in Lexer.x,
  and that created issues for #17750

Updates haddock submodule.

- - - - -
5a1ce45d by Joshua Price at 2020-02-18T20:16:47-05:00
Fix unboxed tuple size limit (#17837)

- - - - -
192caf58 by Vladislav Zavialov at 2020-02-18T20:17:24-05:00
Fix testsuite driver output (#17847)

- - - - -
1500f089 by Sylvain Henry at 2020-02-18T20:18:12-05:00
Modules: Llvm (#13009)

- - - - -
d53e81c0 by Niklas Hambüchen at 2020-02-20T10:36:22-05:00
8.10 Release notes for atomic .o writes [skip ci]

- - - - -
19680ee5 by Niklas Hambüchen at 2020-02-20T10:37:53-05:00
8.10 Release notes for --disable-delayed-os-memory-return [skip ci]

- - - - -
74ad75e8 by Simon Peyton Jones at 2020-02-20T21:17:57-05:00
Re-implement unsafe coercions in terms of unsafe equality proofs

(Commit message written by Omer, most of the code is written by Simon
and Richard)

See Note [Implementing unsafeCoerce] for how unsafe equality proofs and
the new unsafeCoerce# are implemented.

New notes added:

- [Checking for levity polymorphism] in CoreLint.hs
- [Implementing unsafeCoerce] in base/Unsafe/Coerce.hs
- [Patching magic definitions] in Desugar.hs
- [Wiring in unsafeCoerce#] in Desugar.hs

Only breaking change in this patch is unsafeCoerce# is not exported from
GHC.Exts, instead of GHC.Prim.

Fixes #17443
Fixes #16893

NoFib
-----

--------------------------------------------------------------------------------
        Program           Size    Allocs    Instrs     Reads    Writes
--------------------------------------------------------------------------------
             CS          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
            CSD          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
             FS          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
              S          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
             VS          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
            VSD          -0.1%      0.0%     -0.0%     -0.0%     -0.1%
            VSM          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
           anna          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
           ansi          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
           atom          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
         awards          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
         banner          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
     bernouilli          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
   binary-trees          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
          boyer          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
         boyer2          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
           bspt          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
      cacheprof          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
       calendar          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
       cichelli          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
        circsim          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
       clausify          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
  comp_lab_zift          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
       compress          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
      compress2          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
    constraints          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
   cryptarithm1          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
   cryptarithm2          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
            cse          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
   digits-of-e1          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
   digits-of-e2          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
         dom-lt          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
          eliza          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
          event          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
    exact-reals          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
         exp3_8          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
         expert          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
 fannkuch-redux          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
          fasta          -0.1%      0.0%     -0.5%     -0.3%     -0.4%
            fem          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
            fft          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
           fft2          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
       fibheaps          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
           fish          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
          fluid          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
         fulsom          -0.1%      0.0%     +0.0%     +0.0%     +0.0%
         gamteb          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
            gcd          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
    gen_regexps          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
         genfft          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
             gg          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
           grep          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
         hidden          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
            hpg          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
            ida          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
          infer          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
        integer          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
      integrate          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
   k-nucleotide          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
          kahan          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
        knights          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
         lambda          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
     last-piece          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
           lcss          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
           life          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
           lift          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
         linear          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
      listcompr          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
       listcopy          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
       maillist          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
         mandel          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
        mandel2          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
           mate          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
        minimax          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
        mkhprog          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
     multiplier          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
         n-body          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
       nucleic2          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
           para          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
      paraffins          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
         parser          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
        parstof          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
            pic          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
       pidigits          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
          power          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
         pretty          -0.1%      0.0%     -0.1%     -0.1%     -0.1%
         primes          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
      primetest          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
         prolog          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
         puzzle          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
         queens          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
        reptile          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
reverse-complem          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
        rewrite          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
           rfib          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
            rsa          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
            scc          -0.1%      0.0%     -0.1%     -0.1%     -0.1%
          sched          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
            scs          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
         simple          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
          solid          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
        sorting          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
  spectral-norm          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
         sphere          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
         symalg          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
            tak          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
      transform          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
       treejoin          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
      typecheck          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
        veritas          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
           wang          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
      wave4main          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
   wheel-sieve1          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
   wheel-sieve2          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
           x2n1          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
--------------------------------------------------------------------------------
            Min          -0.1%      0.0%     -0.5%     -0.3%     -0.4%
            Max          -0.0%      0.0%     +0.0%     +0.0%     +0.0%
 Geometric Mean          -0.1%     -0.0%     -0.0%     -0.0%     -0.0%

Test changes
------------

- break006 is marked as broken, see #17833
- The compiler allocates less when building T14683 (an unsafeCoerce#-
  heavy happy-generated code) on 64-platforms. Allocates more on 32-bit
  platforms.
- Rest of the increases are tiny amounts (still enough to pass the
  threshold) in micro-benchmarks. I briefly looked at each one in a
  profiling build: most of the increased allocations seem to be because
  of random changes in the generated code.

Metric Decrease:
    T14683

Metric Increase:
    T12150
    T12234
    T12425
    T13035
    T14683
    T5837
    T6048

Co-Authored-By: Richard Eisenberg <rae at cs.brynmawr.edu>
Co-Authored-By: Ömer Sinan Ağacan <omeragacan at gmail.com>

- - - - -
6880d6aa by Sylvain Henry at 2020-02-20T21:18:48-05:00
Disentangle DynFlags and SDoc

Remove several uses of `sdocWithDynFlags`. The remaining ones are mostly
CodeGen related (e.g. depend on target platform constants) and will be
fixed separately.

Metric Decrease:
   T12425
   T9961
   WWRec
   T1969
   T14683

- - - - -
70a90110 by Julien Debon at 2020-02-20T21:19:27-05:00
doc(List): Add examples to GHC.List

* Add examples
* Cleanup documentation
* Clarify merge process and Marge bot

- - - - -
c8439fc7 by Peter Trommler at 2020-02-20T21:20:05-05:00
Fix testsuite on powerpc64le

Remove expect broken on recomp tests, #11260 was closed
by !2264 and #11323 most likely by !2264 as well.

GHCi scripts tests work on GHCi but not the external interpreter,
adjust test configuration accordingly. Fixes unexpected passes.

Mark test requiring DWARF expect fail on powerpc64[le] for #11261.

- - - - -
65b7256a by Ömer Sinan Ağacan at 2020-02-20T21:20:45-05:00
Use concatMap(M) instead of `concat . map` and the monadic variant

- - - - -
8b76d457 by Roland Senn at 2020-02-20T21:21:28-05:00
Fix #17832: Weird handling of exports named main in 8.10-rc1

Switching from `lookupGlobalOccRn_maybe` to `lookupInfoOccRn`
to check whether a `main` function is in scope. Unfortunately
`lookupGlobalOccRn_maybe` complains if there are multiple `main`
functions in scope.

- - - - -
466e1ad5 by Krzysztof Gogolewski at 2020-02-20T21:22:11-05:00
Use TTG for HsSplicedT constructor

The constructor HsSplicedT occurs only in the GhcTc pass.
This enforces this fact statically via TTG.

- - - - -
4e622fca by Alexis King at 2020-02-20T21:22:49-05:00
Normalize types when dropping absent arguments from workers

fixes #17852

- - - - -
a533e547 by Adam Sandberg Eriksson at 2020-02-20T21:23:31-05:00
Mention users guide and release notes in merge request template
- - - - -
05251b17 by Ben Gamari at 2020-02-20T21:24:08-05:00
gitlab-ci: Fix typo in BIN_DIST_PREP_TAR_COMP variable name
- - - - -
f44c7e67 by Ben Gamari at 2020-02-20T21:24:46-05:00
gitlab-ci: Avoid duplicating ~/.cabal contents with every build

Previously our attempt to cache the cabal store would
`cp cabal-cache ~/.cabal`. However, if the latter already
 existed this meant that we would end up with
~/.cabal/cabal-cache. Not only would this not help caching
but it would exponentially grow the size of ~/.cabal. Not
good!
- - - - -
c5ec9965 by Ben Gamari at 2020-02-20T21:56:13-05:00
GHC.Hs.Extension: Use Type instead of *

- - - - -
89cb4cc4 by Ben Gamari at 2020-02-20T21:56:13-05:00
Use Type instead of * in GHC

- - - - -
04eb0d6c by Ben Gamari at 2020-02-20T21:56:13-05:00
Enable -Wstar-is-type in -Wall

As noted in [proposal 0143][proposal] this is supposed to happen in
8.12.

Also fix an incorrect claim in the users guide that -Wstar-is-type is
enabled by default.

[proposal]: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0143-remove-star-kind.rst

- - - - -
6de966f1 by Andreas Klebinger at 2020-02-20T21:56:15-05:00
Fix #17724 by having occAnal preserve used bindings.

It sometimes happened that occAnal would remove bindings
as dead code by relying on bindings to be in dependency
order. The fix was contributed by SPJ.

- - - - -
abd7f962 by Ben Gamari at 2020-02-20T21:56:15-05:00
users-guide: Mention dependency on `exceptions` in release notes

Fixes #17845.

- - - - -
58175379 by Sylvain Henry at 2020-02-20T21:56:20-05:00
Hadrian: minor GMP refactoring

Somehow I forgot to totally remove `gmpContext` in
d7029cc09edc052c2f97effe33233c53340fcce0. This patch fixes it and adds
some additional comments.

- - - - -
33fa8d94 by Ryan Scott at 2020-02-20T21:56:21-05:00
Generalize liftData to work over any Quote (#17857)

The Overloaded Quotations proposal generalized the type of `lift`
to work over any `Quote`, but not the type of `liftData`, leading
to #17857. Thankfully, generalizing `liftData` is extremely
straightforward.

Fixes #17857.

- - - - -
3cea6795 by Sylvain Henry at 2020-02-20T21:56:23-05:00
Make: fix sdist target (#17848)

- - - - -
e2cce997 by Sylvain Henry at 2020-02-20T21:56:23-05:00
Hadrian: fix source-dist target (#17849)

- - - - -
0a4c89b2 by Matthew Pickering at 2020-02-21T20:44:45-05:00
Special case `mkTyConApp liftedTypeKind []`

We really need to make sure that these are shared because otherwise GHC
will allocate thousands of identical `TyConApp` nodes.

See #17292

-------------------------
Metric Decrease:
    haddock.Cabal
    T14683
-------------------------

- - - - -
0482f58a by Matthew Pickering at 2020-02-21T20:45:21-05:00
TH: wrapGenSyns, don't split the element type too much

The invariant which allowed the pervious method of splitting the type of
the body to find the type of the elements didn't work in the new
overloaded quotation world as the type can be something like
`WriterT () m a` rather than `Q a` like before.

Fixes #17839

- - - - -
be7068a6 by Vladislav Zavialov at 2020-02-21T20:45:59-05:00
Parser API annotations: RealSrcLoc

During parsing, GHC collects lexical information about AST nodes and
stores it in a map. It is needed to faithfully restore original source
code, e.g. compare these expressions:

	a =  b
	a  = b

The position of the equality sign is not recorded in the AST, so it must
be stored elsewhere.

This system is described in Note [Api annotations].

Before this patch, the mapping was represented by:

	Map (SrcSpan, AnnKeywordId) SrcSpan

After this patch, the mapping is represented by:

	Map (RealSrcSpan, AnnKeywordId) RealSrcSpan

The motivation behind this change is to avoid using the Ord SrcSpan
instance (required by Map here), as it interferes with #17632 (see the
discussion there).

SrcSpan is isomorphic to  Either String RealSrcSpan,  but we shouldn't
use those strings as Map keys. Those strings are intended as hints to
the user, e.g. "<interactive>" or "<compiler-generated code>", so they
are not a valid way to identify nodes in the source code.

- - - - -
240f5bf6 by Sylvain Henry at 2020-02-21T20:46:40-05:00
Modules: Driver (#13009)

submodule updates: nofib, haddock

- - - - -
9d094111 by Sylvain Henry at 2020-02-21T20:47:19-05:00
Hadrian: `docs` rule needs `configure` (#17840)

- - - - -
1674353a by Ben Gamari at 2020-02-23T17:31:19-05:00
fs: Port fixes from ghc-jailbreak repository

* Override rename, unlink, and remove
* Factor out wchar conversion

- - - - -
853210f2 by Adam Sandberg Ericsson at 2020-02-23T17:32:03-05:00
show gcc linker options in configure summary

- - - - -
2831544a by Adam Sandberg Ericsson at 2020-02-23T17:32:44-05:00
hadrian: docs depend on stage1 ghc

- - - - -
1d9df9e0 by Adam Sandberg Ericsson at 2020-02-23T17:33:23-05:00
ci: after 5ce63d52fed the linux bindist for doc-tarball has changed name

- - - - -
26e8fff3 by Vladislav Zavialov at 2020-02-24T02:05:30-05:00
Remove Ord SrcLoc, Ord SrcSpan

Before this patch, GHC relied on Ord SrcSpan to identify source elements, by
using SrcSpan as Map keys:

	blackList :: Map SrcSpan ()      -- compiler/GHC/HsToCore/Coverage.hs
	instanceMap :: Map SrcSpan Name  -- compiler/GHC/HsToCore/Docs.hs

Firstly, this design is not valid in presence of UnhelpfulSpan, as it
distinguishes between  UnhelpfulSpan "X"  and  UnhelpfulSpan "Y", but those
strings are messages for the user, unfit to serve as identifiers for source
elements.

Secondly, this design made it hard to extend SrcSpan with additional data.
Recall that the definition of SrcSpan is:

	data SrcSpan =
	    RealSrcSpan !RealSrcSpan
	  | UnhelpfulSpan !FastString

Say we want to extend the RealSrcSpan constructor with additional information:

	data SrcSpan =
	    RealSrcSpan !RealSrcSpan !AdditionalInformation
	  | UnhelpfulSpan !FastString

	getAdditionalInformation :: SrcSpan -> AdditionalInformation
	getAdditionalInformation (RealSrcSpan _ a) = a

Now, in order for  Map SrcSpan  to keep working correctly, we must *ignore* additional
information when comparing SrcSpan values:

	instance Ord SrcSpan where
	  compare (RealSrcSpan r1 _) (RealSrcSpan r2 _) = compare r1 r2
	  ...

However, this would violate an important law:

	a == b  therefore  f a == f b

Ignoring  AdditionalInformation  in comparisons would mean that with
f=getAdditionalInformation, the law above does not hold.

A more robust design is to avoid  Ord SrcSpan  altogether, which is what this patch implements.
The mappings are changed to use RealSrcSpan instead:

	blackList :: Set RealSrcSpan         -- compiler/GHC/HsToCore/Coverage.hs
	instanceMap :: Map RealSrcSpan Name  -- compiler/GHC/HsToCore/Docs.hs

All SrcSpan comparisons are now done with explicit comparison strategies:

	SrcLoc.leftmost_smallest
	SrcLoc.leftmost_largest
	SrcLoc.rightmost_smallest

These strategies are not subject to the law mentioned above and can easily
discard both the string stored in  UnhelpfulSpan  and  AdditionalInformation.

Updates haddock submodule.

- - - - -
5aa6c188 by Ben Gamari at 2020-02-24T02:06:09-05:00
users-guide: Shuffle text

- - - - -
e3f17413 by Ben Gamari at 2020-02-24T02:06:09-05:00
users-guide: Drop old release notes

- - - - -
84dd9610 by Ben Gamari at 2020-02-24T02:06:09-05:00
Bump directory submodule to 1.3.6.0

- - - - -
e295a024 by Stefan Pavikevik at 2020-02-24T20:53:44-05:00
check for safe arguments, raising error when invalid (fix #17720)

- - - - -
354e2787 by Krzysztof Gogolewski at 2020-02-24T20:54:35-05:00
Comments, small refactor

* Remove outdated Note [HsForAllTy tyvar binders] and [Context quantification].
  Since the wildcard refactor 1e041b7382, HsForAllTy no longer has an flag
  controlling explicity. The field `hsq_implicit` is gone too.
  The current situation is covered by Note [HsType binders] which is already
  linked from LHsQTyVars.
* Small refactor in CoreLint, extracting common code to a function
* Remove "not so sure about WpFun" in TcEvidence, per Richard's comment
  https://gitlab.haskell.org/ghc/ghc/merge_requests/852#note_223226
* Use mkIfThenElse in Foreign/Call, as it does exactly what we need.

- - - - -
1b1067d1 by Sylvain Henry at 2020-02-24T20:55:25-05:00
Modules: CmmToAsm (#13009)

- - - - -
621468f6 by Alexis King at 2020-02-26T15:08:09-05:00
Treat coercions as arguments for floating and inlining

This reverts commit 8924224ecfa065ebc67b96a90d01cf9d2edd0e77
and fixes #17787.

- - - - -
def486c9 by Ben Gamari at 2020-02-26T15:08:47-05:00
hadrian: Allow libnuma library path to be specified

- - - - -
ed03d4e7 by Ben Gamari at 2020-02-26T15:08:47-05:00
hadrian: Refactor gmp arguments

Move the gmp configuration to its own binding.

- - - - -
09b88384 by Ben Gamari at 2020-02-26T15:08:47-05:00
hadrian: Tell Cabal about integer-gmp library location

- - - - -
161e08c5 by Krzysztof Gogolewski at 2020-02-26T15:09:30-05:00
Remove dead code

* FailablePattern can no longer be created since ab51bee40c82
  Therefore, Opt_WarnMissingMonadFailInstances has no effect anymore.
* XWrap is no longer used, it was moved to an extension field

- - - - -
e0d09db3 by Ben Gamari at 2020-02-26T15:10:09-05:00
gitlab-ci: Use 8.8.3 to bootstrap on Windows

This should fix #17861.

- - - - -
972bcf3a by Ben Gamari at 2020-02-26T15:10:09-05:00
testsuite: Fix symlink test

Needs to `write` bytes, not str.

- - - - -
273e60de by Ben Gamari at 2020-02-26T15:10:09-05:00
gitlab-ci: Add shell subcommand for debugging within CI environment

- - - - -
43b13ed3 by Ben Gamari at 2020-02-26T15:10:09-05:00
gitlab-ci: Fix colors on Darwin

Darwin sh doesn't support \e.

- - - - -
217546a7 by Ben Gamari at 2020-02-26T15:10:09-05:00
testsuite: Flush stdout buffers in InitEventLogging

Otherwise we are sensitive to libc's buffering strategy.
Similar to the issue fixed in 543dfaab166c81f46ac4af76918ce32190aaab22.

- - - - -
c7d4fa55 by Ben Gamari at 2020-02-26T15:10:09-05:00
gitlab-ci: Add run_hadrian subcommand

I've ruined two trees already by failing to pass --flavour to hadrian.
Let's factor this out so it can be reused during troubleshooting.

- - - - -
7dc54873 by Ben Gamari at 2020-02-26T15:10:09-05:00
testsuite: Allow tests to be marked as broken on the command line

This allows us to work-around distribution-specific breakage easily.

- - - - -
25e2458e by Ben Gamari at 2020-02-26T15:10:09-05:00
hadrian: Add --broken-test flag

This exposes the flag of the same name supported by the testsuite
driver.

- - - - -
55769996 by Ben Gamari at 2020-02-26T15:10:09-05:00
gitlab-ci: Mark some tests as broken on Alpine

- - - - -
9ee7f87d by Ben Gamari at 2020-02-26T15:10:09-05:00
SysTools: Don't use process jobs if they are broken

- - - - -
bfaa3961 by Ben Gamari at 2020-02-26T15:10:09-05:00
Bump hsc2hs submodule

Fixes name of C compiler.

- - - - -
b2b49a0a by Ben Gamari at 2020-02-26T15:10:09-05:00
testsuite: Make hasMetricsFile RHS more descriptive

- - - - -
817f93ea by Sylvain Henry at 2020-02-26T15:10:58-05:00
Modules: Core (#13009)

Update haddock submodule

- - - - -
74311e10 by Sebastian Graf at 2020-02-27T16:22:45-05:00
PmCheck: Implement Long-distance information with Covered sets

Consider

```hs
data T = A | B | C

f :: T -> Int
f A = 1
f x = case x of
  A -> 2
  B -> 3
  C -> 4
```

Clearly, the RHS returning 2 is redundant. But we don't currently see
that, because our approximation to the covered set of the inner case
expression just picks up the positive information from surrounding
pattern matches. It lacks the context sensivity that `x` can't be `A`
anymore!

Therefore, we adopt the conceptually and practically superior approach
of reusing the covered set of a particular GRHS from an outer pattern
match. In this case, we begin checking the `case` expression with the
covered set of `f`s second clause, which encodes the information that
`x` can't be `A` anymore. After this MR, we will successfully warn about
the RHS returning 2 being redundant.

Perhaps surprisingly, this was a great simplification to the code of
both the coverage checker and the desugarer.

Found a redundant case alternative in `unix` submodule, so we have to
bump it with a fix.

Metric Decrease:
    T12227

- - - - -
59c023ba by Adam Sandberg Ericsson at 2020-02-27T16:23:25-05:00
configure: correctly generate LIBRARY_template_haskell_VERSION

- - - - -
9be82389 by Krzysztof Gogolewski at 2020-02-28T02:35:35-05:00
boot: Remove remote origin check

Previously, we used relative paths in submodules. When cloning from
GitHub, they had to be manually tweaked.
Since a76b233d we use absolute paths, so this workaround can be removed.

- - - - -
f4b6b594 by Ben Gamari at 2020-02-28T02:36:12-05:00
nonmoving: Fix marking in compact regions

Previously we were tracing the object we were asked to mark, even if it
lives in a compact region. However, there is no need to do this; we need
only to mark the region itself as live.

I have seen a segfault due to this due to the concurrent mark seeing a
an object in the process of being compacted by the mutator.

- - - - -
f97d1fb6 by Alp Mestanogullari at 2020-02-28T02:36:59-05:00
base: use an explicit import list in System.Environment.ExecutablePath

This was making -Werror builds fail on Windows (at least with Hadrian).

- - - - -
66f5d6d6 by Simon Peyton Jones at 2020-02-28T22:03:23-05:00
Improve error handling for VTA + deferred type errors

This fixes #17792

See Note [VTA for out-of-scope functions] in TcExpr

- - - - -
37f12603 by Ilias Tsitsimpis at 2020-02-28T22:04:04-05:00
llvm-targets: Add arm-unknown-linux-gnueabi

Add arm-unknown-linux-gnueabi, which is used by Debian's ARM EABI port
(armel), as an LLVM target.

- - - - -
327b29e1 by Vladislav Zavialov at 2020-02-29T05:06:31-05:00
Monotonic locations (#17632)

When GHC is parsing a file generated by a tool, e.g. by the C preprocessor, the
tool may insert #line pragmas to adjust the locations reported to the user.

As the result, the locations recorded in RealSrcLoc are not monotonic. Elements
that appear later in the StringBuffer are not guaranteed to have a higher
line/column number.

In fact, there are no guarantees whatsoever, as #line pragmas can arbitrarily
modify locations. This lack of guarantees makes ideas such as #17544
infeasible.

This patch adds an additional bit of information to every SrcLoc:

	newtype BufPos = BufPos { bufPos :: Int }

A BufPos represents the location in the StringBuffer, unaffected by any
pragmas.

Updates haddock submodule.

Metric Increase:
    haddock.Cabal
    haddock.base
    haddock.compiler
    MultiLayerModules
    Naperian
    parsing001
    T12150

- - - - -
99d2de86 by Ben Gamari at 2020-02-29T05:07:10-05:00
plugins: Ensure that loadInterface plugins can see annotations

loadInterface replaces the `mi_decls`, `mi_insts`, `mi_fam_insts`,
`mi_rules`, `mi_anns` fields of ModIface with `undefined` before
inserting the interface into the EPS. However, we still want to give
loadInterface plugins access to these fields. Consequently, we want to
pass the unmodified `ModIface` the plugin.

- - - - -
a999ee96 by Xavier Denis at 2020-02-29T05:07:50-05:00
Rename ghci.sh and build.sh to ghci and build respectively

Convert hadrian buildscripts to unsuffixed, dashed form

final cleanups

- - - - -
b5fb58fd by Ömer Sinan Ağacan at 2020-02-29T05:08:36-05:00
Document and refactor a few things around bitmap scavenging

- Added a few comments in StgPAP
- Added a few comments and assertions in scavenge_small_bitmap and
  walk_large_bitmap
- Did tiny refactor in GHC.Data.Bitmap: added some comments, deleted
  dead code, used PlatformWordSize type.

- - - - -
18757cab by Sylvain Henry at 2020-02-29T05:09:25-05:00
Refactor runtime interpreter code

In #14335 we want to be able to use both the internal interpreter (for
the plugins) and the external interpreter (for TH and GHCi) at the same
time.

This patch performs some preliminary refactoring: the `hsc_interp` field
of HscEnv replaces `hsc_iserv` and is now used to indicate which
interpreter (internal, external) to use to execute TH and GHCi.

Opt_ExternalInterpreter flag and iserv options in DynFlags are now
queried only when we set the session DynFlags. It should help making GHC
multi-target in the future by selecting an interpreter according to the
selected target.

- - - - -
b86a6395 by Adam Sandberg Ericsson at 2020-02-29T05:10:06-05:00
docs: correct relative links to haddocks from users guide (fixes #17866)

- - - - -
0f55df7f by Adam Sandberg Ericsson at 2020-02-29T05:10:06-05:00
docs: correct link to th haddocks from users guide

- - - - -
252e5117 by Jean-Baptiste Mazon at 2020-02-29T05:10:46-05:00
rts: enforce POSIX numeric locale for heap profiles

- - - - -
34c7d230 by Sylvain Henry at 2020-02-29T05:11:27-05:00
Fix Hadrian's ``--configure`` (fix #17883)

- - - - -
04d30137 by Ömer Sinan Ağacan at 2020-02-29T05:12:06-05:00
Simplify IfaceIdInfo type

IfaceIdInfo type is confusing: there's practically no difference between
`NoInfo` and `HasInfo []`. The comments say NoInfo is used when
-fomit-interface-pragmas is enabled, but we don't need to distinguish
`NoInfo` from `HasInfo []` in when reading the interface so the
distinction is not important.

This patch simplifies the type by removing NoInfo. When we have no info
we use an empty list.

With this change we no longer read the info list lazily when reading an
IfaceInfoItem, but when reading an IfaceId the ifIdInfo field is
read lazily, so I doubt this is going to be a problem.

- - - - -
3979485b by Roland Senn at 2020-02-29T17:36:59+01:00
Show breakpoint locations of breakpoints which were ignored during :force (#2950)

GHCi is split up into 2 major parts: The user-interface (UI)
and the byte-code interpreter. With `-fexternal-interpreter`
they even run in different processes. Communication between
the UI and the Interpreter (called `iserv`) is done using
messages over a pipe. This is called `Remote GHCI` and
explained in the Note [Remote GHCi] in `compiler/ghci/GHCi.hs`.

To process a `:force` command the UI sends a `Seq` message
to the `iserv` process. Then `iserv` does the effective
evaluation of the value. When during this process a breakpoint
is hit, the `iserv` process has no additional information to
enhance the `Ignoring breakpoint` output with the breakpoint
location.

To be able to print additional breakpoint information,
there are 2 possible implementation choices:
1. Store the needed information in the `iserv` process.
2. Print the `Ignoring breakpoint` from the UI process.

For option 1 we need to store the breakpoint info redundantely
in 2 places and this is bad. Therfore option 2 was implemented
in this MR:
- The user enters a `force` command
- The UI sends  a `Seq` message to the `iserv` process.
- If processing of the `Seq` message hits a breakpoint,
  the `iserv` process returns control to the UI process.
- The UI looks up the source location of the breakpoint,
  and prints the enhanced `Ignoring breakpoint` output.
- The UI sends a `ResumeSeq` message to the `iserv` process,
  to continue forcing.

- - - - -
3cf7303b by Krzysztof Gogolewski at 2020-03-02T01:18:33-05:00
Remove dead code

* The names in PrelName and THNames are no longer used
  since TH merged types and kinds, Typeable is kind-polymorphic,
  .net support was removed
* unqualQuasiQuote no longer used since 6f8ff0bbad3b9fa3

- - - - -
dbea7e9d by Ilias Tsitsimpis at 2020-03-02T01:19:12-05:00
Do not define hs_atomic{read,write}64() on non-64bit

Do not define hs_atomicread64() and hs_atomicwrite64() on machines where
WORD_SIZE_IN_BITS is less than 64, just like we do with the rest of the atomic
functions which work on 64-bit values.

Without this, compilation fails on MIPSel and PowerPC with the following error:

/usr/bin/ld: /<<PKGBUILDDIR>>/libraries/ghc-prim/dist-install/build/libHSghc-prim-0.5.3_p.a(atomic.p_o): in function `hs_atomicread64':
atomic.c:(.text.hs_atomicread64+0x8): undefined reference to `__sync_add_and_fetch_8'
/usr/bin/ld: /<<PKGBUILDDIR>>/libraries/ghc-prim/dist-install/build/libHSghc-prim-0.5.3_p.a(atomic.p_o): in function `hs_atomicwrite64':
atomic.c:(.text.hs_atomicwrite64+0x38): undefined reference to `__sync_bool_compare_and_swap_8'

Fixes #17886.

- - - - -
7c0c76fb by Roland Senn at 2020-03-02T17:13:55-05:00
Set `ImpredicativeTypes` during :print command. (#14828)

If ImpredicativeTypes is not enabled, then `:print <term>` will fail if the
type of <term> has nested `forall`s or `=>`s.
This is because the GHCi debugger's internals will attempt to unify a
metavariable with the type of <term> and then display the result, but if the
type has nested `forall`s or `=>`s, then unification will fail.
As a result, `:print` will bail out and the unhelpful result will be
`<term> = (_t1::t1)` (where `t1` is a metavariable).

Beware: <term> can have nested `forall`s even if its definition doesn't use
RankNTypes! Here is an example from #14828:

  class Functor f where
    fmap :: (a -> b) -> f a -> f b

Somewhat surprisingly, `:print fmap` considers the type of fmap to have
nested foralls. This is because the GHCi debugger sees the type
`fmap :: forall f. Functor f => forall a b. (a -> b) -> f a -> f b`.
We could envision deeply instantiating this type to get the type
`forall f a b. Functor f => (a -> b) -> f a -> f b`,
but this trick wouldn't work for higher-rank types.

Instead, we adopt a simpler fix: enable `ImpredicativeTypes` when using
`:print` and friends in the GHCi debugger. This is allows metavariables
to unify with types that have nested (or higher-rank) `forall`s/`=>`s,
which makes `:print fmap` display as
`fmap = (_t1::forall a b. Functor f => (a -> b) -> f a -> f b)`, as expected.

Although ImpredicativeTypes is a somewhat unpredictable from a type inference
perspective, there is no danger in using it in the GHCi debugger, since all
of the terms that the GHCi debugger deals with have already been typechecked.

- - - - -
2a2f51d7 by Sylvain Henry at 2020-03-02T17:14:38-05:00
Use configure script to detect that we should use in-tree GMP on Windows

- - - - -
8c663c2c by Andreas Klebinger at 2020-03-04T16:12:14+01:00
Be explicit about how stack usage of mvar primops are covered.

This fixes #17893

[skip-ci]

- - - - -
cedd6f30 by Ben Gamari at 2020-03-05T14:53:12-05:00
rts: Add getCurrentThreadCPUTime helper

- - - - -
ace618cd by Ben Gamari at 2020-03-05T14:53:12-05:00
nonmoving-gc: Track time usage of nonmoving marking

- - - - -
022b5ad5 by Ben Gamari at 2020-03-05T14:53:12-05:00
Stats: Add sync pauses to +RTS -S output

- - - - -
06763234 by Ben Gamari at 2020-03-05T14:53:12-05:00
rts: Report nonmoving collector statistics in machine-readable output

- - - - -
70d2b995 by Ben Gamari at 2020-03-09T06:10:52-04:00
nonmoving: Fix collection of sparks

Previously sparks living in the non-moving heap would be promptly GC'd
by the minor collector since pruneSparkQueue uses the BF_EVACUATED flag,
which non-moving heap blocks do not have set.

Fix this by implementing proper support in pruneSparkQueue for
determining reachability in the non-moving heap. The story is told in
Note [Spark management in the nonmoving heap].

- - - - -
9668781a by Ben Gamari at 2020-03-09T06:11:30-04:00
gitlab-ci: Disable Sphinx documentation in Alpine build
- - - - -
8eb2c263 by Jean-Baptiste Mazon at 2020-03-09T16:33:37-04:00
Fix Windows breakage by not touching locales on Windows

- - - - -
b8dab057 by Jean-Baptiste Mazon at 2020-03-09T16:33:37-04:00
rts: ensure C numerics in heap profiles using Windows locales if needed

- - - - -
7d95260f by Jean-Baptiste Mazon at 2020-03-09T16:33:37-04:00
rts: refactor and comment profile locales

- - - - -
5b627813 by Ryan Scott at 2020-03-09T16:34:14-04:00
Use InstanceSigs in GND/DerivingVia-generated code (#17899)

Aside from making the generated code easier to read when
`-ddump-deriv` is enabled, this makes the error message in `T15073`
substantially simpler (see the updated `T15073` expected stderr).

Fixes #17899.

- - - - -
70b50778 by Ben Gamari at 2020-03-10T02:05:42-04:00
SysTools: Ensure that error parser can handle absolute paths on Windows

This fixes #17786, where the error parser fails to correctly handle the
drive name in absolute Windows paths.

Unfortunately I couldn't find a satisfactory way to test this.

- - - - -
85b861d8 by Ben Gamari at 2020-03-10T02:05:42-04:00
testsuite: Add test for #17786

This isn't pretty but it's perhaps better than nothing.

- - - - -
ee2c50cb by Sylvain Henry at 2020-03-10T02:06:33-04:00
Hadrian: track missing configure results

- - - - -
ca8f51d4 by Ömer Sinan Ağacan at 2020-03-10T02:07:22-04:00
Add regression test for T17904

Closes #17904

- - - - -
5fa9cb82 by Richard Eisenberg at 2020-03-10T12:29:46-04:00
anyRewritableTyVar now looks in RuntimeReps

Previously, anyRewritableTyVar looked only at the arg and res
of `arg -> res`, but their RuntimeReps are also subject to
rewriting. Easy to fix.

Test case: typecheck/should_compile/T17024

Fixes #17024.

- - - - -
5ba01d83 by Ben Price at 2020-03-10T12:30:27-04:00
Clarify a Lint message

When developing a plugin I had a shadowing problem, where I generated
code
  app = \f{v r7B} x{v r7B} -> f{v r7B} x{v r7B}
This is obviously wrong, since the occurrence of `f` to the right of the
arrow refers to the `x` binder (they share a Unique). However, it is
rather confusing when Lint reports
  Mismatch in type between binder and occurrence
  Var: x{v rB7}
since it is printing the binder, rather than the occurrence.
It is rather easy to read this as claiming there is something wrong with
the `x` occurrence!

We change the report to explicitly print both the binder and the
occurrence variables.

- - - - -
7b2c827b by Simon Peyton Jones at 2020-03-10T12:31:15-04:00
Comments only

Clarify code added in #17852 and MR !2724

- - - - -
3300eeac by Krzysztof Gogolewski at 2020-03-10T12:31:54-04:00
Misc cleanup

- Remove Note [Existentials in shift_con_pat].
  The function shift_con_pat has been removed 15 years ago in 23f40f0e9be6d4.
- Remove kcLookupTcTyCon - it's the same as tcLookupTcTyCon
- Remove ASSERT in tyConAppArgN. It's already done by getNth,
  and it's the only reason getNth exists.
- Remove unused function nextRole

- - - - -
abf5736b by Krzysztof Gogolewski at 2020-03-10T18:05:01+01:00
Typos in comments [skip ci]

- - - - -
bb586f89 by Ben Gamari at 2020-03-11T00:14:59-04:00
rts: Prefer darwin-specific getCurrentThreadCPUTime

macOS Catalina now supports a non-POSIX-compliant version of clock_gettime
which cannot use the clock_gettime codepath.

Fixes #17906.

- - - - -
20800b9a by Sylvain Henry at 2020-03-11T08:17:19-04:00
Split GHC.Iface.Utils module

* GHC.Iface.Recomp: recompilation avoidance stuff
* GHC.Iface.Make: mkIface*

Moved `writeIfaceFile` into GHC.Iface.Load alongside `readIface` and
renamed it `writeIface` for consistency.

- - - - -
1daa2029 by Greg Steuck at 2020-03-11T08:17:56-04:00
Fixed a minor typo in codegen.rst
- - - - -
0bc23338 by Ryan Scott at 2020-03-11T08:18:32-04:00
Re-quantify when generalising over rewrite rule types

Previously, `tcRules` would check for naughty quantification
candidates (see `Note [Naughty quantification candidates]` in
`TcMType`) when generalising over the type of a rewrite rule. This
caused sensible-looking rewrite rules (like those in #17710) to be
rejected. A more permissing (and easier-to-implement) approach is to
do what is described in `Note [Generalising in tcTyFamInstEqnGuts]`
in `TcTyClsDecls`: just re-quantify all the type variable binders,
regardless of the order in which the user specified them. After all,
the notion of type variable specificity has no real meaning in
rewrite rules, since one cannot "visibly apply" a rewrite rule.
I have written up this wisdom in
`Note [Re-quantify type variables in rules]` in `TcRules`.

As a result of this patch, compiling the `ExplicitForAllRules1` test
case now generates one fewer warning than it used to. As far as I can
tell, this is benign, since the thing that the disappearing warning
talked about was also mentioned in an entirely separate warning.

Fixes #17710.

- - - - -
336eac7e by Ben Gamari at 2020-03-11T08:19:08-04:00
testsuite: Mark ghci056 and ghcilink004 as fragile in unreg

As noted in #17018.

Also fix fragile declaration of T13786, which only runs in the normal
way.

- - - - -
c61b9b02 by Simon Peyton Jones at 2020-03-11T08:19:44-04:00
Deepen call stack for isIn

I see quite a few warnings like:

  WARNING: file compiler/utils/Util.hs, line 593
    Over-long elem in unionLists

But the call stack is uninformative.   Better to add HasDebugCallStack
to isIn.  Ditto isn'tIn.

- - - - -
3aa9b35f by Ömer Sinan Ağacan at 2020-03-11T08:20:27-04:00
Zero any slop after compaction in compacting GC

In copying GC, with the relevant debug flags enabled, we release the old
blocks after a GC, and the block allocator zeroes the space before
releasing a block. This effectively zeros the old heap.

In compacting GC we reuse the blocks and previously we didn't zero the
unused space in a compacting generation after compaction. With this
patch we zero the slop between the free pointer and the end of the block
when we're done with compaction and when switching to a new block
(because the current block doesn't have enough space for the next object
we're shifting).

- - - - -
8e6febce by Sylvain Henry at 2020-03-11T20:33:37-04:00
Refactor GHC.Driver.Session (Ways and Flags)

* extract flags and ways into their own modules (with some renaming)

* remove one SOURCE import of GHC.Driver.Session from GHC.Driver.Phases

* when GHC uses dynamic linking (WayDyn), `interpWays` was only
  reporting WayDyn even if the host was profiled (WayProf).  Now it
  returns both as expected (might fix #16803).

* `mkBuildTag :: [Way] -> String` wasn't reporting a canonical tag for
  differently ordered lists. Now we sort and nub the list to fix this.

- - - - -
bc41e471 by Sylvain Henry at 2020-03-11T20:33:37-04:00
Refactor interpreterDynamic and interpreterProfiled

* `interpreterDynamic` and `interpreterProfiled` now take `Interp`
  parameters instead of DynFlags

* slight refactoring of `ExternalInterp` so that we can read the iserv
  configuration (which is pure) without reading an MVar.

- - - - -
a6989971 by Sylvain Henry at 2020-03-11T20:33:37-04:00
Use a Set to represent Ways

Should make `member` queries faster and avoid messing up with missing
`nubSort`.

Metric Increase:
    hie002

- - - - -
cb93a1a4 by Ryan Scott at 2020-03-11T20:34:14-04:00
Make DeriveFunctor-generated code require fewer beta reductions

Issue #17880 demonstrates that `DeriveFunctor`-generated code is
surprisingly fragile when rank-_n_ types are involved. The culprit is
that `$fmap` (the algorithm used to generate `fmap` implementations)
was too keen on applying arguments with rank-_n_ types to lambdas,
which fail to typecheck more often than not.

In this patch, I change `$fmap` (both the specification and the
implementation) to produce code that avoids creating as many lambdas,
avoiding problems when rank-_n_ field types arise.
See the comments titled "Functor instances" in `TcGenFunctor` for a
more detailed description. Not only does this fix #17880, but it also
ensures that the code that `DeriveFunctor` generates will continue
to work after simplified subsumption is implemented (see #17775).

What is truly amazing is that #17880 is actually a regression
(introduced in GHC 7.6.3) caused by commit
49ca2a37bef18aa57235ff1dbbf1cc0434979b1e, the fix #7436. Prior to
that commit, the version of `$fmap` that was used was almost
identical to the one used in this patch! Why did that commit change
`$fmap` then? It was to avoid severe performance issues that would
arise for recursive `fmap` implementations, such as in the example
below:

```hs
data List a = Nil | Cons a (List a) deriving Functor

-- ===>

instance Functor List where
  fmap f Nil = Nil
  fmap f (Cons x xs) = Cons (f x) (fmap (\y -> f y) xs)
```

The fact that `\y -> f y` was eta expanded caused significant
performance overheads. Commit
49ca2a37bef18aa57235ff1dbbf1cc0434979b1e fixed this performance
issue, but it went too far. As a result, this patch partially
reverts 49ca2a37bef18aa57235ff1dbbf1cc0434979b1e.

To ensure that the performance issues pre-#7436 do not resurface,
I have taken some precautionary measures:

* I have added a special case to `$fmap` for situations where the
  last type variable in an application of some type occurs directly.
  If this special case fires, we avoid creating a lambda expression.
  This ensures that we generate
  `fmap f (Cons x xs) = Cons (f x) (fmap f xs)` in the derived
  `Functor List` instance above. For more details, see
  `Note [Avoid unnecessary eta expansion in derived fmap implementations]`
  in `TcGenFunctor`.
* I have added a `T7436b` test case to ensure that the performance
  of this derived `Functor List`-style code does not regress.

When implementing this, I discovered that `$replace`, the algorithm
which generates implementations of `(<$)`, has a special case that is
very similar to the `$fmap` special case described above. `$replace`
marked this special case with a custom `Replacer` data type, which
was a bit overkill. In order to use the same machinery for both
`Functor` methods, I ripped out `Replacer` and instead implemented
a simple way to detect the special case. See the updated commentary
in `Note [Deriving <$]` for more details.

- - - - -
1f9db3e7 by Kirill Elagin at 2020-03-12T09:45:51-04:00
pretty-printer: Properly parenthesise LastStmt

After ApplicatveDo strips the last `return` during renaming, the pretty
printer has to restore it. However, if the return was followed by `$`,
the dollar was stripped too and not restored.

For example, the last stamement in:

```
  foo = do
    x <- ...
    ...
    return $ f x
```

would be printed as:

```
    return f x
```

This commit preserved the dolar, so it becomes:

```
    return $ f x
```

- - - - -
5cb93af7 by Kirill Elagin at 2020-03-12T09:45:51-04:00
pretty-printer: Do not print ApplicativeDo join

* Do not print `join` in ApplictiveStmt, unless ppr-debug
* Print parens around multiple parallel binds

When ApplicativeDo is enabled, the renamer analyses the statements of a
`do` block and in certain cases marks them as needing to be rewritten
using `join`.

For example, if you have:

```
foo = do
  a <- e1
  b <- e2
  doSomething a b
```

it will be desugared into:

```
foo = join (doSomething <$> e1 <*> e2)
```

After renaming but before desugaring the expression is stored
essentially as:

```
foo = do
  [will need join] (a <- e1 | b <- e2)
  [no return] doSomething a b
```

Before this change, the pretty printer would print a call to `join`,
even though it is not needed at this stage at all. The expression will be
actually rewritten into one using join only at desugaring, at which
point a literal call to join will be inserted.

- - - - -
3a259092 by Simon Peyton Jones at 2020-03-12T09:46:29-04:00
Expose compulsory unfoldings always

The unsafeCoerce# patch requires that unsafeCoerce# has
a compulsory unfolding that is always available.  So we have
to be careful to expose compulsory unfoldings unconditionally
and consistently.

We didn't get this quite right: #17871.  This patch fixes
it.  No real surprises here.

See Note [Always expose compulsory unfoldings] in GHC.Iface.Tidy

- - - - -
6a65b8c2 by Alp Mestanogullari at 2020-03-13T02:29:20-04:00
hadrian: improve dependency tracking for the check-* programs

The code in Rules.Register responsible for finding all the build artifacts
that Cabal installs when registering a library (static/shared libs, .hi files,
...) was looking in the wrong place. This patch fixes that logic and makes sure
we gather all those artifacts in a list to declare that the rule for a given
`.conf` file, our proxy for "Hadrian, please install this package in the package
db for this stage", also produces those artifacts under the said package
database.

We also were completely missing some logic to declare that the check-* programs
have dependencies besides their source code, at least when testing an in-tree
compiler.

Finally, this patch also removes redundant packages from 'testsuitePackages',
since they should already be covered by the stage<N>Packages lists from
Settings.Default.

With this patch, after a complete build and freezing stage 1, a change to
`compiler/parser/Parser.y` results in rebuilding the ghc lib, reinstalling it,
and rebuilding the few programs that depend on it, _including_ `check-ppr` and
`check-api-annotations` (therefore fixing #17273).

- - - - -
44fad4a9 by Sylvain Henry at 2020-03-13T02:30:22-04:00
Rename isDllName

I wanted to fix the dangling comment in `isDllName` ("This is the cause
of #", #8696 is already mentioned earlier). I took the opportunity to
change the function name to better reflect what it does.

- - - - -
2f292db8 by Paavo at 2020-03-13T02:31:03-04:00
Update documentation for closureSize

- - - - -
f124ff0d by Ben Gamari at 2020-03-13T02:31:40-04:00
gitlab-ci: Rework triggering of release builds

Use a push option instead of tagging.

- - - - -
7f25557a by Ben Gamari at 2020-03-13T10:38:09-04:00
gitlab-ci: Distinguish integer-simple test envs

Previously two integer-simple jobs declared the same test environment. One (the nightly job) was built in the perf way, the other in the validate way. Consequently they had appreciably different performance characteristics, causing in the nightly job to spuriously fail with performance changes.
- - - - -
c12a2ec5 by Simon Peyton Jones at 2020-03-14T05:25:30-04:00
Fix Lint

Ticket #17590 pointed out a bug in the way the linter dealt with
type lets, exposed by the new uniqAway story.

The fix is described in Note [Linting type lets]. I ended up
putting the in-scope Ids in a different env field, le_ids,
rather than (as before) sneaking them into the TCvSubst.

Surprisingly tiresome, but done.

Metric Decrease:
    hie002

- - - - -
b989845e by Sylvain Henry at 2020-03-14T05:26:11-04:00
Hadrian: fix absolute buildroot support (#17822)

Shake's "**" wildcard doesn't match absolute root. We must use "//" instead.

- - - - -
4f117135 by Sylvain Henry at 2020-03-14T05:26:49-04:00
Make: refactor GMP rules

Document and use simpler rules for the ghc-gmp.h header.

- - - - -
7432b327 by Sylvain Henry at 2020-03-14T05:27:28-04:00
Use correct option name (-opti) (fix #17314)

s/pgmo/opti

- - - - -
8f7dd571 by Judah Jacobson at 2020-03-14T05:28:07-04:00
Allow overriding LD_STAGE0 and AR_STAGE0 in the configure script.

Previously it was possible to override the stage0 C compiler via `CC_STAGE0`,
but you couldn't override `ld` or `ar` in stage0.  This change allows overriding them
by setting `LD_STAGE0` or `AR_STAGE0`, respectively.

Our team uses this feature internally to take more control of our GHC build
and make it run more hermetically.

- - - - -
7c3e39a9 by Judah Jacobson at 2020-03-14T05:28:07-04:00
Use AC_ARG_VAR for LD_STAGE0 and AR_STAGE0.

- - - - -
20d4d676 by Ben Gamari at 2020-03-14T05:28:43-04:00
nonmoving: Don't traverse filled segment list in pause

The non-moving collector would previously walk the entire filled segment
list during the preparatory pause. However, this is far more work than
is strictly necessary. We can rather get away with merely collecting the
allocators' filled segment list heads and process the lists themselves
during the concurrent phase. This can significantly reduce the maximum
gen1 GC pause time in programs with high rates of long-lived allocations.

- - - - -
fdfa2d01 by Ben Gamari at 2020-03-14T05:29:18-04:00
nonmoving: Remove redundant bitmap clearing

nonmovingSweep already clears the bitmap in the sweep loop. There is no
reason to do so a second time.

- - - - -
2f8c7767 by Simon Peyton Jones at 2020-03-14T05:29:55-04:00
Simple refactor of cheapEqExpr

No change in functionality.  Just seems tidier (and signficantly more
efficient) to deal with ticks directly than to call stripTicksTopE.

- - - - -
88f7a762 by Simon Peyton Jones at 2020-03-14T05:29:55-04:00
Improve CSE.combineAlts

This patch improves the way that CSE combines identical
alternatives.  See #17901.

I'm still not happy about the duplication between CSE.combineAlts
and GHC.Core.Utils.combineIdenticalAlts; see the Notes with those
functions.  But this patch is a step forward.

Metric Decrease:
    T12425
    T5642

- - - - -
8b95ddd3 by Ben Gamari at 2020-03-14T05:30:31-04:00
gitlab-ci: Add integer-simple release build for Windows

Closes #16144.

- - - - -
e3c374cc by Simon Peyton Jones at 2020-03-14T05:31:07-04:00
Wrap an implication around class-sig kind errors

Ticket #17841 showed that we can get a kind error
in a class signature, but lack an enclosing implication
that binds its skolems.

This patch

* Adds the wrapping implication: the new call to
  checkTvConstraints in tcClassDecl1

* Simplifies the API to checkTvConstraints, which
  was not otherwise called at all.

* Simplifies TcErrors.report_unsolved by *not*
  initialising the TidyEnv from the typechecker lexical
  envt.  It's enough to do so from the free vars of the
  unsolved constraints; and we get silly renamings if
  we add variables twice: once from the lexical scope
  and once from the implication constraint.

- - - - -
73133a3b by Simon Peyton Jones at 2020-03-14T05:31:07-04:00
Refactoring in TcSMonad

This patch is just refactoring: no change in
behaviour.

I removed the rather complicated
    checkConstraintsTcS
    checkTvConstraintsTcS

in favour of simpler functions
    emitImplicationTcS
    emitTvImplicationTcS
    pushLevelNoWorkList

The last of these is a little strange, but overall
it's much better I think.

- - - - -
93c88c26 by Ben Gamari at 2020-03-14T05:31:42-04:00
base: Make `open` calls interruptible

As noted in #17912, `open` system calls were `safe` rather than
`interruptible`. Consequently, the program could not be interrupted with
SIGINT if stuck in a slow open operation. Fix this by marking
`c_safe_open` as interruptible.

- - - - -
bee4cdad by Vladislav Zavialov at 2020-03-14T05:32:18-04:00
Remove second tcLookupTcTyCon in tcDataDefn

Before this patch, tcDataDefn used to call tcLookupTcTyCon twice in a row:
	1. in bindTyClTyVars itself
	2. in the continuation passed to it

Now bindTyClTyVars passes the TcTyCon to the continuation, making
the second lookup unnecessary.

- - - - -
3f116d35 by Cale Gibbard at 2020-03-14T19:34:42-04:00
Enable stage1 build of haddock

The submodule has already been bumped to contain the fix.

- - - - -
49e9d739 by Ömer Sinan Ağacan at 2020-03-14T19:35:24-04:00
rts: Fix printClosure when printing fwd ptrs

- - - - -
1de3ab4a by Krzysztof Gogolewski at 2020-03-14T19:36:04-04:00
Remove unused field var_inline (#17915)

- - - - -
d30aeb4b by Krzysztof Gogolewski at 2020-03-15T03:57:41-04:00
Document restriction on SCC pragma syntax

Currently, the names of cost centres must be quoted or
be lowercase identifiers.

Fixes #17916.

- - - - -
b4774598 by Brian Foley at 2020-03-15T03:58:18-04:00
Remove some dead code

>From the notes.ghc.drop list found using weeder in #17713

- - - - -
dd6ffe6b by Viktor Dukhovni at 2020-03-15T03:58:55-04:00
Note platform-specific Foreign.C.Types in context

Also fix the markup in the general note at the top of the module.  Haddock
(usability trade-off), does not support multi-line emphasised text.

- - - - -
2e82465f by Sylvain Henry at 2020-03-15T10:57:10-04:00
Refactor CmmToAsm (disentangle DynFlags)

This patch disentangles a bit more DynFlags from the native code
generator (CmmToAsm).

In more details:

- add a new NCGConfig datatype in GHC.CmmToAsm.Config which contains the
  configuration of a native code generation session
- explicitly pass NCGConfig/Platform arguments when necessary
- as a consequence `sdocWithPlatform` is gone and there are only a few
  `sdocWithDynFlags` left
- remove the use of `unsafeGlobalDynFlags` from GHC.CmmToAsm.CFG
- remove `sdocDebugLevel` (now we pass the debug level via NCGConfig)

There are still some places where DynFlags is used, especially because
of pretty-printing (CLabel), because of Cmm helpers (such as
`cmmExprType`) and because of `Outputable` instance for the
instructions. These are left for future refactoring as this patch is
already big.

- - - - -
c35c545d by Judah Jacobson at 2020-03-15T10:57:48-04:00
Add a -no-haddock flag.

This flag undoes the effect of a previous "-haddock" flag.  Having both flags makes it easier
for build systems to enable Haddock parsing in a set of global flags, but then disable it locally for
specific targets (e.g., third-party packages whose comments don't pass the validation in the latest GHC).

I added the flag to expected-undocumented-flags.txt since `-haddock` was alreadyin that list.

- - - - -
cfcc3c9a by Ömer Sinan Ağacan at 2020-03-15T10:58:27-04:00
Fix global_link of TSOs for threads reachable via dead weaks

Fixes #17785

Here's how the problem occurs:

- In generation 0 we have a TSO that is finished (i.e. it has no more
  work to do or it is killed).

- The TSO only becomes reachable after collectDeadWeakPtrs().

- After collectDeadWeakPtrs() we switch to WeakDone phase where we don't
  move TSOs to different lists anymore (like the next gen's thread list
  or the resurrected_threads list).

- So the TSO will never be moved to a generation's thread list, but it
  will be promoted to generation 1.

- Generation 1 collected via mark-compact, and because the TSO is
  reachable it is marked, and its `global_link` field, which is bogus at
  this point (because the TSO is not in a list), will be threaded.

- Chaos ensues.

In other words, when these conditions hold:

- A TSO is reachable only after collectDeadWeakPtrs()
- It's finished (what_next is ThreadComplete or ThreadKilled)
- It's retained by mark-compact collector (moving collector doesn't
  evacuate the global_list field)

We end up doing random mutations on the heap because the TSO's
global_list field is not valid, but it still looks like a heap pointer
so we thread it during compacting GC.

The fix is simple: when we traverse old_threads lists to resurrect
unreachable threads the threads that won't be resurrected currently
stays on the old_threads lists. Those threads will never be visited
again by MarkWeak so we now reset the global_list fields. This way
compacting GC does not thread pointers to nowhere.

Testing
-------

The reproducer in #17785 is quite large and hard to build, because of
the dependencies, so I'm not adding a regression test.

In my testing the reproducer would take a less than 5 seconds to run,
and once in every ~5 runs would fail with a segfault or an assertion
error. In other cases it also fails with a test failure. Because the
tests never fail with the bug fix, assuming the code is correct, this
also means that this bug can sometimes lead to incorrect runtime
results.

After the fix I was able to run the reproducer repeatedly for about an
hour, with no runtime crashes or test failures.

To run the reproducer clone the git repo:

    $ git clone https://github.com/osa1/streamly --branch ghc-segfault

Then clone primitive and atomic-primops from their git repos and point
to the clones in cabal.project.local. The project should then be
buildable using GHC HEAD. Run the executable `properties` with `+RTS -c
-DZ`.

In addition to the reproducer above I run the test suite using:

    $ make slowtest EXTRA_HC_OPTS="-debug -with-rtsopts=-DS \
        -with-rtsopts=-c +RTS -c -RTS" SKIPWAY='nonmoving nonmoving_thr'

This enables compacting GC always in both GHC when building the test
programs and when running the test programs, and also enables sanity
checking when running the test programs. These set of flags are not
compatible for all tests so there are some failures, but I got the same
set of failures with this patch compared to GHC HEAD.

- - - - -
818b3c38 by Lysxia at 2020-03-16T23:52:42-04:00
base: add strict IO functions: readFile', getContents', hGetContents'

- - - - -
18a346a4 by Sylvain Henry at 2020-03-16T23:53:24-04:00
Modules: Core (#13009)

Update submodule: haddock

- - - - -
92327e3a by Ömer Sinan Ağacan at 2020-03-16T23:54:04-04:00
Update sanity checking for TSOs:

- Remove an invalid assumption about GC checking what_next field. The GC
  doesn't care about what_next at all, if a TSO is reachable then all
  its pointers are followed (other than global_tso, which is only
  followed by compacting GC).

- Remove checkSTACK in checkTSO: TSO stacks will be visited in
  checkHeapChain, or checkLargeObjects etc.

- Add an assertion in checkTSO to check that the global_link field is
  sane.

- Did some refactor to remove forward decls in checkGlobalTSOList and
  added braces around single-statement if statements.

- - - - -
e1aa4052 by PHO at 2020-03-17T07:36:09-04:00
Don't use non-portable operator "==" in configure.ac

The test operator "==" is a Bash extension and produces a wrong result
if /bin/sh is not Bash.

- - - - -
89f034dd by Maximilian Tagher at 2020-03-17T07:36:48-04:00
Document the units of -ddump-timings

Right now, in the output of -ddump-timings to a file, you can't tell what the units are:

```
CodeGen [TemplateTestImports]: alloc=22454880 time=14.597
```

I believe bytes/milliseconds are the correct units, but confirmation would be appreciated. I'm basing it off of this snippet from `withTiming'`:

```
when (verbosity dflags >= 2 && prtimings == PrintTimings)
  $ liftIO $ logInfo dflags (defaultUserStyle dflags)
      (text "!!!" <+> what <> colon <+> text "finished in"
       <+> doublePrec 2 time
       <+> text "milliseconds"
       <> comma
       <+> text "allocated"
       <+> doublePrec 3 (realToFrac alloc / 1024 / 1024)
       <+> text "megabytes")
```

which implies time is in milliseconds, and allocations in bytes (which divided by 1024 would be KB, and again would be MB)

- - - - -
beffa147 by Simon Peyton Jones at 2020-03-17T07:37:25-04:00
Implement mapTyCo like foldTyCo

This patch makes mapType use the successful idiom described
in TyCoRep
   Note [Specialising foldType]

I have not yet changed any functions to use mapType, though there
may be some suitable candidates.

This patch should be a no-op in terms of functionality but,
because it inlines the mapper itself, I'm hoping that there may
be some modest perf improvements.

Metric Decrease:
    T5631
    T5642
    T3064
    T9020
    T14683
    hie002
    haddock.Cabal
    haddock.base
    haddock.compiler

- - - - -
5800ebfe by Ömer Sinan Ağacan at 2020-03-17T07:38:08-04:00
Don't update ModDetails with CafInfos when opts are disabled

This is consistent with the interface file behavior where we omit
HsNoCafRefs annotations with -fomit-interface-pragmas (implied by -O0).

ModDetails and ModIface are just different representations of the same
thing, so they really need to be in sync. This patch does the right
thing and does not need too much explanation, but here's an example of a
problem not doing this causes in !2842:

    -- MyInteger.hs
    module MyInteger
      ( MyInteger (MyInteger)
      , ToMyInteger (toMyInteger)
      ) where

    newtype MyInteger = MyInteger Integer

    class ToMyInteger a where
      toMyInteger :: a -> MyInteger

    instance ToMyInteger Integer where
      toMyInteger = MyInteger {- . succ -}

    -- Main.hs
    module Main
      ( main
      ) where

    import MyInteger (MyInteger (MyInteger), toMyInteger)

    main :: IO ()
    main = do
      let (MyInteger i) = (id . toMyInteger) (41 :: Integer)
      print i

If I build this with -O0, without this fix, we generate a ModDetails with
accurate LFInfo for toMyInteger (MyInteger.$fToMyIntegerInteger) which says that
it's a LFReEntrant with arity 1. This means in the use site (Main) we tag the
value:

    R3 = MyInteger.$fToMyIntegerInteger_closure + 1;
    R2 = GHC.Base.id_closure;
    R1 = GHC.Base.._closure;
    Sp = Sp - 16;
    call stg_ap_ppp_fast(R4, R3, R2, R1) args: 24, res: 0, upd: 24;

Now we change the definition by uncommenting the `succ` part and it becomes a thunk:

    MyInteger.$fToMyIntegerInteger [InlPrag=INLINE (sat-args=0)]
      :: MyInteger.ToMyInteger GHC.Integer.Type.Integer
    [GblId[DFunId(nt)]] =
        {} \u [] $ctoMyInteger_rEA;

and its LFInfo is now LFThunk. This change in LFInfo makes a difference in the
use site: we can no longer tag it.

But becuase the interface fingerprint does not change (because ModIface does not
change) we don't rebuild Main and tag the thunk.

(1.2% increase in allocations when building T12545 on armv7 because we
generate more code without CafInfos)

Metric Increase:
    T12545

- - - - -
5b632dad by Paavo at 2020-03-17T07:38:48-04:00
Add example for Data.Semigroup.diff

- - - - -
4d85d68b by Paavo at 2020-03-17T07:38:48-04:00
Clean up

- - - - -
75168d07 by Paavo at 2020-03-17T07:38:48-04:00
Make example collapsible

- - - - -
53ff2cd0 by Richard Eisenberg at 2020-03-17T13:46:57+00:00
Fix #17021 by checking more return kinds

All the details are in new Note [Datatype return kinds] in
TcTyClsDecls.

Test case: typecheck/should_fail/T17021{,b}
           typecheck/should_compile/T17021a

Updates haddock submodule

- - - - -
528df8ec by Sylvain Henry at 2020-03-18T10:06:43-04:00
Modules: Core operations (#13009)

- - - - -
4e8a71c1 by Richard Eisenberg at 2020-03-18T10:07:19-04:00
Add release note about fix to #16502.

We thought we needed to update the manual, but the fix for #16502
actually brings the implementation in line with the manual. So we
just alert users of how to update their code.

- - - - -
5cbf9934 by Andreas Klebinger at 2020-03-19T00:39:27-04:00
Update "GHC differences to the FFI Chapter" in user guide.

The old entry had a heavy focus on how things had been. Which is
not what I generally look for in a user guide.

I also added a small section on behaviour of nested safe ffi calls.

[skip-ci]

- - - - -
b03fd3bc by Sebastian Graf at 2020-03-19T00:40:06-04:00
PmCheck: Use ConLikeSet to model negative info

In #17911, Simon recognised many warnings stemming from over-long list
unions while coverage checking Cabal's `LicenseId` module.

This patch introduces a new `PmAltConSet` type which uses a `UniqDSet`
instead of an association list for `ConLike`s. For `PmLit`s, it will
still use an assocation list, though, because a similar map data
structure would entail a lot of busy work.

Fixes #17911.

- - - - -
64f20756 by Sylvain Henry at 2020-03-19T12:16:49-04:00
Refactoring: use Platform instead of DynFlags when possible

Metric Decrease:
    ManyConstructors
    T12707
    T13035
    T1969

- - - - -
cb1785d9 by Ömer Sinan Ağacan at 2020-03-19T12:16:54-04:00
FastString: fix eager reading of string ptr in hashStr

This read causes NULL dereferencing when len is 0.

Fixes #17909

In the reproducer in #17909 this bug is triggered as follows:

- SimplOpt.dealWithStringLiteral is called with a single-char string
  ("=" in #17909)

- tailFS gets called on the FastString of the single-char string.

- tailFS checks the length of the string, which is 1, and calls
  mkFastStringByteString on the tail of the ByteString, which is an
  empty ByteString as the original ByteString has only one char.

- ByteString's unsafeUseAsCStringLen returns (NULL, 0) for the empty
  ByteString, which is passed to mkFastStringWith.

- mkFastStringWith gets hash of the NULL pointer via hashStr, which
  fails on empty strings because of this bug.

- - - - -
73a7383e by Richard Eisenberg at 2020-03-20T20:42:56-04:00
Simplify treatment of heterogeneous equality

Previously, if we had a [W] (a :: k1) ~ (rhs :: k2), we would
spit out a [D] k1 ~ k2 and part the W as irreducible, hoping for
a unification. But we needn't do this. Instead, we now spit out
a [W] co :: k2 ~ k1 and then use co to cast the rhs of the original
Wanted. This means that we retain the connection between the
spat-out constraint and the original.

The problem with this new approach is that we cannot use the
casted equality for substitution; it's too like wanteds-rewriting-
wanteds. So, we forbid CTyEqCans that mention coercion holes.

All the details are in Note [Equalities with incompatible kinds]
in TcCanonical.

There are a few knock-on effects, documented where they occur.

While debugging an error in this patch, Simon and I ran into
infelicities in how patterns and matches are printed; we made
small improvements.

This patch includes mitigations for #17828, which causes spurious
pattern-match warnings. When #17828 is fixed, these lines should
be removed.

- - - - -
faa36e5b by Sylvain Henry at 2020-03-20T20:43:41-04:00
Hadrian: ignore in-tree GMP objects with ``--lint``

- - - - -
9a96ff6b by Richard Eisenberg at 2020-03-20T20:44:17-04:00
Update core spec to reflect changes to Core.

Key changes:
 * Adds a new rule for forall-coercions over coercion variables, which
was implemented but conspicuously missing from the spec.
 * Adds treatment for FunCo.
 * Adds treatment for ForAllTy over coercion variables.
 * Improves commentary (including restoring a Note lost in
03d4852658e1b7407abb4da84b1b03bfa6f6db3b) in the source.

No changes to running code.

- - - - -
7e0451c6 by Sergej Jaskiewicz at 2020-03-20T20:44:55-04:00
Fix event message in withTiming'

This typo caused generating 'end' events without the corresponding 'begin' events.

- - - - -
1542a626 by Ben Gamari at 2020-03-22T22:37:47-04:00
fs.h: Add missing declarations on Windows

- - - - -
3bcf2ccd by Ben Gamari at 2020-03-22T22:37:47-04:00
Bump process submodule

Avoids redundant case alternative warning.

- - - - -
3b363ef9 by Ben Gamari at 2020-03-22T22:37:47-04:00
testsuite: Normalize slashes in ghc-api annotations output

Enable `normalise_slashes` on `annotations`, `listcomps`, and
`parseTree` to fix Windows failures.

- - - - -
25fc9429 by Ben Gamari at 2020-03-22T22:37:47-04:00
testsuite: Update expected output on Windows

- - - - -
7f58ec6d by Ben Gamari at 2020-03-22T22:37:47-04:00
testsuite: Fix TOP of T17786

- - - - -
aadcd909 by GHC GitLab CI at 2020-03-22T22:37:47-04:00
testsuite: Update expected output on Windows

- - - - -
dc1eb10d by GHC GitLab CI at 2020-03-22T22:37:47-04:00
hadrian: Fix executable extension passed to testsuite driver

- - - - -
58f62e2c by GHC GitLab CI at 2020-03-22T22:37:47-04:00
gitlab-ci: Require that Windows-hadrian job passes

- - - - -
8dd2415d by Ben Gamari at 2020-03-22T22:37:47-04:00
hadrian: Eliminate redundant .exe from GHC path

Previously we were invoking:

    bash -c
    "c:/GitLabRunner/builds/eEQrxK4p/0/ghc/ghc/toolchain/bin/ghc.exe.exe
    testsuite/mk/ghc-config.hs -o _build/test/bin/ghc-config.exe"

- - - - -
373621f6 by Ben Gamari at 2020-03-22T22:37:47-04:00
Bump hsc2hs submodule

- - - - -
abc02b40 by Hécate at 2020-03-22T22:38:33-04:00
Annotate the non-total function in Data.Foldable as such

- - - - -
19f12557 by Josef Svenningsson at 2020-03-23T14:05:33-04:00
Fix ApplicativeDo regression #17835

A previous fix for #15344 made sure that monadic 'fail' is used properly
when translating ApplicativeDo. However, it didn't properly account
for when a 'fail' will be inserted which resulted in some programs
failing with a type error.

- - - - -
2643ba46 by Paavo at 2020-03-24T08:31:32-04:00
Add example and doc for Arg (Fixes #17153)

- - - - -
703221f4 by Roland Senn at 2020-03-25T14:45:04-04:00
Use export list of Main module in function TcRnDriver.hs:check_main (Fix #16453)

- Provide the export list of the `Main` module as parameter to the
  `compiler/typecheck/TcRnDriver.hs:check_main` function.
- Instead of `lookupOccRn_maybe` call the function `lookupInfoOccRn`.
  It returns the list `mains_all` of all the main functions in scope.
- Select from this list `mains_all` all `main` functions that are in
  the export list of the `Main` module.
- If this new list contains exactly one single `main` function, then
  typechecking continues.
- Otherwise issue an appropriate error message.

- - - - -
3e27205a by Sebastian Graf at 2020-03-25T14:45:40-04:00
Remove -fkill-absence and -fkill-one-shot flags

They seem to be a benchmarking vestige of the Cardinality paper and
probably shouldn't have been merged to HEAD in the first place.

- - - - -
262e42aa by Peter Trommler at 2020-03-25T22:41:39-04:00
Do not panic on linker errors

- - - - -
0de03cd7 by Sylvain Henry at 2020-03-25T22:42:02-04:00
DynFlags refactoring III

Use Platform instead of DynFlags when possible:
* `tARGET_MIN_INT` et al. replaced with `platformMinInt` et al.
* no more DynFlags in PreRules: added a new `RuleOpts` datatype
* don't use `wORD_SIZE` in the compiler
* make `wordAlignment` use `Platform`
* make `dOUBLE_SIZE` a constant

Metric Decrease:
    T13035
    T1969

- - - - -
7a04920b by Tristan Cacqueray at 2020-03-25T22:42:06-04:00
Base: fix a typo in liftA doc

This change removes an extra '|' that should not be rendered in
the liftA documentation.

Tracking: #17929

- - - - -
1c5a15f7 by Tristan Cacqueray at 2020-03-25T22:42:06-04:00
Base: add Control.Applicative optional example

This change adds an optional example.

Tracking: #17929

- - - - -
6d172e63 by Tristan Cacqueray at 2020-03-25T22:42:06-04:00
Base: add markup around Except

- - - - -
eb2162c8 by John Ericson at 2020-03-26T12:37:08-04:00
Remove unused `ghciTablesNextToCode` from compiler proper

- - - - -
f51efc4b by Joachim Breitner at 2020-03-26T12:37:09-04:00
Prepare to use run-time tablesNextToCode in compiler exclusively

Factor out CPP as much as possible to prepare for runtime
determinattion.

Progress towards #15548

- - - - -
1c446220 by Joachim Breitner at 2020-03-26T12:37:09-04:00
Use run-time tablesNextToCode in compiler exclusively (#15548)

Summary:

 - There is no more use of the TABLES_NEXT_TO_CODE CPP macro in
   `compiler/`. GHCI_TABLES_NEXT_TO_CODE is also removed entirely.
   The field within `PlatformMisc` within `DynFlags` is used instead.

 - The field is still not exposed as a CLI flag. We might consider some
   way to ensure the right RTS / libraries are used before doing that.

Original reviewers:

Original subscribers: TerrorJack, rwbarton, carter

Original Differential Revision: https://phabricator.haskell.org/D5082

- - - - -
1941ef4f by Sylvain Henry at 2020-03-29T17:28:51-04:00
Modules: Types (#13009)

Update Haddock submodule

Metric Increase:
   haddock.compiler

- - - - -
1c7c6f1a by Sylvain Henry at 2020-03-29T17:28:51-04:00
Remove GHC.Types.Unique.Map module

This module isn't used anywhere in GHC.

- - - - -
f1a6c73d by Sylvain Henry at 2020-03-29T17:28:51-04:00
Merge GHC.Types.CostCentre.Init into GHC.Driver.CodeOutput

- - - - -
54250f2d by Simon Peyton Jones at 2020-03-29T17:29:30-04:00
Demand analysis: simplify the demand for a RHS

Ticket #17932 showed that we were using a stupid demand for the RHS
of a let-binding, when the result is a product.  This was the result
of a "fix" in 2013, which (happily) turns out to no longer be
necessary.

So I just deleted the code, which simplifies the demand analyser,
and fixes #17932. That in turn uncovered that the anticipation
of worker/wrapper in CPR analysis was inaccurate, hence the logic
that decides whether to unbox an argument in WW was extracted into
a function `wantToUnbox`, now consulted by CPR analysis.

I tried nofib, and got 0.0% perf changes.

All this came up when messing about with !2873 (ticket #17917),
but is idependent of it.

Unfortunately, this patch regresses #4267 and realised that it is now
blocked on #16335.

- - - - -
03060b2f by Ben Gamari at 2020-03-29T17:30:05-04:00
testsuite: Fix T17786 on Windows

Fixes line ending normalization issue.

- - - - -
1f7995ba by Ben Gamari at 2020-03-29T17:30:05-04:00
testsuite: Fix T17786

Fix missing quoting and expected exit code.

- - - - -
ef9c608e by Ben Gamari at 2020-03-29T17:30:05-04:00
testsuite: Mark T12971 as broken on Windows

Due to #17945.

- - - - -
e54500c1 by Sylvain Henry at 2020-03-29T17:30:47-04:00
Store ComponentId details

As far as GHC is concerned, installed package components ("units") are
identified by an opaque ComponentId string provided by Cabal. But we
don't want to display it to users (as it contains a hash) so GHC queries
the database to retrieve some infos about the original source package
(name, version, component name).

This patch caches these infos in the ComponentId itself so that we don't
need to provide DynFlags (which contains installed package informations)
to print a ComponentId.

In the future we want GHC to support several independent package states
(e.g. for plugins and for target code), hence we need to avoid
implicitly querying a single global package state.

- - - - -
7e7cb714 by Marius Bakke at 2020-03-29T17:31:27-04:00
testsuite: Remove test that dlopens a PIE object.

glibc 2.30 disallowed dlopening PIE objects, so just remove the test.
Fixes #17952.

- - - - -
6c8f80d8 by Andreas Klebinger at 2020-03-29T17:32:04-04:00
Correct haddocks for testBit in Data.Bits

It conflated the nth bit with the bit at offset n.

Now we instead give the definition in terms of `bit and `.&.`
on top of clearer phrasing.

- - - - -
c916f190 by Andreas Klebinger at 2020-03-29T17:32:04-04:00
Apply suggestion to libraries/base/Data/Bits.hs
- - - - -
64bf7f51 by Ben Gamari at 2020-03-29T17:32:41-04:00
gitlab-ci: Add FreeBSD release job

- - - - -
a0d8e92e by Ryan Scott at 2020-03-29T17:33:20-04:00
Run checkNewDataCon before constraint-solving newtype constructors

Within `checkValidDataCon`, we used to run `checkValidType` on the
argument types of a newtype constructor before running
`checkNewDataCon`, which ensures that the user does not attempt
non-sensical things such as newtypes with multiple arguments or
constraints. This works out in most situations, but this falls over
on a corner case revealed in #17955:

```hs
newtype T = Coercible () T => T ()
```

`checkValidType`, among other things, peforms an ambiguity check on
the context of a data constructor, and that it turn invokes the
constraint solver. It turns out that there is a special case in the
constraint solver for representational equalities (read: `Coercible`
constraints) that causes newtypes to be unwrapped (see
`Note [Unwrap newtypes first]` in `TcCanonical`). This special case
does not know how to cope with an ill formed newtype like `T`, so
it ends up panicking.

The solution is surprisingly simple: just invoke `checkNewDataCon`
before `checkValidType` to ensure that the illicit newtype
constructor context is detected before the constraint solver can
run amok with it.

Fixes #17955.

- - - - -
45eb9d8c by Krzysztof Gogolewski at 2020-03-29T17:33:59-04:00
Minor cleanup

- Simplify mkBuildExpr, the function newTyVars was called
  only on a one-element list.
- TTG: use noExtCon in more places. This is more future-proof.
- In zonkExpr, panic instead of printing a warning.

- - - - -
f024b6e3 by Sylvain Henry at 2020-03-30T12:48:39+02:00
Expect T4267 to pass

Since 54250f2d8de910b094070c1b48f086030df634b1 we expected T4267 to
fail, but it passes on CI.

- - - - -
57b888c0 by Ryan Scott at 2020-03-31T10:54:20-04:00
Require GHC 8.8 as the minimum compiler for bootstrapping

This allows us to remove several bits of CPP that are either always
true or no longer reachable. As an added bonus, we no longer need to
worry about importing `Control.Monad.Fail.fail` qualified to avoid
clashing with `Control.Monad.fail`, since the latter is now the same
as the former.

- - - - -
33f09551 by Ryan Scott at 2020-03-31T10:54:57-04:00
Add regression test for #17963

The panic in #17963 happened to be fixed by commit
e3c374cc5bd7eb49649b9f507f9f7740697e3f70. This patch adds a
regression test to ensure that it remains fixed.

Fixes #17963.

- - - - -
09a36e80 by Ömer Sinan Ağacan at 2020-03-31T10:55:37-04:00
Simplify stderrSupportsAnsiColors

The combinator andM is used only once, and the code is shorter and
simpler if you inline it.

- - - - -
95bccdd0 by Ben Gamari at 2020-03-31T10:56:19-04:00
base: Ensure that encoding global variables aren't inlined

As noted in #17970, these (e.g. `getFileSystemEncoding` and
`setFileSystemEncoding`) previously had unfoldings, which would
break their global-ness.

While not strictly necessary, I also add a NOINLINE on
`initLocaleEncoding` since it is used in `System.IO`, ensuring that we
only system's query the locale encoding once.

Fixes #17970.

- - - - -
982aaa83 by Andreas Klebinger at 2020-03-31T10:56:55-04:00
Update hadrian index revision.

Required in order to build hadrian using ghc-8.10

- - - - -
4b9c5864 by Ben Gamari at 2020-03-31T10:57:32-04:00
integer-gmp: Bump version and add changelog entry

- - - - -
9b39f2e6 by Ryan Scott at 2020-04-01T01:20:00-04:00
Clean up "Eta reduction for data families" Notes

Before, there were two distinct Notes named
"Eta reduction for data families". This renames one of them to
"Implementing eta reduction for data families" to disambiguate the
two and fixes references in other parts of the codebase to ensure
that they are pointing to the right place.

Fixes #17313.

[ci skip]

- - - - -
7627eab5 by Ryan Scott at 2020-04-01T01:20:38-04:00
Fix the changelog/@since information for hGetContents'/getContents'/readFile'

Fixes #17979.

[ci skip]

- - - - -
0002db1b by Sylvain Henry at 2020-04-01T01:21:27-04:00
Kill wORDS_BIGENDIAN and replace it with platformByteOrder (#17957)

Metric Decrease:
    T13035
    T1969

- - - - -
7b217179 by Sebastian Graf at 2020-04-01T15:03:24-04:00
PmCheck: Adjust recursion depth for inhabitation test

In #17977, we ran into the reduction depth limit of the typechecker.
That was only a symptom of a much broader issue: The recursion depth
of the coverage checker for trying to instantiate strict fields in the
`nonVoid` test was far too high (100, the `defaultMaxTcBound`).

As a result, we were performing quite poorly on `T17977`.
Short of a proper termination analysis to prove emptyness of a type,
we just arbitrarily default to a much lower recursion limit of 3.

Fixes #17977.

- - - - -
3c09f636 by Andreas Klebinger at 2020-04-01T15:03:59-04:00
Make hadrian pass on the no-colour setting to GHC.

Fixes #17983.

- - - - -
b943b25d by Simon Peyton Jones at 2020-04-02T01:45:58-04:00
Re-engineer the binder-swap transformation

The binder-swap transformation is implemented by the occurrence
analyser -- see Note [Binder swap] in OccurAnal. However it had
a very nasty corner in it, for the case where the case scrutinee
was a GlobalId.  This led to trouble and hacks, and ultimately
to #16296.

This patch re-engineers how the occurrence analyser implements
the binder-swap, by actually carrying out a substitution rather
than by adding a let-binding.  It's all described in
Note [The binder-swap substitution].

I did a few other things along the way

* Fix a bug in StgCse, which could allow a loop breaker to be CSE'd
  away.  See Note [Care with loop breakers] in StgCse.  I think it can
  only show up if occurrence analyser sets up bad loop breakers, but
  still.

* Better commenting in SimplUtils.prepareAlts

* A little refactoring in CoreUnfold; nothing significant
  e.g. rename CoreUnfold.mkTopUnfolding to mkFinalUnfolding

* Renamed CoreSyn.isFragileUnfolding to hasCoreUnfolding

* Move mkRuleInfo to CoreFVs

We observed respectively 4.6% and 5.9% allocation decreases for the following
tests:

Metric Decrease:
    T9961
    haddock.base

- - - - -
42d68364 by Sebastian Graf at 2020-04-02T01:46:34-04:00
Preserve precise exceptions in strictness analysis

Fix #13380 and #17676 by

1. Changing `raiseIO#` to have `topDiv` instead of `botDiv`
2. Give it special treatment in `Simplifier.Util.mkArgInfo`, treating it
   as if it still had `botDiv`, to recover dead code elimination.

This is the first commit of the plan outlined in
https://gitlab.haskell.org/ghc/ghc/-/merge_requests/2525#note_260886.

- - - - -
0a88dd11 by Ömer Sinan Ağacan at 2020-04-02T01:47:25-04:00
Fix a pointer format string in RTS

- - - - -
5beac042 by Ömer Sinan Ağacan at 2020-04-02T01:48:05-04:00
Remove unused closure stg_IND_direct

- - - - -
88f38b03 by Ben Gamari at 2020-04-02T01:48:42-04:00
Session: Memoize stderrSupportsAnsiColors

Not only is this a reasonable efficiency measure but it avoids making
reentrant calls into ncurses, which is not thread-safe. See #17922.

- - - - -
27740f24 by Ryan Scott at 2020-04-02T01:49:21-04:00
Make Hadrian build with Cabal-3.2

GHC 8.10 ships with `Cabal-3.2.0.0`, so it would be convenient to
make Hadrian supporting building against 3.2.* instead of having to
rebuild the entirety of `Cabal-3.0.0.0`. There is one API change in
`Cabal-3.2.*` that affects Hadrian: the `synopsis` and `description`
functions now return `ShortText` instead of `String`. Since Hadrian
manipulates these `String`s in various places, I found that the
simplest fix was to use CPP to convert `ShortText` to `String`s
where appropriate.

- - - - -
49802002 by Sylvain Henry at 2020-04-02T01:50:00-04:00
Update Stack resolver for hadrian/build-stack

Broken by 57b888c0e90be7189285a6b078c30b26d0923809

- - - - -
30a63e79 by Ryan Scott at 2020-04-02T01:50:36-04:00
Fix two ASSERT buglets in reifyDataCon

Two `ASSERT`s in `reifyDataCon` were always using `arg_tys`, but
`arg_tys` is not meaningful for GADT constructors. In fact, it's
worse than non-meaningful, since using `arg_tys` when reifying a
GADT constructor can lead to failed `ASSERT`ions, as #17305
demonstrates.

This patch applies the simplest possible fix to the immediate
problem. The `ASSERT`s now use `r_arg_tys` instead of `arg_tys`, as
the former makes sure to give something meaningful for GADT
constructors. This makes the panic go away at the very least. There
is still an underlying issue with the way the internals of
`reifyDataCon` work, as described in
https://gitlab.haskell.org/ghc/ghc/issues/17305#note_227023, but we
leave that as future work, since fixing the underlying issue is
much trickier (see
https://gitlab.haskell.org/ghc/ghc/issues/17305#note_227087).

- - - - -
ef7576c4 by Zubin Duggal at 2020-04-03T06:24:56-04:00
Add outputable instances for the types in GHC.Iface.Ext.Types, add -ddump-hie
flag to dump pretty printed contents of the .hie file

Metric Increase:
   hie002

Because of the regression on i386:

compile_time/bytes allocated increased from i386-linux-deb9 baseline @ HEAD~10:
    Expected    hie002 (normal) compile_time/bytes allocated: 583014888.0 +/-10%
    Lower bound hie002 (normal) compile_time/bytes allocated:   524713399
    Upper bound hie002 (normal) compile_time/bytes allocated:   641316377
    Actual      hie002 (normal) compile_time/bytes allocated:   877986292
    Deviation   hie002 (normal) compile_time/bytes allocated:        50.6 %
*** unexpected stat test failure for hie002(normal)

- - - - -
9462452a by Andreas Klebinger at 2020-04-03T06:25:33-04:00
Improve and refactor StgToCmm codegen for DataCons.

We now differentiate three cases of constructor bindings:

1)Bindings which we can "replace" with a reference to
  an existing closure. Reference the replacement closure
  when accessing the binding.
2)Bindings which we can "replace" as above. But we still
  generate a closure which will be referenced by modules
  importing this binding.
3)For any other binding generate a closure. Then reference
  it.

Before this patch 1) did only apply to local bindings and we
didn't do 2) at all.

- - - - -
a214d214 by Moritz Bruder at 2020-04-03T06:26:11-04:00
Add singleton to NonEmpty in libraries/base

This adds a definition to construct a singleton non-empty list
(Data.List.NonEmpty) according to issue #17851.

- - - - -
f7597aa0 by Sylvain Henry at 2020-04-03T06:26:54-04:00
Testsuite: measure compiler stats for T16190

We were mistakenly measuring program stats

- - - - -
a485c3c4 by Sylvain Henry at 2020-04-03T06:26:54-04:00
Move blob handling into StgToCmm

Move handling of big literal strings from CmmToAsm to StgToCmm. It
avoids the use of `sdocWithDynFlags` (cf #10143). We might need to move
this handling even higher in the pipeline in the future (cf #17960):
this patch will make it easier.

- - - - -
cc2918a0 by Sylvain Henry at 2020-04-03T06:26:54-04:00
Refactor CmmStatics

In !2959 we noticed that there was some redundant code (in GHC.Cmm.Utils
and GHC.Cmm.StgToCmm.Utils) used to deal with `CmmStatics` datatype
(before SRT generation) and `RawCmmStatics` datatype (after SRT
generation).

This patch removes this redundant code by using a single GADT for
(Raw)CmmStatics.

- - - - -
9e60273d by Maxim Koltsov at 2020-04-03T06:27:32-04:00
Fix haddock formatting in Control.Monad.ST.Lazy.Imp.hs

- - - - -
1b7e8a94 by Andreas Klebinger at 2020-04-03T06:28:08-04:00
Turn newlines into spaces for hadrian/ghci.

The newlines break the command on windows.

- - - - -
4291bdda by Simon Peyton Jones at 2020-04-03T06:28:44-04:00
Major improvements to the specialiser

This patch is joint work of Alexis King and Simon PJ.  It does some
significant refactoring of the type-class specialiser.  Main highlights:

* We can specialise functions with types like
     f :: Eq a => a -> Ord b => b => blah
  where the classes aren't all at the front (#16473).  Here we can
  correctly specialise 'f' based on a call like
     f @Int @Bool dEqInt x dOrdBool
  This change really happened in an earlier patch
     commit 2d0cf6252957b8980d89481ecd0b79891da4b14b
     Author: Sandy Maguire <sandy at sandymaguire.me>
     Date:   Thu May 16 12:12:10 2019 -0400
  work that this new patch builds directly on that work, and refactors
  it a bit.

* We can specialise functions with implicit parameters (#17930)
     g :: (?foo :: Bool, Show a) => a -> String
  Previously we could not, but now they behave just like a non-class
  argument as in 'f' above.

* We can specialise under-saturated calls, where some (but not all of
  the dictionary arguments are provided (#17966).  For example, we can
  specialise the above 'f' based on a call
     map (f @Int dEqInt) xs
  even though we don't (and can't) give Ord dictionary.

  This may sound exotic, but #17966 is a program from the wild, and
  showed significant perf loss for functions like f, if you need
  saturation of all dictionaries.

* We fix a buglet in which a floated dictionary had a bogus demand
  (#17810), by using zapIdDemandInfo in the NonRec case of specBind.

* A tiny side benefit: we can drop dead arguments to specialised
  functions; see Note [Drop dead args from specialisations]

* Fixed a bug in deciding what dictionaries are "interesting"; see
  Note [Keep the old dictionaries interesting]

This is all achieved by by building on Sandy Macguire's work in
defining SpecArg, which mkCallUDs uses to describe the arguments of
the call. Main changes:

* Main work is in specHeader, which marched down the [InBndr] from the
  function definition and the [SpecArg] from the call site, together.

* specCalls no longer has an arity check; the entire mechanism now
  handles unders-saturated calls fine.

* mkCallUDs decides on an argument-by-argument basis whether to
  specialise a particular dictionary argument; this is new.
  See mk_spec_arg in mkCallUDs.

It looks as if there are many more lines of code, but I think that
all the extra lines are comments!

- - - - -
40a85563 by Ömer Sinan Ağacan at 2020-04-03T18:26:19+03:00
Revert accidental change in 9462452

[ci skip]

- - - - -
bd75e5da by Ryan Scott at 2020-04-04T07:07:58-04:00
Enable ImpredicativeTypes internally when typechecking selector bindings

This is necessary for certain record selectors with higher-rank
types, such as the examples in #18005. See
`Note [Impredicative record selectors]` in `TcTyDecls`.

Fixes #18005.

- - - - -
dcfe29c8 by Ömer Sinan Ağacan at 2020-04-06T13:16:08-04:00
Don't override proc CafInfos in ticky builds

Fixes #17947

When we have a ticky label for a proc, IdLabels for the ticky counter
and proc entry share the same Name. This caused overriding proc CafInfos
with the ticky CafInfos (i.e. NoCafRefs) during SRT analysis.

We now ignore the ticky labels when building SRTMaps. This makes sense
because:

- When building the current module they don't need to be in SRTMaps as
  they're initialized as non-CAFFY (see mkRednCountsLabel), so they
  don't take part in the dependency analysis and they're never added to
  SRTs.

  (Reminder: a "dependency" in the SRT analysis is a CAFFY dependency,
  non-CAFFY uses are not considered as dependencies for the algorithm)

- They don't appear in the interfaces as they're not exported, so it
  doesn't matter for cross-module concerns whether they're in the SRTMap
  or not.

See also the new Note [Ticky labels in SRT analysis].

- - - - -
cec2c71f by Simon Peyton Jones at 2020-04-06T13:16:44-04:00
Fix an tricky specialiser loop

Issue #17151 was a very tricky example of a bug in which the
specialiser accidentally constructs a recurive dictionary,
so that everything turns into bottom.

I have fixed variants of this bug at least twice before:
see Note [Avoiding loops].  It was a bit of a struggle
to isolate the problem, greatly aided by the work that
Alexey Kuleshevich did in distilling a test case.

Once I'd understood the problem, it was not difficult to fix,
though it did lead me a bit of refactoring in specImports.

- - - - -
e850d14f by Simon Peyton Jones at 2020-04-06T13:16:44-04:00
Refactoring only

This refactors DictBinds into a data type rather than a pair.
No change in behaviour, just better code

- - - - -
f38e8d61 by Daniel Gröber at 2020-04-07T02:00:05-04:00
rts: ProfHeap: Fix memory leak when not compiled with profiling

If we're doing heap profiling on an unprofiled executable we keep
allocating new space in initEra via nextEra on each profiler run but we
don't have a corresponding freeEra call.

We do free the last era in endHeapProfiling but previous eras will have
been overwritten by initEra and will never get free()ed.

Metric Decrease:
    space_leak_001

- - - - -
bcd66859 by Sebastian Graf at 2020-04-07T02:00:41-04:00
Re-export GHC.Magic.noinline from base

- - - - -
3d2991f8 by Ben Gamari at 2020-04-07T18:36:09-04:00
simplifier: Kill off ufKeenessFactor

We used to have another factor, ufKeenessFactor, which would scale the
discounts before they were subtracted from the size. This was justified
with the following comment:

  -- We multiple the raw discounts (args_discount and result_discount)
  -- ty opt_UnfoldingKeenessFactor because the former have to do with
  --  *size* whereas the discounts imply that there's some extra
  --  *efficiency* to be gained (e.g. beta reductions, case reductions)
  -- by inlining.

However, this is highly suspect since it means that we subtract a
*scaled* size from an absolute size, resulting in crazy (e.g. negative)
scores in some cases (#15304). We consequently killed off
ufKeenessFactor and bumped up the ufUseThreshold to compensate.

Adjustment of unfolding use threshold
=====================================

Since this removes a discount from our inlining heuristic, I revisited our
default choice of -funfolding-use-threshold to minimize the change in
overall inlining behavior. Specifically, I measured runtime allocations
and executable size of nofib and the testsuite performance tests built
using compilers (and core libraries) built with several values of
-funfolding-use-threshold.

This comes as a result of a quantitative comparison of testsuite
performance and code size as a function of ufUseThreshold, comparing
GHC trees using values of 50, 60, 70, 80, 90, and 100. The test set
consisted of nofib and the testsuite performance tests.
A full summary of these measurements are found in the description of
!2608

Comparing executable sizes (relative to the base commit) across all
nofib tests, we see that sizes are similar to the baseline:

            gmean      min      max   median
thresh
50         -6.36%   -7.04%   -4.82%   -6.46%
60         -5.04%   -5.97%   -3.83%   -5.11%
70         -2.90%   -3.84%   -2.31%   -2.92%
80         -0.75%   -2.16%   -0.42%   -0.73%
90         +0.24%   -0.41%   +0.55%   +0.26%
100        +1.36%   +0.80%   +1.64%   +1.37%
baseline   +0.00%   +0.00%   +0.00%   +0.00%

Likewise, looking at runtime allocations we see that 80 gives slightly
better optimisation than the baseline:

            gmean      min      max   median
thresh
50         +0.16%   -0.16%   +4.43%   +0.00%
60         +0.09%   -0.00%   +3.10%   +0.00%
70         +0.04%   -0.09%   +2.29%   +0.00%
80         +0.02%   -1.17%   +2.29%   +0.00%
90         -0.02%   -2.59%   +1.86%   +0.00%
100        +0.00%   -2.59%   +7.51%   -0.00%
baseline   +0.00%   +0.00%   +0.00%   +0.00%

Finally, I had to add a NOINLINE in T4306 to ensure that `upd` is
worker-wrappered as the test expects. This makes me wonder whether the
inlining heuristic is now too liberal as `upd` is quite a large
function. The same measure was taken in T12600.

             Wall clock time compiling Cabal with -O0
thresh       50     60     70     80     90      100    baseline
build-Cabal  93.88  89.58  92.59  90.09  100.26  94.81  89.13

Also, this change happens to avoid the spurious test output in
`plugin-recomp-change` and `plugin-recomp-change-prof` (see #17308).

Metric Decrease:
    hie002
    T12234
    T13035
    T13719
    T14683
    T4801
    T5631
    T5642
    T9020
    T9872d
    T9961
Metric Increase:
    T12150
    T12425
    T13701
    T14697
    T15426
    T1969
    T3064
    T5837
    T6048
    T9203
    T9872a
    T9872b
    T9872c
    T9872d
    haddock.Cabal
    haddock.base
    haddock.compiler

- - - - -
255418da by Sylvain Henry at 2020-04-07T18:36:49-04:00
Modules: type-checker (#13009)

Update Haddock submodule

- - - - -
04b6cf94 by Ryan Scott at 2020-04-07T19:43:20-04:00
Make NoExtCon fields strict

This changes every unused TTG extension constructor to be strict in
its field so that the pattern-match coverage checker is smart enough
any such constructors are unreachable in pattern matches. This lets
us remove nearly every use of `noExtCon` in the GHC API. The only
ones we cannot remove are ones underneath uses of `ghcPass`, but that
is only because GHC 8.8's and 8.10's coverage checkers weren't smart
enough to perform this kind of reasoning. GHC HEAD's coverage
checker, on the other hand, _is_ smart enough, so we guard these uses
of `noExtCon` with CPP for now.

Bumps the `haddock` submodule.

Fixes #17992.

- - - - -
7802fa17 by Ryan Scott at 2020-04-08T16:43:44-04:00
Handle promoted data constructors in typeToLHsType correctly

Instead of using `nlHsTyVar`, which hardcodes `NotPromoted`, have
`typeToLHsType` pick between `Promoted` and `NotPromoted` by checking
if a type constructor is promoted using `isPromotedDataCon`.

Fixes #18020.

- - - - -
ce481361 by Ben Gamari at 2020-04-09T16:17:21-04:00
hadrian: Use --export-dynamic when linking iserv

As noticed in #17962, the make build system currently does this (see
3ce0e0ba) but the change was never ported to Hadrian.

- - - - -
fa66f143 by Ben Gamari at 2020-04-09T16:17:21-04:00
iserv: Don't pass --export-dynamic on FreeBSD

This is definitely a hack but it's probably the best we can do for now.
Hadrian does the right thing here by passing --export-dynamic only to
the linker.

- - - - -
39075176 by Ömer Sinan Ağacan at 2020-04-09T16:18:00-04:00
Fix CNF handling in compacting GC

Fixes #17937

Previously compacting GC simply ignored CNFs. This is mostly fine as
most (see "What about small compacts?" below) CNF objects don't have
outgoing pointers, and are "large" (allocated in large blocks) and large
objects are not moved or compacted.

However if we do GC *during* sharing-preserving compaction then the CNF
will have a hash table mapping objects that have been moved to the CNF
to their location in the CNF, to be able to preserve sharing.

This case is handled in the copying collector, in `scavenge_compact`,
where we evacuate hash table entries and then rehash the table.

Compacting GC ignored this case.

We now visit CNFs in all generations when threading pointers to the
compacted heap and thread hash table keys. A visited CNF is added to the
list `nfdata_chain`. After compaction is done, we re-visit the CNFs in
that list and rehash the tables.

The overhead is minimal: the list is static in `Compact.c`, and link
field is added to `StgCompactNFData` closure. Programs that don't use
CNFs should not be affected.

To test this CNF tests are now also run in a new way 'compacting_gc',
which just passes `-c` to the RTS, enabling compacting GC for the oldest
generation. Before this patch the result would be:

    Unexpected failures:
       compact_gc.run          compact_gc [bad exit code (139)] (compacting_gc)
       compact_huge_array.run  compact_huge_array [bad exit code (1)] (compacting_gc)

With this patch all tests pass. I can also pass `-c -DS` without any
failures.

What about small compacts? Small CNFs are still not handled by the
compacting GC. However so far I'm unable to write a test that triggers a
runtime panic ("update_fwd: unknown/strange object") by allocating a
small CNF in a compated heap. It's possible that I'm missing something
and it's not possible to have a small CNF.

NoFib Results:

--------------------------------------------------------------------------------
        Program           Size    Allocs    Instrs     Reads    Writes
--------------------------------------------------------------------------------
             CS          +0.1%      0.0%      0.0%     +0.0%     +0.0%
            CSD          +0.1%      0.0%      0.0%      0.0%      0.0%
             FS          +0.1%      0.0%      0.0%      0.0%      0.0%
              S          +0.1%      0.0%      0.0%      0.0%      0.0%
             VS          +0.1%      0.0%      0.0%      0.0%      0.0%
            VSD          +0.1%      0.0%     +0.0%     +0.0%     -0.0%
            VSM          +0.1%      0.0%     +0.0%     -0.0%      0.0%
           anna          +0.0%      0.0%     -0.0%     -0.0%     -0.0%
           ansi          +0.1%      0.0%     +0.0%     +0.0%     +0.0%
           atom          +0.1%      0.0%     +0.0%     +0.0%     +0.0%
         awards          +0.1%      0.0%     +0.0%     +0.0%     +0.0%
         banner          +0.1%      0.0%     +0.0%     +0.0%     +0.0%
     bernouilli          +0.1%      0.0%      0.0%     -0.0%     +0.0%
   binary-trees          +0.1%      0.0%     -0.0%     -0.0%      0.0%
          boyer          +0.1%      0.0%     +0.0%     +0.0%     +0.0%
         boyer2          +0.1%      0.0%     +0.0%     +0.0%     +0.0%
           bspt          +0.1%      0.0%     -0.0%     -0.0%     -0.0%
      cacheprof          +0.1%      0.0%     -0.0%     -0.0%     -0.0%
       calendar          +0.1%      0.0%     +0.0%     +0.0%     +0.0%
       cichelli          +0.1%      0.0%     +0.0%     +0.0%     +0.0%
        circsim          +0.1%      0.0%     +0.0%     +0.0%     +0.0%
       clausify          +0.1%      0.0%     -0.0%     +0.0%     +0.0%
  comp_lab_zift          +0.1%      0.0%     +0.0%     +0.0%     +0.0%
       compress          +0.1%      0.0%     +0.0%     +0.0%      0.0%
      compress2          +0.1%      0.0%     -0.0%      0.0%      0.0%
    constraints          +0.1%      0.0%     +0.0%     +0.0%     +0.0%
   cryptarithm1          +0.1%      0.0%     +0.0%     +0.0%     +0.0%
   cryptarithm2          +0.1%      0.0%     +0.0%     +0.0%     +0.0%
            cse          +0.1%      0.0%     +0.0%     +0.0%     +0.0%
   digits-of-e1          +0.1%      0.0%     +0.0%     -0.0%     -0.0%
   digits-of-e2          +0.1%      0.0%     -0.0%     -0.0%     -0.0%
         dom-lt          +0.1%      0.0%     +0.0%     +0.0%     +0.0%
          eliza          +0.1%      0.0%     +0.0%     +0.0%     +0.0%
          event          +0.1%      0.0%     +0.0%     +0.0%     +0.0%
    exact-reals          +0.1%      0.0%     +0.0%     +0.0%     +0.0%
         exp3_8          +0.1%      0.0%     +0.0%     -0.0%      0.0%
         expert          +0.1%      0.0%     +0.0%     +0.0%     +0.0%
 fannkuch-redux          +0.1%      0.0%     -0.0%      0.0%      0.0%
          fasta          +0.1%      0.0%     -0.0%     +0.0%     +0.0%
            fem          +0.1%      0.0%     -0.0%     +0.0%      0.0%
            fft          +0.1%      0.0%     -0.0%     +0.0%     +0.0%
           fft2          +0.1%      0.0%     +0.0%     +0.0%     +0.0%
       fibheaps          +0.1%      0.0%     +0.0%     +0.0%     +0.0%
           fish          +0.1%      0.0%     +0.0%     +0.0%     +0.0%
          fluid          +0.0%      0.0%     +0.0%     +0.0%     +0.0%
         fulsom          +0.1%      0.0%     -0.0%     +0.0%      0.0%
         gamteb          +0.1%      0.0%     +0.0%     +0.0%      0.0%
            gcd          +0.1%      0.0%     +0.0%     +0.0%     +0.0%
    gen_regexps          +0.1%      0.0%     -0.0%     +0.0%      0.0%
         genfft          +0.1%      0.0%     +0.0%     +0.0%     +0.0%
             gg          +0.1%      0.0%      0.0%     +0.0%     +0.0%
           grep          +0.1%      0.0%     -0.0%     +0.0%     +0.0%
         hidden          +0.1%      0.0%     +0.0%     -0.0%      0.0%
            hpg          +0.1%      0.0%     -0.0%     -0.0%     -0.0%
            ida          +0.1%      0.0%     +0.0%     +0.0%     +0.0%
          infer          +0.1%      0.0%     +0.0%      0.0%     -0.0%
        integer          +0.1%      0.0%     +0.0%     +0.0%     +0.0%
      integrate          +0.1%      0.0%     -0.0%     -0.0%     -0.0%
   k-nucleotide          +0.1%      0.0%     +0.0%     +0.0%      0.0%
          kahan          +0.1%      0.0%     +0.0%     +0.0%     +0.0%
        knights          +0.1%      0.0%     -0.0%     -0.0%     -0.0%
         lambda          +0.1%      0.0%     +0.0%     +0.0%     -0.0%
     last-piece          +0.1%      0.0%     +0.0%      0.0%      0.0%
           lcss          +0.1%      0.0%     +0.0%     +0.0%      0.0%
           life          +0.1%      0.0%     -0.0%     +0.0%     +0.0%
           lift          +0.1%      0.0%     +0.0%     +0.0%     +0.0%
         linear          +0.1%      0.0%     -0.0%     +0.0%      0.0%
      listcompr          +0.1%      0.0%     +0.0%     +0.0%     +0.0%
       listcopy          +0.1%      0.0%     +0.0%     +0.0%     +0.0%
       maillist          +0.1%      0.0%     +0.0%     -0.0%     -0.0%
         mandel          +0.1%      0.0%     +0.0%     +0.0%      0.0%
        mandel2          +0.1%      0.0%     +0.0%     +0.0%     +0.0%
           mate          +0.1%      0.0%     +0.0%      0.0%     +0.0%
        minimax          +0.1%      0.0%     -0.0%      0.0%     -0.0%
        mkhprog          +0.1%      0.0%     +0.0%     +0.0%     +0.0%
     multiplier          +0.1%      0.0%     +0.0%      0.0%      0.0%
         n-body          +0.1%      0.0%     +0.0%     +0.0%     +0.0%
       nucleic2          +0.1%      0.0%     +0.0%     +0.0%     +0.0%
           para          +0.1%      0.0%      0.0%     +0.0%     +0.0%
      paraffins          +0.1%      0.0%     +0.0%     -0.0%      0.0%
         parser          +0.1%      0.0%     -0.0%     -0.0%     -0.0%
        parstof          +0.1%      0.0%     +0.0%     +0.0%     +0.0%
            pic          +0.1%      0.0%     -0.0%     -0.0%      0.0%
       pidigits          +0.1%      0.0%     +0.0%     -0.0%     -0.0%
          power          +0.1%      0.0%     +0.0%     +0.0%     +0.0%
         pretty          +0.1%      0.0%     -0.0%     -0.0%     -0.1%
         primes          +0.1%      0.0%     -0.0%     -0.0%     -0.0%
      primetest          +0.1%      0.0%     -0.0%     -0.0%     -0.0%
         prolog          +0.1%      0.0%     -0.0%     -0.0%     -0.0%
         puzzle          +0.1%      0.0%     -0.0%     -0.0%     -0.0%
         queens          +0.1%      0.0%     +0.0%     +0.0%     +0.0%
        reptile          +0.1%      0.0%     -0.0%     -0.0%     +0.0%
reverse-complem          +0.1%      0.0%     +0.0%      0.0%     -0.0%
        rewrite          +0.1%      0.0%     -0.0%     -0.0%     -0.0%
           rfib          +0.1%      0.0%     +0.0%     +0.0%     +0.0%
            rsa          +0.1%      0.0%     -0.0%     +0.0%     -0.0%
            scc          +0.1%      0.0%     -0.0%     -0.0%     -0.1%
          sched          +0.1%      0.0%     +0.0%     +0.0%     +0.0%
            scs          +0.1%      0.0%     +0.0%     +0.0%     +0.0%
         simple          +0.1%      0.0%     -0.0%     -0.0%     -0.0%
          solid          +0.1%      0.0%     +0.0%     +0.0%     +0.0%
        sorting          +0.1%      0.0%     -0.0%     -0.0%     -0.0%
  spectral-norm          +0.1%      0.0%     +0.0%     +0.0%     +0.0%
         sphere          +0.1%      0.0%     -0.0%     -0.0%     -0.0%
         symalg          +0.1%      0.0%     -0.0%     -0.0%     -0.0%
            tak          +0.1%      0.0%     +0.0%     +0.0%     +0.0%
      transform          +0.1%      0.0%     +0.0%     +0.0%     +0.0%
       treejoin          +0.1%      0.0%     +0.0%     -0.0%     -0.0%
      typecheck          +0.1%      0.0%     +0.0%     +0.0%     +0.0%
        veritas          +0.0%      0.0%     +0.0%     +0.0%     +0.0%
           wang          +0.1%      0.0%      0.0%     +0.0%     +0.0%
      wave4main          +0.1%      0.0%     +0.0%     +0.0%     +0.0%
   wheel-sieve1          +0.1%      0.0%     +0.0%     +0.0%     +0.0%
   wheel-sieve2          +0.1%      0.0%     +0.0%     +0.0%     +0.0%
           x2n1          +0.1%      0.0%     +0.0%     +0.0%     +0.0%
--------------------------------------------------------------------------------
            Min          +0.0%      0.0%     -0.0%     -0.0%     -0.1%
            Max          +0.1%      0.0%     +0.0%     +0.0%     +0.0%
 Geometric Mean          +0.1%     -0.0%     -0.0%     -0.0%     -0.0%

Bumping numbers of nonsensical perf tests:

Metric Increase:
    T12150
    T12234
    T12425
    T13035
    T5837
    T6048

It's simply not possible for this patch to increase allocations, and
I've wasted enough time on these test in the past (see #17686). I think
these tests should not be perf tests, but for now I'll bump the numbers.

- - - - -
dce50062 by Sylvain Henry at 2020-04-09T16:18:44-04:00
Rts: show errno on failure (#18033)

- - - - -
045139f4 by Hécate at 2020-04-09T23:10:44-04:00
Add an example to liftIO and explain its purpose

- - - - -
101fab6e by Sebastian Graf at 2020-04-09T23:11:21-04:00
Special case `isConstraintKindCon` on `AlgTyCon`

Previously, the `tyConUnique` record selector would unfold into a huge
case expression that would be inlined in all call sites, such as the
`INLINE`-annotated `coreView`, see #18026. `constraintKindTyConKey` only
occurs as the `Unique` of an `AlgTyCon` anyway, so we can make the code
a lot more compact, but have to move it to GHC.Core.TyCon.

Metric Decrease:
    T12150
    T12234

- - - - -
f5212dfc by Sebastian Graf at 2020-04-09T23:11:57-04:00
DmdAnal: No need to attach a StrictSig to DataCon workers

In GHC.Types.Id.Make we were giving a strictness signature to every data
constructor wrapper Id that we weren't looking at in demand analysis
anyway. We used to use its CPR info, but that has its own CPR signature
now.

`Note [Data-con worker strictness]` then felt very out of place, so I
moved it to GHC.Core.DataCon.

- - - - -
75a185dc by Sylvain Henry at 2020-04-09T23:12:37-04:00
Hadrian: fix --summary

- - - - -
723062ed by Ömer Sinan Ağacan at 2020-04-10T09:18:14+03:00
testsuite: Move no_lint to the top level, tweak hie002

- We don't want to benchmark linting so disable lints in hie002 perf
  test

- Move no_lint to the top-level to be able to use it in tests other than
  those in `testsuite/tests/perf/compiler`.

- Filter out -dstg-lint in no_lint.

- hie002 allocation numbers on 32-bit are unstable, so skip it on 32-bit

Metric Decrease:
    hie002
    ManyConstructors
    T12150
    T12234
    T13035
    T1969
    T4801
    T9233
    T9961

- - - - -
bcafaa82 by Peter Trommler at 2020-04-10T19:29:33-04:00
Testsuite: mark T11531 fragile

The test depends on a link editor allowing undefined symbols in an ELF
shared object. This is the standard but it seems some distributions
patch their link editor. See the report by @hsyl20 in #11531.

Fixes #11531

- - - - -
0889f5ee by Takenobu Tani at 2020-04-12T11:44:52+09:00
testsuite: Fix comment for a language extension

[skip ci]

- - - - -
cd4f92b5 by Simon Peyton Jones at 2020-04-12T11:20:58-04:00
Significant refactor of Lint

This refactoring of Lint was triggered by #17923, which is
fixed by this patch.

The main change is this.  Instead of
   lintType :: Type -> LintM LintedKind
we now have
   lintType :: Type -> LintM LintedType

Previously, all of typeKind was effectively duplicate in lintType.
Moreover, since we have an ambient substitution, we still had to
apply the substition here and there, sometimes more than once. It
was all very tricky, in the end, and made my head hurt.

Now, lintType returns a fully linted type, with all substitutions
performed on it.  This is much simpler.

The same thing is needed for Coercions.  Instead of
  lintCoercion :: OutCoercion
               -> LintM (LintedKind, LintedKind,
                         LintedType, LintedType, Role)
we now have
  lintCoercion :: Coercion -> LintM LintedCoercion

Much simpler!  The code is shorter and less bug-prone.

There are a lot of knock on effects.  But life is now better.

Metric Decrease:
    T1969

- - - - -
0efaf301 by Josh Meredith at 2020-04-12T11:21:34-04:00
Implement extensible interface files

- - - - -
54ca66a7 by Ryan Scott at 2020-04-12T11:22:10-04:00
Use conLikeUserTyVarBinders to quantify field selector types

This patch:

1. Writes up a specification for how the types of top-level field
   selectors should be determined in a new section of the GHC User's
   Guide, and
2. Makes GHC actually implement that specification by using
   `conLikeUserTyVarBinders` in `mkOneRecordSelector` to preserve the
   order and specificity of type variables written by the user.

Fixes #18023.

- - - - -
35799dda by Ben Gamari at 2020-04-12T11:22:50-04:00
hadrian: Don't --export-dynamic on Darwin

When fixing #17962 I neglected to consider that --export-dynamic is only
supported on ELF platforms.

- - - - -
e8029816 by Alexis King at 2020-04-12T11:23:27-04:00
Add an INLINE pragma to Control.Category.>>>

This fixes #18013 by adding INLINE pragmas to both Control.Category.>>>
and GHC.Desugar.>>>. The functional change in this patch is tiny (just
two lines of pragmas!), but an accompanying Note explains in gory
detail what’s going on.

- - - - -
0da186c1 by Krzysztof Gogolewski at 2020-04-14T07:55:20-04:00
Change zipWith to zipWithEqual in a few places

- - - - -
074c1ccd by Andreas Klebinger at 2020-04-14T07:55:55-04:00
Small change to the windows ticker.

We already have a function to go from time to ms so use it.
Also expand on the state of timer resolution.

- - - - -
b69cc884 by Alp Mestanogullari at 2020-04-14T07:56:38-04:00
hadrian: get rid of unnecessary levels of nesting in source-dist

- - - - -
d0c3b069 by Julien Debon at 2020-04-14T07:57:16-04:00
doc (Foldable): Add examples to Data.Foldable

See #17929

- - - - -
5b08e0c0 by Ben Gamari at 2020-04-14T23:28:20-04:00
StgCRun: Enable unwinding only on Linux

It's broken on macOS due and SmartOS due to assembler differences
(#15207) so let's be conservative in enabling it. Also, refactor things
to make the intent clearer.

- - - - -
27cc2e7b by Ben Gamari at 2020-04-14T23:28:57-04:00
rts: Don't mark evacuate_large as inline

This function has two callsites and is quite large. GCC consequently
decides not to inline and warns instead. Given the situation, I can't
blame it. Let's just remove the inline specifier.

- - - - -
9853fc5e by Ben Gamari at 2020-04-14T23:29:48-04:00
base: Enable large file support for OFD locking impl.

Not only is this a good idea in general but this should also avoid
issue #17950 by ensuring that off_t is 64-bits.

- - - - -
7b41f21b by Matthew Pickering at 2020-04-14T23:30:24-04:00
Hadrian: Make -i paths absolute

The primary reason for this change is that ghcide does not work with
relative paths. It also matches what cabal and stack do, they always
pass absolute paths.

- - - - -
41230e26 by Daniel Gröber at 2020-04-14T23:31:01-04:00
Zero out pinned block alignment slop when profiling

The heap profiler currently cannot traverse pinned blocks because of
alignment slop. This used to just be a minor annoyance as the whole block
is accounted into a special cost center rather than the respective object's
CCS, cf. #7275. However for the new root profiler we would like to be able
to visit _every_ closure on the heap. We need to do this so we can get rid
of the current 'flip' bit hack in the heap traversal code.

Since info pointers are always non-zero we can in principle skip all the
slop in the profiler if we can rely on it being zeroed. This assumption
caused problems in the past though, commit a586b33f8e ("rts: Correct
handling of LARGE ARR_WORDS in LDV profiler"), part of !1118, tried to use
the same trick for BF_LARGE objects but neglected to take into account that
shrink*Array# functions don't ensure that slop is zeroed when not
compiling with profiling.

Later, commit 0c114c6599 ("Handle large ARR_WORDS in heap census (fix
as we will only be assuming slop is zeroed when profiling is on.

This commit also reduces the ammount of slop we introduce in the first
place by calculating the needed alignment before doing the allocation for
small objects where we know the next available address. For large objects
we don't know how much alignment we'll have to do yet since those details
are hidden behind the allocateMightFail function so there we continue to
allocate the maximum additional words we'll need to do the alignment.

So we don't have to duplicate all this logic in the cmm code we pull it
into the RTS allocatePinned function instead.

Metric Decrease:
    T7257
    haddock.Cabal
    haddock.base

- - - - -
15fa9bd6 by Daniel Gröber at 2020-04-14T23:31:01-04:00
rts: Expand and add more notes regarding slop

- - - - -
caf3f444 by Daniel Gröber at 2020-04-14T23:31:01-04:00
rts: allocatePinned: Fix confusion about word/byte units

- - - - -
c3c0f662 by Daniel Gröber at 2020-04-14T23:31:01-04:00
rts: Underline some Notes as is conventional

- - - - -
e149dea9 by Daniel Gröber at 2020-04-14T23:31:38-04:00
rts: Fix nomenclature in OVERWRITING_CLOSURE macros

The additional commentary introduced by commit 8916e64e5437 ("Implement
shrinkSmallMutableArray# and resizeSmallMutableArray#.") unfortunately got
this wrong. We set 'prim' to true in overwritingClosureOfs because we
_don't_ want to call LDV_recordDead().

The reason is because of this "inherently used" distinction made in the LDV
profiler so I rename the variable to be more appropriate.

- - - - -
1dd3d18c by Daniel Gröber at 2020-04-14T23:31:38-04:00
Remove call to LDV_RECORD_CREATE for array resizing

- - - - -
19de2fb0 by Daniel Gröber at 2020-04-14T23:31:38-04:00
rts: Assert LDV_recordDead is not called for inherently used closures

The comments make it clear LDV_recordDead should not be called for
inhererently used closures, so add an assertion to codify this fact.

- - - - -
0b934e30 by Ryan Scott at 2020-04-14T23:32:14-04:00
Bump template-haskell version to 2.17.0.0

This requires bumping the `exceptions` and `text` submodules to bring
in commits that bump their respective upper version bounds on
`template-haskell`.

Fixes #17645. Fixes #17696.

Note that the new `text` commit includes a fair number of additions
to the Haddocks in that library. As a result, Haddock has to do more
work during the `haddock.Cabal` test case, increasing the number of
allocations it requires. Therefore,

-------------------------
Metric Increase:
    haddock.Cabal
-------------------------

- - - - -
22cc8e51 by Ryan Scott at 2020-04-15T17:48:47-04:00
Fix #18052 by using pprPrefixOcc in more places

This fixes several small oversights in the choice of pretty-printing
function to use. Fixes #18052.

- - - - -
ec77b2f1 by Daniel Gröber at 2020-04-15T17:49:24-04:00
rts: ProfHeap: Fix wrong time in last heap profile sample

We've had this longstanding issue in the heap profiler, where the time of
the last sample in the profile is sometimes way off causing the rendered
graph to be quite useless for long runs.

It seems to me the problem is that we use mut_user_time() for the last
sample as opposed to getRTSStats(), which we use when calling heapProfile()
in GC.c.

The former is equivalent to getProcessCPUTime() but the latter does
some additional stuff:

    getProcessCPUTime() - end_init_cpu - stats.gc_cpu_ns -
    stats.nonmoving_gc_cpu_ns

So to fix this just use getRTSStats() in both places.

- - - - -
85fc32f0 by Sylvain Henry at 2020-04-17T12:45:25-04:00
Hadrian: fix dyn_o/dyn_hi rule (#17534)

- - - - -
bfde3b76 by Ryan Scott at 2020-04-17T12:46:02-04:00
Fix #18065 by fixing an InstCo oversight in Core Lint

There was a small thinko in Core Lint's treatment of `InstCo`
coercions that ultimately led to #18065. The fix: add an apostrophe.
That's it!

Fixes #18065.

Co-authored-by: Simon Peyton Jones <simonpj at microsoft.com>

- - - - -
a05348eb by Cale Gibbard at 2020-04-17T13:08:47-04:00
Change the fail operator argument of BindStmt to be a Maybe

Don't use noSyntaxExpr for it. There is no good way to defensively case
on that, nor is it clear one ought to do so.

- - - - -
79e27144 by John Ericson at 2020-04-17T13:08:47-04:00
Use trees that grow for rebindable operators for `<-` binds

Also add more documentation.

- - - - -
18bc16ed by Cale Gibbard at 2020-04-17T13:08:47-04:00
Use FailOperator in more places, define a couple datatypes (XBindStmtRn and XBindStmtTc) to help clarify the meaning of XBindStmt in the renamer and typechecker

- - - - -
84cc8394 by Simon Peyton Jones at 2020-04-18T13:20:29-04:00
Add a missing zonk in tcHsPartialType

I omitted a vital zonk when refactoring tcHsPartialType in
   commit 48fb3482f8cbc8a4b37161021e846105f980eed4
   Author: Simon Peyton Jones <simonpj at microsoft.com>
   Date:   Wed Jun 5 08:55:17 2019 +0100

   Fix typechecking of partial type signatures

This patch fixes it and adds commentary to explain why.

Fixes #18008

- - - - -
2ee96ac1 by Ben Gamari at 2020-04-18T13:21:05-04:00
gitlab-ci: Bump FreeBSD bootstrap compiler to 8.10.1

- - - - -
434312e5 by Ben Gamari at 2020-04-18T13:21:05-04:00
gitlab-ci: Enable FreeBSD job for so-labelled MRs

- - - - -
ddffb227 by Ben Gamari at 2020-04-18T13:21:05-04:00
gitlab-ci: Use rules syntax for conditional jobs

- - - - -
e2586828 by Ben Gamari at 2020-04-18T13:21:05-04:00
Bump hsc2hs submodule

- - - - -
15ab6cd5 by Ömer Sinan Ağacan at 2020-04-18T13:21:44-04:00
Improve prepForeignCall error reporting

Show parameters and description of the error code when ffi_prep_cif
fails.

This may be helpful for debugging #17018.

- - - - -
3ca52151 by Sylvain Henry at 2020-04-18T20:04:14+02:00
GHC.Core.Opt renaming

* GHC.Core.Op                  => GHC.Core.Opt
* GHC.Core.Opt.Simplify.Driver => GHC.Core.Opt.Driver
* GHC.Core.Opt.Tidy            => GHC.Core.Tidy
* GHC.Core.Opt.WorkWrap.Lib    => GHC.Core.Opt.WorkWrap.Utils

As discussed in:
 * https://mail.haskell.org/pipermail/ghc-devs/2020-April/018758.html
 * https://gitlab.haskell.org/ghc/ghc/issues/13009#note_264650

- - - - -
15312bbb by Sylvain Henry at 2020-04-18T20:04:46+02:00
Modules (#13009)

* SysTools
* Parser
* GHC.Builtin
* GHC.Iface.Recomp
* Settings

Update Haddock submodule

Metric Decrease:
    Naperian
    parsing001

- - - - -
eaed0a32 by Alexis King at 2020-04-19T03:16:44-04:00
Add missing addInScope call for letrec binders in OccurAnal

This fixes #18044, where a shadowed variable was incorrectly substituted
by the binder swap on the RHS of a floated-in letrec. This can only
happen when the uniques line up *just* right, so writing a regression
test would be very difficult, but at least the fix is small and
straightforward.

- - - - -
36882493 by Shayne Fletcher at 2020-04-20T04:36:43-04:00
Derive Ord instance for Extension

Metric Increase:
   T12150
   T12234

- - - - -
b43365ad by Simon Peyton Jones at 2020-04-20T04:37:20-04:00
Fix a buglet in redundant-constraint warnings

Ticket #18036 pointed out that we were reporting a redundant
constraint when it really really wasn't.

Turned out to be a buglet in the SkolemInfo for the
relevant implication constraint.  Easily fixed!

- - - - -
d5fae7da by Ömer Sinan Ağacan at 2020-04-20T14:39:28-04:00
Mark T12010 fragile on 32-bit

- - - - -
bca02fca by Adam Sandberg Ericsson at 2020-04-21T06:38:45-04:00
docs: drop note about not supporting shared libraries on unix systems

[skip ci]

- - - - -
6655f933 by Sylvain Henry at 2020-04-21T06:39:32-04:00
Use ParserFlags in GHC.Runtime.Eval (#17957)

Instead of passing `DynFlags` to functions such as `isStmt` and
`hasImport` in `GHC.Runtime.Eval` we pass `ParserFlags`. It's a much
simpler structure that can be created purely with `mkParserFlags'`.

- - - - -
70be0fbc by Sylvain Henry at 2020-04-21T06:39:32-04:00
GHC.Runtime: avoid DynFlags (#17957)

* add `getPlatform :: TcM Platform` helper
* remove unused `DynFlags` parameter from `emptyPLS`

- - - - -
35e43d48 by Sylvain Henry at 2020-04-21T06:39:32-04:00
Avoid DynFlags in Ppr code (#17957)

* replace `DynFlags` parameters with `SDocContext` parameters for a few
  Ppr related functions: `bufLeftRenderSDoc`, `printSDoc`,
  `printSDocLn`, `showSDocOneLine`.

* remove the use of `pprCols :: DynFlags -> Int` in Outputable. We
  already have the information via `sdocLineLength :: SDocContext ->
  Int`

- - - - -
ce5c2999 by Sylvain Henry at 2020-04-21T06:39:32-04:00
Avoid using sdocWithDynFlags (#17957)

Remove one use of `sdocWithDynFlags` from `GHC.CmmToLlvm.llvmCodeGen'`
and from `GHC.Driver.CodeOutput.profilingInitCode`

- - - - -
f2a98996 by Sylvain Henry at 2020-04-21T06:39:32-04:00
Avoid `sdocWithDynFlags` in `pprCLbl` (#17957)

* add a `DynFlags` parameter to `pprCLbl`
* put `maybe_underscore` and `pprAsmCLbl` in a `where` clause to avoid
  `DynFlags` parameters

- - - - -
747093b7 by Sylvain Henry at 2020-04-21T06:39:32-04:00
CmmToAsm DynFlags refactoring (#17957)

* Remove `DynFlags` parameter from `isDynLinkName`: `isDynLinkName` used
  to test the global `ExternalDynamicRefs` flag. Now we test it outside of
  `isDynLinkName`

* Add new fields into `NCGConfig`: current unit id, sse/bmi versions,
  externalDynamicRefs, etc.

* Replace many uses of `DynFlags` by `NCGConfig`

* Moved `BMI/SSE` datatypes into `GHC.Platform`

- - - - -
ffd7eef2 by Takenobu Tani at 2020-04-22T23:09:50-04:00
stg-spec: Modify file paths according to new module hierarchy

This patch updates file paths according to new module hierarchy [1]:

  * GHC/Stg/Syntax.hs       <= stgSyn/StgSyn.hs
  * GHC/Types/Literal.hs    <= basicTypes/Literal.hs
  * GHC/Types/CostCentre.hs <= profiling/CostCentre.hs

This patch also updates old file path [2]:

  * utils/genapply/Main.hs  <= utils/genapply/GenApply.hs

[1]: https://gitlab.haskell.org/ghc/ghc/-/wikis/Make-GHC-codebase-more-modular
[2]: commit 0cc4aad36f

[skip ci]

- - - - -
e8a5d81b by Jonathan DK Gibbons at 2020-04-22T23:10:28-04:00
Refactor the `MatchResult` type in the desugarer

This way, it does a better job of proving whether or not the fail operator is used.

- - - - -
dcb7fe5a by John Ericson at 2020-04-22T23:10:28-04:00
Remove panic in dsHandleMonadicFailure

Rework dsHandleMonadicFailure to be correct by construction instead of
using an unreachable panic.

- - - - -
cde23cd4 by John Ericson at 2020-04-22T23:10:28-04:00
Inline `adjustMatchResult`

It is just `fmap`

- - - - -
72cb6bcc by John Ericson at 2020-04-22T23:10:28-04:00
Generalize type of `matchCanFail`

- - - - -
401f7bb3 by John Ericson at 2020-04-22T23:10:28-04:00
`MatchResult'` -> `MatchResult`

Inline `MatchResult` alias accordingly.

- - - - -
6c9fae23 by Alexis King at 2020-04-22T23:11:12-04:00
Mark DataCon wrappers CONLIKE

Now that DataCon wrappers don’t inline until phase 0 (see commit
b78cc64e923716ac0512c299f42d4d0012306c05), it’s important that
case-of-known-constructor and RULE matching be able to see saturated
applications of DataCon wrappers in unfoldings. Making them conlike is a
natural way to do it, since they are, in fact, precisely the sort of
thing the CONLIKE pragma exists to solve.

Fixes #18012.

This also bumps the version of the parsec submodule to incorporate a
patch that avoids a metric increase on the haddock perf tests. The
increase was not really a flaw in this patch, as parsec was implicitly
relying on inlining heuristics. The patch to parsec just adds some
INLINABLE pragmas, and we get a nice performance bump out of it (well
beyond the performance we lost from this patch).

Metric Decrease:
    T12234
    WWRec
    haddock.Cabal
    haddock.base
    haddock.compiler

- - - - -
48b8951e by Roland Senn at 2020-04-22T23:11:51-04:00
Fix tab-completion for :break (#17989)

In tab-completion for the `:break` command, only those
identifiers should be shown, that are accepted in the
`:break` command. Hence these identifiers must be

- defined in an interpreted module
- top-level
- currently in scope
- listed in a `ModBreaks` value as a possible breakpoint.

The identifiers my be qualified or unqualified.

To get all possible top-level breakpoints for tab-completeion
with the correct qualification do:

1. Build the  list called `pifsBreaks` of all pairs of
(Identifier, module-filename) from the `ModBreaks` values.
Here all identifiers are unqualified.

2. Build the list called `pifInscope` of all pairs of
(Identifiers, module-filename) with identifiers from
the `GlobalRdrEnv`. Take only those identifiers that are
in scope and have the  correct prefix.
Here the identifiers may be qualified.

3. From the `pifInscope` list seclect all pairs that can be
found in the `pifsBreaks` list, by comparing only the
unqualified part of the identifier.
The remaining identifiers can be used for tab-completion.

This ensures, that we show only identifiers, that can be used
in a `:break` command.

- - - - -
34a45ee6 by Peter Trommler at 2020-04-22T23:12:27-04:00
PPC NCG: Add DWARF constants and debug labels

Fixes #11261

- - - - -
ffde2348 by Simon Peyton Jones at 2020-04-22T23:13:06-04:00
Do eager instantation in terms

This patch implements eager instantiation, a small but critical change
to the type inference engine, #17173.  The main change is this:

  When inferring types, always return an instantiated type
  (for now, deeply instantiated; in future shallowly instantiated)

There is more discussion in
https://www.tweag.io/posts/2020-04-02-lazy-eager-instantiation.html

There is quite a bit of refactoring in this patch:

* The ir_inst field of GHC.Tc.Utils.TcType.InferResultk
  has entirely gone.  So tcInferInst and tcInferNoInst have collapsed
  into tcInfer.

* Type inference of applications, via tcInferApp and
  tcInferAppHead, are substantially refactored, preparing
  the way for Quick Look impredicativity.

* New pure function GHC.Tc.Gen.Expr.collectHsArgs and applyHsArgs
  are beatifully dual.  We can see the zipper!

* GHC.Tc.Gen.Expr.tcArgs is now much nicer; no longer needs to return
  a wrapper

* In HsExpr, HsTypeApp now contains the the actual type argument,
  and is used in desugaring, rather than putting it in a mysterious
  wrapper.

* I struggled a bit with good error reporting in
  Unify.matchActualFunTysPart. It's a little bit simpler than before,
  but still not great.

Some smaller things

* Rename tcPolyExpr --> tcCheckExpr
         tcMonoExpr --> tcLExpr
* tcPatSig moves from GHC.Tc.Gen.HsType to GHC.Tc.Gen.Pat

Metric Decrease:
    T9961

Reduction of 1.6% in comiler allocation on T9961, I think.

- - - - -
6f84aca3 by Ben Gamari at 2020-04-22T23:13:43-04:00
rts: Ensure that sigaction structs are initialized

I noticed these may have uninitialized fields when looking into #18037.
The reporter says that zeroing them doesn't fix the MSAN failures they
observe but zeroing them is the right thing to do regardless.

- - - - -
c29f0fa6 by Andreas Klebinger at 2020-04-22T23:14:21-04:00
Add "ddump-cmm-opt" as alias for "ddump-opt-cmm".

- - - - -
4b4a8b60 by Ben Gamari at 2020-04-22T23:14:57-04:00
llvmGen: Remove -fast-llvm flag

Issue #18076 drew my attention to the undocumented `-fast-llvm` flag for
the LLVM code generator introduced in
22733532171330136d87533d523f565f2a4f102f. Speaking to Moritz about this,
the motivation for this flag was to avoid potential incompatibilities
between LLVM and the assembler/linker toolchain by making LLVM
responsible for machine-code generation.

Unfortunately, this cannot possibly work: the LLVM backend's mangler
performs a number of transforms on the assembler generated by LLVM that
are necessary for correctness. These are currently:

 * mangling Haskell functions' symbol types to be `object` instead of
   `function` on ELF platforms (necessary for tables-next-to-code)
 * mangling AVX instructions to ensure that we don't assume alignment
   (which LLVM otherwise does)
 * mangling Darwin's  subsections-via-symbols directives

Given that these are all necessary I don't believe that we can support
`-fast-llvm`. Let's rather remove it.

- - - - -
831b6642 by Moritz Angermann at 2020-04-22T23:15:33-04:00
Fix build warning; add more informative information to the linker; fix linker for empty sections

- - - - -
c409961a by Ryan Scott at 2020-04-22T23:16:12-04:00
Update commentary and slightly refactor GHC.Tc.Deriv.Infer

There was some out-of-date commentary in `GHC.Tc.Deriv.Infer` that
has been modernized. Along the way, I removed the `bad` constraints
in `simplifyDeriv`, which did not serve any useful purpose (besides
being printed in debugging output).

Fixes #18073.

- - - - -
125aa2b8 by Ömer Sinan Ağacan at 2020-04-22T23:16:51-04:00
Remove leftover comment in tcRnModule', redundant bind

The code for the comment was moved in dc8c03b2a5c but the comment was
forgotten.

- - - - -
8ea37b01 by Sylvain Henry at 2020-04-22T23:17:34-04:00
RTS: workaround a Linux kernel bug in timerfd

Reading a timerfd may return 0: https://lkml.org/lkml/2019/8/16/335.

This is currently undocumented behavior and documentation "won't happen
anytime soon" (https://lkml.org/lkml/2020/2/13/295).

With this patch, we just ignore the result instead of crashing. It may
fix #18033 but we can't be sure because we don't have enough
information.

See also this discussion about the kernel bug:
https://github.com/Azure/sonic-swss-common/pull/302/files/1f070e7920c2e5d63316c0105bf4481e73d72dc9

- - - - -
cd8409c2 by Ryan Scott at 2020-04-23T11:39:24-04:00
Create di_scoped_tvs for associated data family instances properly

See `Note [Associated data family instances and di_scoped_tvs]` in
`GHC.Tc.TyCl.Instance`, which explains all of the moving parts.

Fixes #18055.

- - - - -
339e8ece by Ben Gamari at 2020-04-23T11:40:02-04:00
hadrian/ghci: Allow arguments to be passed to GHCi

Previously the arguments passed to hadrian/ghci were passed both to
`hadrian` and GHCi. This is rather odd given that there are essentially
not arguments in the intersection of the two. Let's just pass them to
GHCi; this allows `hadrian/ghci -Werror`.

- - - - -
5946c85a by Ben Gamari at 2020-04-23T11:40:38-04:00
testsuite: Don't attempt to read .std{err,out} files if they don't exist

Simon reports that he was previously seeing framework failures due to
an attempt to read the non-existing T13456.stderr. While I don't know
exactly what this is due to, it does seem like a non-existing
.std{out,err} file should be equivalent to an empty file. Teach the
testsuite driver to treat it as such.

- - - - -
c42754d5 by John Ericson at 2020-04-23T18:32:43-04:00
Trees That Grow refactor for `ConPat` and `CoPat`

- `ConPat{In,Out}` -> `ConPat`

- `CoPat` -> `XPat (CoPat ..)`

Note that `GHC.HS.*` still uses `HsWrap`, but only when `p ~ GhcTc`.
After this change, moving the type family instances out of `GHC.HS.*` is
sufficient to break the cycle.

Add XCollectPat class to decide how binders are collected from XXPat based on the pass.

Previously we did this with IsPass, but that doesn't work for Haddock's
DocNameI, and the constraint doesn't express what actual distinction is being
made. Perhaps a class for collecting binders more generally is in order, but we
haven't attempted this yet.

Pure refactor of code around ConPat

 - InPat/OutPat synonyms removed

 - rename several identifiers

 - redundant constraints removed

 - move extension field in ConPat to be first

 - make ConPat use record syntax more consistently

Fix T6145 (ConPatIn became ConPat)

Add comments from SPJ.

Add comment about haddock's use of CollectPass.

Updates haddock submodule.

- - - - -
72da0c29 by mniip at 2020-04-23T18:33:21-04:00
Add :doc to GHC.Prim

- - - - -
2c23e2e3 by mniip at 2020-04-23T18:33:21-04:00
Include docs for non-primop entries in primops.txt as well

- - - - -
0ac29c88 by mniip at 2020-04-23T18:33:21-04:00
GHC.Prim docs: note and test

- - - - -
b0fbfc75 by John Ericson at 2020-04-24T12:07:14-04:00
Switch order on `GhcMake.IsBoot`

In !1798 we were requested to replace many `Bool`s with this data type.
But those bools had `False` meaning `NotBoot`, so the `Ord` instance
would be flipped if we use this data-type as-is.

Since the planned formally-`Bool` occurrences vastly outnumber the
current occurrences, we figured it would be better to conform the `Ord`
instance to how the `Bool` is used now, fixing any issues, rather than
fix them currently with the bigger refactor later in !1798. That way,
!1798 can be a "pure" refactor with no behavioral changes.

- - - - -
af332442 by Sylvain Henry at 2020-04-26T13:55:14-04:00
Modules: Utils and Data (#13009)

Update Haddock submodule

Metric Increase:
   haddock.compiler

- - - - -
cd4434c8 by Sylvain Henry at 2020-04-26T13:55:16-04:00
Fix misleading Ptr phantom type in SerializedCompact (#15653)

- - - - -
22bf5c73 by Ömer Sinan Ağacan at 2020-04-26T13:55:22-04:00
Tweak includes in non-moving GC headers

We don't use hash tables in non-moving GC so remove the includes.

This breaks Compact.c as existing includes no longer include Hash.h, so
include Hash.h explicitly in Compact.c.

- - - - -
99823ed2 by Sylvain Henry at 2020-04-27T20:24:46-04:00
TH: fix Show/Eq/Ord instances for Bytes (#16457)

We shouldn't compare pointer values but the actual bytes.

- - - - -
c62271a2 by Alp Mestanogullari at 2020-04-27T20:25:33-04:00
hadrian: always capture both stdout and stderr when running a builder fails

The idea being that when a builder('s command) fails, we quite likely want to
have all the information available to figure out why. Depending on the builder
_and_ the particular problem, the useful bits of information can be printed
on stdout or stderr.

We accomplish this by defining a simple wrapper for Shake's `cmd` function,
that just _always_ captures both streams in case the command returns a non-zero
exit code, and by using this wrapper everywhere in `hadrian/src/Builder.hs`.

Fixes #18089.

- - - - -
4b9764db by Ryan Scott at 2020-04-28T15:40:04-04:00
Define a Quote IO instance

Fixes #18103.

- - - - -
518a63d4 by Ryan Scott at 2020-04-28T15:40:42-04:00
Make boxed 1-tuples have known keys

Unlike other tuples, which use special syntax and are "known" by way
of a special `isBuiltInOcc_maybe` code path, boxed 1-tuples do not
use special syntax. Therefore, in order to make sure that the
internals of GHC are aware of the `data Unit a = Unit a` definition
in `GHC.Tuple`, we give `Unit` known keys. For the full details, see
`Note [One-tuples] (Wrinkle: Make boxed one-tuple names have known keys)`
in `GHC.Builtin.Types`.

Fixes #18097.

- - - - -
2cfc4ab9 by Sylvain Henry at 2020-04-30T01:56:56-04:00
Document backpack fields in DynFlags

- - - - -
10a2ba90 by Sylvain Henry at 2020-04-30T01:56:56-04:00
Refactor UnitInfo

* Rename InstalledPackageInfo into GenericUnitInfo

The name InstalledPackageInfo is only kept for alleged backward
compatibility reason in Cabal. ghc-boot has its own stripped down copy
of this datatype but it doesn't need to keep the name. Internally we
already use type aliases (UnitInfo in GHC, PackageCacheFormat in
ghc-pkg).

* Rename UnitInfo fields: add "unit" prefix and fix misleading names

* Add comments on every UnitInfo field

* Rename SourcePackageId into PackageId

"Package" already indicates that it's a "source package". Installed
package components are called units.

Update Haddock submodule

- - - - -
69562e34 by Sylvain Henry at 2020-04-30T01:56:56-04:00
Remove unused `emptyGenericUnitInfo`

- - - - -
9e2c8e0e by Sylvain Henry at 2020-04-30T01:56:56-04:00
Refactor UnitInfo load/store from databases

Converting between UnitInfo stored in package databases and UnitInfo as
they are used in ghc-pkg and ghc was done in a very convoluted way (via
BinaryStringRep and DbUnitModuleRep type classes using fun deps, etc.).
It was difficult to understand and even more to modify (I wanted to
try to use a GADT for UnitId but fun deps got in the way).

The new code uses much more straightforward functions to convert between
the different representations. Much simpler.

- - - - -
ea717aa4 by Sylvain Henry at 2020-04-30T01:56:56-04:00
Factorize mungePackagePaths code

This patch factorizes the duplicated code used in ghc-pkg and in GHC to
munge package paths/urls.

It also fixes haddock-html munging in GHC (allowed to be either a file
or a url) to mimic ghc-pkg behavior.

- - - - -
10d15f1e by Sylvain Henry at 2020-04-30T01:56:56-04:00
Refactoring unit management code

Over the years the unit management code has been modified a lot to keep
up with changes in Cabal (e.g. support for several library components in
the same package), to integrate BackPack, etc. I found it very hard to
understand as the terminology wasn't consistent, was referring to past
concepts, etc.

The terminology is now explained as clearly as I could in the Note
"About Units" and the code is refactored to reflect it.

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

Many names were misleading: UnitId is not an Id but could be a virtual
unit (an indefinite one instantiated on the fly), IndefUnitId
constructor may contain a definite instantiated unit, etc.

   * Rename IndefUnitId into InstantiatedUnit
   * Rename IndefModule into InstantiatedModule
   * Rename UnitId type into Unit
   * Rename IndefiniteUnitId constructor into VirtUnit
   * Rename DefiniteUnitId constructor into RealUnit
   * Rename packageConfigId into mkUnit
   * Rename getPackageDetails into unsafeGetUnitInfo
   * Rename InstalledUnitId into UnitId

Remove references to misleading ComponentId: a ComponentId is just an
indefinite unit-id to be instantiated.

   * Rename ComponentId into IndefUnitId
   * Rename ComponentDetails into UnitPprInfo
   * Fix display of UnitPprInfo with empty version: this is now used for
     units dynamically generated by BackPack

Generalize several types (Module, Unit, etc.) so that they can be used
with different unit identifier types: UnitKey, UnitId, Unit, etc.

   * GenModule: Module, InstantiatedModule and InstalledModule are now
     instances of this type
   * Generalize DefUnitId, IndefUnitId, Unit, InstantiatedUnit,
     PackageDatabase

Replace BackPack fake "hole" UnitId by a proper HoleUnit constructor.

Add basic support for UnitKey. They should be used more in the future to
avoid mixing them up with UnitId as we do now.

Add many comments.

Update Haddock submodule

- - - - -
8bfb0219 by Sylvain Henry at 2020-04-30T01:56:56-04:00
Unit: split and rename modules

Introduce GHC.Unit.* hierarchy for everything concerning units, packages
and modules.

Update Haddock submodule

- - - - -
71484b09 by Alexis King at 2020-04-30T01:57:35-04:00
Allow block arguments in arrow control operators

Arrow control operators have their own entries in the grammar, so they
did not cooperate with BlockArguments. This was just a minor oversight,
so this patch adjusts the grammar to add the desired behavior.

fixes #18050

- - - - -
a48cd2a0 by Alexis King at 2020-04-30T01:57:35-04:00
Allow LambdaCase to be used as a command in proc notation

- - - - -
f4d3773c by Alexis King at 2020-04-30T01:57:35-04:00
Document BlockArguments/LambdaCase support in arrow notation

- - - - -
5bdfdd13 by Simon Peyton Jones at 2020-04-30T01:58:15-04:00
Add tests for #17873

- - - - -
19b701c2 by Simon Peyton Jones at 2020-04-30T07:30:13-04:00
Mark rule args as non-tail-called

This was just an omission...b I'd failed to call markAllNonTailCall on
rule args.  I think this bug has been here a long time, but it's quite
hard to trigger.

Fixes #18098

- - - - -
014ef4a3 by Matthew Pickering at 2020-04-30T07:30:50-04:00
Hadrian: Improve tool-args command to support more components

There is a new command to hadrian, tool:path/to/file.hs, which returns
the options needed to compile that file in GHCi.

This is now used in the ghci script with argument `ghc/Main.hs` but its
main purpose is to support the new multi-component branch of ghcide.

- - - - -
2aa67611 by Ben Gamari at 2020-04-30T21:34:44-04:00
nonmoving: Clear bitmap after initializing block size

Previously nonmovingInitSegment would clear the bitmap before
initializing the segment's block size. This is broken since
nonmovingClearBitmap looks at the segment's block size to determine how
much bitmap to clear.

- - - - -
54dad3cf by Ben Gamari at 2020-04-30T21:34:44-04:00
nonmoving: Explicitly memoize block count

A profile cast doubt on whether the compiler hoisted the bound out the
loop as I would have expected here. It turns out it did but nevertheless
it seems clearer to just do this manually.

- - - - -
99ff8145 by Ben Gamari at 2020-04-30T21:34:44-04:00
nonmoving: Eagerly flush all capabilities' update remembered sets

(cherry picked from commit 2fa79119570b358a4db61446396889b8260d7957)

- - - - -
05b0a9fd by Ömer Sinan Ağacan at 2020-04-30T21:35:24-04:00
Remove OneShotInfo field of LFReEntrant, document OneShotInfo

The field is only used in withNewTickyCounterFun and it's easier to
directly pass a parameter for one-shot info to withNewTickyCounterFun
instead of passing it via LFReEntrant. This also makes !2842 simpler.

Other changes:

- New Note (by SPJ) [OneShotInfo overview] added.
- Arity argument of thunkCode removed as it's always 0.

- - - - -
a43620c6 by Ömer Sinan Ağacan at 2020-04-30T21:35:24-04:00
GHC.StgToCmm.Ticky: remove a few unused stuff

- - - - -
780de9e1 by Sylvain Henry at 2020-05-01T10:37:39-04:00
Use platform in Iface Binary

- - - - -
f8386c7b by Sylvain Henry at 2020-05-01T10:37:39-04:00
Refactor PprDebug handling

If `-dppr-debug` is set, then PprUser and PprDump styles are silently
replaced with PprDebug style. This was done in `mkUserStyle` and
`mkDumpStyle` smart constructors. As a consequence they needed a
DynFlags parameter.

Now we keep the original PprUser and PprDump styles until they are used
to create an `SDocContext`. I.e. the substitution is only performed in
`initSDocContext`.

- - - - -
b3df9e78 by Sylvain Henry at 2020-05-01T10:37:39-04:00
Remove PprStyle param of logging actions

Use `withPprStyle` instead to apply a specific style to a SDoc.

- - - - -
de9fc995 by Sylvain Henry at 2020-05-01T10:37:39-04:00
Fully remove PprDebug

PprDebug was a pain to deal with consistently as it is implied by
`-dppr-debug` but it isn't really a PprStyle. We remove it completely
and query the appropriate SDoc flag instead (`sdocPprDebug`) via
helpers (`getPprDebug` and its friends).

- - - - -
8b51fcbd by Sebastian Graf at 2020-05-01T10:38:16-04:00
PmCheck: Only call checkSingle if we would report warnings

- - - - -
fd7ea0fe by Sebastian Graf at 2020-05-01T10:38:16-04:00
PmCheck: Pick up `EvVar`s bound in `HsWrapper`s for long-distance info

`HsWrapper`s introduce evidence bindings through `WpEvLam` which the
pattern-match coverage checker should be made aware of.

Failing to do so caused #18049, where the resulting impreciseness of
imcompleteness warnings seemingly contradicted with
`-Winaccessible-code`.

The solution is simple: Collect all the evidence binders of an
`HsWrapper` and add it to the ambient `Deltas` before desugaring
the wrapped expression.

But that means we pick up many more evidence bindings, even when they
wrap around code without a single pattern match to check! That regressed
`T3064` by over 300%, so now we are adding long-distance info lazily
through judicious use of `unsafeInterleaveIO`.

Fixes #18049.

- - - - -
7bfe9ac5 by Ben Gamari at 2020-05-03T04:41:33-04:00
rts: Enable tracing of nonmoving heap census with -ln

Previously this was not easily available to the user. Fix this.
Non-moving collection lifecycle events are now reported with -lg.

- - - - -
c560dd07 by Ben Gamari at 2020-05-03T04:41:33-04:00
users guide: Move eventlog documentation users guide

- - - - -
02543d5e by Ben Gamari at 2020-05-03T04:41:33-04:00
users guide: Add documentation for non-moving GC events

- - - - -
b465dd45 by Alexis King at 2020-05-03T04:42:12-04:00
Flatten nested casts in the simple optimizer

Normally, we aren’t supposed to generated any nested casts, since mkCast
takes care to flatten them, but the simple optimizer didn’t use mkCast,
so they could show up after inlining. This isn’t really a problem, since
the simplifier will clean them up immediately anyway, but it can clutter
the -ddump-ds output, and it’s an extremely easy fix.

closes #18112

- - - - -
8bdc03d6 by Simon Peyton Jones at 2020-05-04T01:56:59-04:00
Don't return a panic in tcNestedSplice

In GHC.Tc.Gen.Splice.tcNestedSplice we were returning a
typechecked expression of "panic". That is usually OK, because
the result is discarded.  But it happens that tcApp now looks at
the typechecked expression, trivially, to ask if it is tagToEnum.
So being bottom is bad.

Moreover a debug-trace might print it out.

So better to return a civilised expression, even though it is
usually discarded.

- - - - -
0bf640b1 by Baldur Blöndal at 2020-05-04T01:57:36-04:00
Don't require parentheses around via type (`-XDerivingVia'). Fixes #18130".

- - - - -
30272412 by Artem Pelenitsyn at 2020-05-04T13:19:59-04:00
Remove custom ExceptionMonad class (#18075) (updating haddock submodule accordingly)

- - - - -
b9f7c08f by jneira at 2020-05-04T13:20:37-04:00
Remove unused hs-boot file

- - - - -
1d8f80cd by Sylvain Henry at 2020-05-05T03:22:46-04:00
Remove references to -package-key

* remove references to `-package-key` which has been removed in 2016
  (240ddd7c39536776e955e881d709bbb039b48513)

* remove support for `-this-package-key` which has been deprecated at the
  same time

- - - - -
7bc3a65b by Sylvain Henry at 2020-05-05T03:23:31-04:00
Remove SpecConstrAnnotation (#13681)

This has been deprecated since 2013. Use GHC.Types.SPEC instead.

Make GHC.Exts "not-home" for haddock

Metric Decrease:
   haddock.base

- - - - -
3c862f63 by DenisFrezzato at 2020-05-05T03:24:15-04:00
Fix Haskell98 short description in documentation

- - - - -
2420c555 by Ryan Scott at 2020-05-05T03:24:53-04:00
Add regression tests for #16244, #16245, #16758

Commit e3c374cc5bd7eb49649b9f507f9f7740697e3f70 ended up
fixing quite a few bugs:

* This commit fixes #16244 completely. A regression test has been
  added.
* This commit fixes one program from #16245. (The program in
  https://gitlab.haskell.org/ghc/ghc/issues/16245#note_211369 still
  panics, and the program in
  https://gitlab.haskell.org/ghc/ghc/issues/16245#note_211400 still
  loops infinitely.) A regression test has been added for this
  program.
* This commit fixes #16758. Accordingly, this patch removes the
  `expect_broken` label from the `T16758` test case, moves it from
  `should_compile` to `should_fail` (as it should produce an error
  message), and checks in the expected stderr.

- - - - -
40c71c2c by Sylvain Henry at 2020-05-05T03:25:31-04:00
Fix colorized error messages (#18128)

In b3df9e780fb2f5658412c644849cd0f1e6f50331 I broke colorized messages
by using "dump" style instead of "user" style. This commits fixes it.

- - - - -
7ab6ab09 by Richard Eisenberg at 2020-05-06T04:39:32-04:00
Refactor hole constraints.

Previously, holes (both expression holes / out of scope variables and
partial-type-signature wildcards) were emitted as *constraints* via
the CHoleCan constructor. While this worked fine for error reporting,
there was a fair amount of faff in keeping these constraints in line.
In particular, and unlike other constraints, we could never change
a CHoleCan to become CNonCanonical. In addition:
 * the "predicate" of a CHoleCan constraint was really the type
   of the hole, which is not a predicate at all
 * type-level holes (partial type signature wildcards) carried
   evidence, which was never used
 * tcNormalise (used in the pattern-match checker) had to create
   a hole constraint just to extract it again; it was quite messy

The new approach is to record holes directly in WantedConstraints.
It flows much more nicely now.

Along the way, I did some cleaning up of commentary in
GHC.Tc.Errors.Hole, which I had a hard time understanding.

This was instigated by a future patch that will refactor
the way predicates are handled. The fact that CHoleCan's
"predicate" wasn't really a predicate is incompatible with
that future patch.

No test case, because this is meant to be purely internal.

It turns out that this change improves the performance of
the pattern-match checker, likely because fewer constraints
are sloshing about in tcNormalise. I have not investigated
deeply, but an improvement is not a surprise here:

-------------------------
Metric Decrease:
    PmSeriesG
-------------------------

- - - - -
420b957d by Ben Gamari at 2020-05-06T04:40:08-04:00
rts: Zero block flags with -DZ

Block flags are very useful for determining the state of a block.
However, some block allocator users don't touch them, leading to
misleading values. Ensure that we zero then when zero-on-gc is set. This
is safe and makes the flags more useful during debugging.

- - - - -
740b3b8d by Ben Gamari at 2020-05-06T04:40:08-04:00
nonmoving: Fix incorrect failed_to_evac value during deadlock gc

Previously we would incorrectly set the failed_to_evac flag if we
evacuated a value due to a deadlock GC. This would cause us to mark more
things as dirty than strictly necessary. It also turned up a nasty but
which I will fix next.

- - - - -
b2d72c75 by Ben Gamari at 2020-05-06T04:40:08-04:00
nonmoving: Fix handling of dirty objects

Previously we (incorrectly) relied on failed_to_evac to be "precise".
That is, we expected it to only be true if *all* of an object's fields
lived outside of the non-moving heap. However, does not match the
behavior of failed_to_evac, which is true if *any* of the object's
fields weren't promoted (meaning that some others *may* live in the
non-moving heap).

This is problematic as we skip the non-moving write barrier for dirty
objects (which we can only safely do if *all* fields point outside of
the non-moving heap).

Clearly this arises due to a fundamental difference in the behavior
expected of failed_to_evac in the moving and non-moving collector.
e.g., in the moving collector it is always safe to conservatively say
failed_to_evac=true whereas in the non-moving collector the safe value
is false.

This issue went unnoticed as I never wrote down the dirtiness
invariant enforced by the non-moving collector. We now define this
invariant as

    An object being marked as dirty implies that all of its fields are
    on the mark queue (or, equivalently, update remembered set).

To maintain this invariant we teach nonmovingScavengeOne to push the
fields of objects which we fail to evacuate to the update remembered
set. This is a simple and reasonably cheap solution and avoids the
complexity and fragility that other, more strict alternative invariants
would require.

All of this is described in a new Note, Note [Dirty flags in the
non-moving collector] in NonMoving.c.

- - - - -
9f3e6884 by Zubin Duggal at 2020-05-06T04:41:08-04:00
Allow atomic update of NameCache in readHieFile

The situation arises in ghcide where multiple different threads may need to
update the name cache, therefore with the older interface it could happen
that you start reading a hie file with name cache A and produce name cache
A + B, but another thread in the meantime updated the namecache to A +
C. Therefore if you write the new namecache you will lose the A' updates
from the second thread.

Updates haddock submodule

- - - - -
edec6a6c by Ryan Scott at 2020-05-06T04:41:57-04:00
Make isTauTy detect higher-rank contexts

Previously, `isTauTy` would only detect higher-rank `forall`s, not
higher-rank contexts, which led to some minor bugs observed
in #18127. Easily fixed by adding a case for
`(FunTy InvisArg _ _)`.

Fixes #18127.

- - - - -
a95e7fe0 by Ömer Sinan Ağacan at 2020-05-06T04:42:39-04:00
ELF linker: increment curSymbol after filling in fields of current entry

The bug was introduced in a8b7cef4d45 which added a field to the
`symbols` array elements and then updated this code incorrectly:

    - oc->symbols[curSymbol++] = nm;
    + oc->symbols[curSymbol++].name = nm;
    + oc->symbols[curSymbol].addr = symbol->addr;

- - - - -
cab1871a by Sylvain Henry at 2020-05-06T04:43:21-04:00
Move LeadingUnderscore into Platform (#17957)

Avoid direct use of DynFlags to know if symbols must be prefixed by an
underscore.

- - - - -
94e7c563 by Sylvain Henry at 2020-05-06T04:43:21-04:00
Don't use DynFlags in showLinkerState (#17957)

- - - - -
9afd9251 by Ryan Scott at 2020-05-06T04:43:58-04:00
Refactoring: Use bindSigTyVarsFV in rnMethodBinds

`rnMethodBinds` was explicitly using `xoptM` to determine if
`ScopedTypeVariables` is enabled before bringing type variables
bound by the class/instance header into scope. However, this `xoptM`
logic is already performed by the `bindSigTyVarsFV` function. This
patch uses `bindSigTyVarsFV` in `rnMethodBinds` to reduce the number
of places where we need to consult if `ScopedTypeVariables` is on.

This is purely refactoring, and there should be no user-visible
change in behavior.

- - - - -
6f6d72b2 by Brian Foley at 2020-05-08T15:29:25-04:00
Remove further dead code found by a simple Python script.

Avoid removing some functions that are part of an API even
though they're not used in-tree at the moment.

- - - - -
78bf8bf9 by Julien Debon at 2020-05-08T15:29:28-04:00
Add doc examples for Bifoldable

See #17929

- - - - -
66f0a847 by Julien Debon at 2020-05-08T15:29:29-04:00
doc (Bitraversable): Add examples to Bitraversable

* Add examples to Data.Bitraversable
* Fix formatting for (,) in Bitraversable and Bifoldable
* Fix mistake on bimapAccumR documentation

See #17929

- - - - -
9749fe12 by Baldur Blöndal at 2020-05-08T15:29:32-04:00
Specify kind variables for inferred kinds in base.

- - - - -
4e9aef9e by John Ericson at 2020-05-08T15:29:36-04:00
HsSigWcTypeScoping: Pull in documentation from stray location

- - - - -
f4d5c6df by John Ericson at 2020-05-08T15:29:36-04:00
Rename local `real_fvs` to `implicit_vs`

It doesn't make sense to call the "free" variables we are about to
implicitly bind the real ones.

- - - - -
20570b4b by John Ericson at 2020-05-08T15:29:36-04:00
A few tiny style nits with renaming

 - Use case rather than guards that repeatedly scrutenize same thing.

 - No need for view pattern when `L` is fine.

 - Use type synnonym to convey the intent like elsewhere.

- - - - -
09ac8de5 by John Ericson at 2020-05-08T15:29:36-04:00
Add `forAllOrNothing` function with note

- - - - -
bb35c0e5 by Joseph C. Sible at 2020-05-08T15:29:40-04:00
Document lawlessness of Ap's Num instance
- - - - -
cdd229ff by Joseph C. Sible at 2020-05-08T15:29:40-04:00
Apply suggestion to libraries/base/Data/Monoid.hs
- - - - -
926d2aab by Joseph C. Sible at 2020-05-08T15:29:40-04:00
Apply more suggestions from Simon Jakobi
- - - - -
7a763cff by Adam Gundry at 2020-05-08T15:29:41-04:00
Reject all duplicate declarations involving DuplicateRecordFields (fixes #17965)

This fixes a bug that resulted in some programs being accepted that used the same
identifier as a field label and another declaration, depending on the order they
appeared in the source code.

- - - - -
88e3c815 by Simon Peyton Jones at 2020-05-08T15:29:41-04:00
Fix specialisation for DFuns

When specialising a DFun we must take care to saturate the
unfolding.  See Note [Specialising DFuns] in Specialise.

Fixes #18120

- - - - -
86c77b36 by Greg Steuck at 2020-05-08T15:29:45-04:00
Remove unused SEGMENT_PROT_RWX

It's been unused for a year and is problematic on any OS which
requires W^X for security.

- - - - -
9d97f4b5 by nineonine at 2020-05-08T15:30:03-04:00
Add test for #16167

- - - - -
aa318338 by Ryan Scott at 2020-05-08T15:30:04-04:00
Bump exceptions submodule so that dist-boot is .gitignore'd

`exceptions` is a stage-0 boot library as of commit
30272412fa437ab8e7a8035db94a278e10513413, which means that building
`exceptions` in a GHC tree will generate a `dist-boot` directory.
However, this directory was not specified in `exceptions`'
`.gitignore` file, which causes it to dirty up the current `git`
working directory.

Accordingly, this bumps the `exceptions` submodule to commit
ghc/packages/exceptions at 23c0b8a50d7592af37ca09beeec16b93080df98f,
which adds `dist-boot` to the `.gitignore` file.

- - - - -
ea86360f by Ömer Sinan Ağacan at 2020-05-08T15:30:30-04:00
Linker.c: initialize n_symbols of ObjectCode with other fields

- - - - -
951c1fb0 by Sylvain Henry at 2020-05-09T21:46:38-04:00
Fix unboxed-sums GC ptr-slot rubbish value (#17791)

This patch allows boot libraries to use unboxed sums without implicitly
depending on `base` package because of `absentSumFieldError`.

See updated Note [aBSENT_SUM_FIELD_ERROR_ID] in GHC.Core.Make

- - - - -
b352d63c by Ben Gamari at 2020-05-09T21:47:14-04:00
rts: Make non-existent linker search path merely a warning

As noted in #18105, previously this resulted in a rather intrusive error
message. This is in contrast to the general expectation that search
paths are merely places to look, not places that must exist.

Fixes #18105.

- - - - -
cf4f1e2f by Ben Gamari at 2020-05-13T02:02:33-04:00
rts/CNF: Fix fixup comparison function

Previously we would implicitly convert the difference between two words
to an int, resulting in an integer overflow on 64-bit machines.

Fixes #16992

- - - - -
a03da9bf by Ömer Sinan Ağacan at 2020-05-13T02:03:16-04:00
Pack some of IdInfo fields into a bit field

This reduces residency of compiler quite a bit on some programs.
Example stats when building T10370:

Before:

   2,871,242,832 bytes allocated in the heap
   4,693,328,008 bytes copied during GC
      33,941,448 bytes maximum residency (276 sample(s))
         375,976 bytes maximum slop
              83 MiB total memory in use (0 MB lost due to fragmentation)

After:

   2,858,897,344 bytes allocated in the heap
   4,629,255,440 bytes copied during GC
      32,616,624 bytes maximum residency (278 sample(s))
         314,400 bytes maximum slop
              80 MiB total memory in use (0 MB lost due to fragmentation)

So -3.9% residency, -1.3% bytes copied and -0.4% allocations.

Fixes #17497

Metric Decrease:
    T9233
    T9675

- - - - -
670c3e5c by Ben Gamari at 2020-05-13T02:03:54-04:00
get-win32-tarballs: Fix base URL

Revert a change previously made for testing purposes.

- - - - -
8ad8dc41 by Ben Gamari at 2020-05-13T02:03:54-04:00
get-win32-tarballs: Improve diagnostics output

- - - - -
8c0740b7 by Simon Jakobi at 2020-05-13T02:04:33-04:00
docs: Add examples for Data.Semigroup.Arg{Min,Max}

Context: #17153

- - - - -
cb22348f by Ben Gamari at 2020-05-13T02:05:11-04:00
Add few cleanups of the CAF logic

Give the NameSet of non-CAFfy names a proper newtype to distinguish it
from all of the other NameSets floating about.

- - - - -
90e38b81 by Emeka Nkurumeh at 2020-05-13T02:05:51-04:00
fix printf warning when using with ghc with clang on mingw
- - - - -
86d8ac22 by Sebastian Graf at 2020-05-13T02:06:29-04:00
CprAnal: Don't attach CPR sigs to expandable bindings (#18154)

Instead, look through expandable unfoldings in `cprTransform`.
See the new Note [CPR for expandable unfoldings]:

```
Long static data structures (whether top-level or not) like

  xs = x1 : xs1
  xs1 = x2 : xs2
  xs2 = x3 : xs3

should not get CPR signatures, because they

  * Never get WW'd, so their CPR signature should be irrelevant after analysis
    (in fact the signature might even be harmful for that reason)
  * Would need to be inlined/expanded to see their constructed product
  * Recording CPR on them blows up interface file sizes and is redundant with
    their unfolding. In case of Nested CPR, this blow-up can be quadratic!

But we can't just stop giving DataCon application bindings the CPR property,
for example

  fac 0 = 1
  fac n = n * fac (n-1)

fac certainly has the CPR property and should be WW'd! But FloatOut will
transform the first clause to

  lvl = 1
  fac 0 = lvl

If lvl doesn't have the CPR property, fac won't either. But lvl doesn't have a
CPR signature to extrapolate into a CPR transformer ('cprTransform'). So
instead we keep on cprAnal'ing through *expandable* unfoldings for these arity
0 bindings via 'cprExpandUnfolding_maybe'.

In practice, GHC generates a lot of (nested) TyCon and KindRep bindings, one
for each data declaration. It's wasteful to attach CPR signatures to each of
them (and intractable in case of Nested CPR).
```

Fixes #18154.

- - - - -
e34bf656 by Ben Gamari at 2020-05-13T02:07:08-04:00
users-guide: Add discussion of shared object naming

Fixes #18074.

- - - - -
5d0f2445 by Ben Gamari at 2020-05-13T02:07:47-04:00
testsuite: Print sign of performance changes

Executes the minor formatting change in the tabulated performance
changes suggested in #18135.

- - - - -
9e4b981f by Ben Gamari at 2020-05-13T02:08:24-04:00
testsuite: Add testcase for #18129

- - - - -
266310c3 by Ivan-Yudin at 2020-05-13T02:09:03-04:00
doc: Reformulate the opening paragraph of Ch. 4 in User's guide

Removes mentioning of Hugs
(it is not helpful for new users anymore).

Changes the wording for the rest of the paragraph.

Fixes #18132.

- - - - -
55e35c0b by Baldur Blöndal at 2020-05-13T20:02:48-04:00
Predicate, Equivalence derive via `.. -> a -> All'

- - - - -
d7e0b57f by Alp Mestanogullari at 2020-05-13T20:03:30-04:00
hadrian: add a --freeze2 option to freeze stage 1 and 2

- - - - -
d880d6b2 by Artem Pelenitsyn at 2020-05-13T20:04:11-04:00
Don't reload environment files on every setSessionDynFlags

Makes `interpretPackageEnv` (which loads envirinment files) a part of
`parseDynamicFlags` (parsing command-line arguments, which is typically
done once) instead of `setSessionDynFlags` (which is typically called
several times). Making several (transitive) calls to `interpretPackageEnv`,
as before, caused #18125 #16318, which should be fixed now.

- - - - -
102cfd67 by Ryan Scott at 2020-05-13T20:04:46-04:00
Factor out HsPatSigType for pat sigs/RULE term sigs (#16762)

This implements chunks (2) and (3) of
https://gitlab.haskell.org/ghc/ghc/issues/16762#note_270170. Namely,
it introduces a dedicated `HsPatSigType` AST type, which represents
the types that can appear in pattern signatures and term-level `RULE`
binders. Previously, these were represented with `LHsSigWcType`.
Although `LHsSigWcType` is isomorphic to `HsPatSigType`, the intended
semantics of the two types are slightly different, as evidenced by
the fact that they have different code paths in the renamer and
typechecker.

See also the new `Note [Pattern signature binders and scoping]` in
`GHC.Hs.Types`.

- - - - -
b17574f7 by Hécate at 2020-05-13T20:05:28-04:00
fix(documentation): Fix the RST links to GHC.Prim

- - - - -
df021fb1 by Baldur Blöndal at 2020-05-13T20:06:06-04:00
Document (->) using inferred quantification for its runtime representations.

Fixes #18142.

- - - - -
1a93ea57 by Takenobu Tani at 2020-05-13T20:06:54-04:00
Tweak man page for ghc command

This commit updates the ghc command's man page as followings:

* Enable `man_show_urls` to show URL addresses in the `DESCRIPTION`
section of ghc.rst, because sphinx currently removes hyperlinks
for man pages.

* Add a `SEE ALSO` section to point to the GHC homepage

- - - - -
a951e1ba by Takenobu Tani at 2020-05-13T20:07:37-04:00
GHCi: Add link to the user's guide in help message

This commit adds a link to the user's guide in ghci's
`:help` message.

Newcomers could easily reach to details of ghci.

- - - - -
404581ea by Jeff Happily at 2020-05-13T20:08:15-04:00
Handle single unused import

- - - - -
1c999e5d by Ben Gamari at 2020-05-13T20:09:07-04:00
Ensure that printMinimalImports closes handle

Fixes #18166.

- - - - -
c9f5a8f4 by Ben Gamari at 2020-05-13T20:09:51-04:00
hadrian: Tell testsuite driver about LLVM availability

This reflects the logic present in the Make build system into Hadrian.

Fixes #18167.

- - - - -
c05c0659 by Simon Jakobi at 2020-05-14T03:31:21-04:00
Improve some folds over Uniq[D]FM

* Replace some non-deterministic lazy folds with
  strict folds.
* Replace some O(n log n) folds in deterministic order
  with O(n) non-deterministic folds.
* Replace some folds with set-operations on the underlying
  IntMaps.

This reduces max residency when compiling
`nofib/spectral/simple/Main.hs` with -O0 by about 1%.

Maximum residency when compiling Cabal also seems reduced on the
order of 3-9%.

- - - - -
477f13bb by Simon Jakobi at 2020-05-14T03:31:58-04:00
Use Data.IntMap.disjoint

Data.IntMap gained a dedicated `disjoint` function in containers-0.6.2.1.

This patch applies this function where appropriate in hopes of modest
compiler performance improvements.

Closes #16806.

- - - - -
e9c0110c by Ben Gamari at 2020-05-14T12:25:53-04:00
IdInfo: Add reference to bitfield-packing ticket

- - - - -
9bd20e83 by Sebastian Graf at 2020-05-15T10:42:09-04:00
DmdAnal: Improve handling of precise exceptions

This patch does two things: Fix possible unsoundness in what was called
the "IO hack" and implement part 2.1 of the "fixing precise exceptions"
plan in
https://gitlab.haskell.org/ghc/ghc/wikis/fixing-precise-exceptions,
which, in combination with !2956, supersedes !3014 and !2525.

**IO hack**

The "IO hack" (which is a fallback to preserve precise exceptions
semantics and thus soundness, rather than some smart thing that
increases precision) is called `exprMayThrowPreciseException` now.
I came up with two testcases exemplifying possible unsoundness (if
twisted enough) in the old approach:

- `T13380d`: Demonstrating unsoundness of the "IO hack" when resorting
             to manual state token threading and direct use of primops.
             More details below.
- `T13380e`: Demonstrating unsoundness of the "IO hack" when we have
             Nested CPR. Not currently relevant, as we don't have Nested
             CPR yet.
- `T13380f`: Demonstrating unsoundness of the "IO hack" for safe FFI
             calls.

Basically, the IO hack assumed that precise exceptions can only be
thrown from a case scrutinee of type `(# State# RealWorld, _ #)`. I
couldn't come up with a program using the `IO` abstraction that violates
this assumption. But it's easy to do so via manual state token threading
and direct use of primops, see `T13380d`. Also similar code might be
generated by Nested CPR in the (hopefully not too) distant future, see
`T13380e`. Hence, we now have a more careful test in `forcesRealWorld`
that passes `T13380{d,e}` (and will hopefully be robust to Nested CPR).

**Precise exceptions**

In #13380 and #17676 we saw that we didn't preserve precise exception
semantics in demand analysis. We fixed that with minimal changes in
!2956, but that was terribly unprincipled.

That unprincipledness resulted in a loss of precision, which is tracked
by these new test cases:

- `T13380b`: Regression in dead code elimination, because !2956 was too
             syntactic about `raiseIO#`
- `T13380c`: No need to apply the "IO hack" when the IO action may not
             throw a precise exception (and the existing IO hack doesn't
             detect that)

Fixing both issues in !3014 turned out to be too complicated and had
the potential to regress in the future. Hence we decided to only fix
`T13380b` and augment the `Divergence` lattice with a new middle-layer
element, `ExnOrDiv`, which means either `Diverges` (, throws an
imprecise exception) or throws a *precise* exception.

See the wiki page on Step 2.1 for more implementational details:
https://gitlab.haskell.org/ghc/ghc/wikis/fixing-precise-exceptions#dead-code-elimination-for-raiseio-with-isdeadenddiv-introducing-exnordiv-step-21

- - - - -
568d7279 by Ben Gamari at 2020-05-15T10:42:46-04:00
GHC.Cmm.Opt: Handle MO_XX_Conv

This MachOp was introduced by 2c959a1894311e59cd2fd469c1967491c1e488f3
but a wildcard match in cmmMachOpFoldM hid the fact that it wasn't
handled. Ideally we would eliminate the match but this appears to be a
larger task.

Fixes #18141.

- - - - -
5bcf8606 by Ryan Scott at 2020-05-17T08:46:38-04:00
Remove duplicate Note [When to print foralls] in GHC.Core.TyCo.Ppr

There are two different Notes named `[When to print foralls]`. The
most up-to-date one is in `GHC.Iface.Type`, but there is a second
one in `GHC.Core.TyCo.Ppr`. The latter is less up-to-date, as it was
written before GHC switched over to using ifaces to pretty-print
types. I decided to just remove the latter and replace it with a
reference to the former.

[ci skip]

- - - - -
55f0e783 by Fumiaki Kinoshita at 2020-05-21T12:10:44-04:00
base: Add Generic instances to various datatypes under GHC.*

* GHC.Fingerprint.Types: Fingerprint
* GHC.RTS.Flags: GiveGCStats, GCFlags, ConcFlags, DebugFlags, CCFlags, DoHeapProfile, ProfFlags, DoTrace, TraceFlags, TickyFlags, ParFlags and RTSFlags
* GHC.Stats: RTSStats and GCStats
* GHC.ByteOrder: ByteOrder
* GHC.Unicode: GeneralCategory
* GHC.Stack.Types: SrcLoc

Metric Increase:
    haddock.base

- - - - -
a9311cd5 by Gert-Jan Bottu at 2020-05-21T12:11:31-04:00
Explicit Specificity

Implementation for Ticket #16393.
Explicit specificity allows users to manually create inferred type variables,
by marking them with braces.
This way, the user determines which variables can be instantiated through
visible type application.

The additional syntax is included in the parser, allowing users to write
braces in type variable binders (type signatures, data constructors etc).
This information is passed along through the renamer and verified in the
type checker.
The AST for type variable binders, data constructors, pattern synonyms,
partial signatures and Template Haskell has been updated to include the
specificity of type variables.

Minor notes:
- Bumps haddock submodule
- Disables pattern match checking in GHC.Iface.Type with GHC 8.8

- - - - -
24e61aad by Ben Price at 2020-05-21T12:12:17-04:00
Lint should say when it is checking a rule

It is rather confusing that when lint finds an error in a rule attached
to a binder, it reports the error as in the RHS, not the rule:
  ...
  In the RHS of foo

We add a clarifying line:
  ...
  In the RHS of foo
  In a rule attached to foo

The implication that the rule lives inside the RHS is a bit odd, but
this niggle is already present for unfoldings, whose pattern we are
following.

- - - - -
78c6523c by Ben Gamari at 2020-05-21T12:13:01-04:00
nonmoving: Optimise the write barrier

- - - - -
13f6c9d0 by Andreas Klebinger at 2020-05-21T12:13:45-04:00
Refactor linear reg alloc to remember past assignments.

When assigning registers we now first try registers we
assigned to in the past, instead of picking the "first"
one.

This is in extremely helpful when dealing with loops for
which variables are dead for part of the loop.

This is important for patterns like this:

        foo = arg1
    loop:
        use(foo)
        ...
        foo = getVal()
        goto loop;

There we:
* assign foo to the register of arg1.
* use foo, it's dead after this use as it's overwritten after.
* do other things.
* look for a register to put foo in.

If we pick an arbitrary one it might differ from the register the
start of the loop expect's foo to be in.
To fix this we simply look for past register assignments for
the given variable. If we find one and the register is free we
use that register.

This reduces the need for fixup blocks which match the register
assignment between blocks. In the example above between the end
and the head of the loop.

This patch also moves branch weight estimation ahead of register
allocation and adds a flag to control it (cmm-static-pred).
* It means the linear allocator is more likely to assign the hotter
  code paths first.
* If it assign these first we are:
  + Less likely to spill on the hot path.
  + Less likely to introduce fixup blocks on the hot path.

These two measure combined are surprisingly effective. Based on nofib
we get in the mean:

* -0.9% instructions executed
* -0.1% reads/writes
* -0.2% code size.
* -0.1% compiler allocations.
* -0.9% compile time.
* -0.8% runtime.

Most of the benefits are simply a result of removing redundant moves
and spills.

Reduced compiler allocations likely are the result of less code being
generated. (The added lookup is mostly non-allocating).

- - - - -
edc2cc58 by Andreas Klebinger at 2020-05-21T12:14:25-04:00
NCG: Codelayout: Distinguish conditional and other branches.

In #18053 we ended up with a suboptimal code layout because
the code layout algorithm didn't distinguish between conditional
and unconditional control flow.

We can completely eliminate unconditional control flow instructions
by placing blocks next to each other, not so much for conditionals.

In terms of implementation we simply give conditional branches less
weight before computing the layout.

Fixes #18053

- - - - -
b7a6b2f4 by Gleb Popov at 2020-05-21T12:15:26-04:00
gitlab-ci: Set locale to C.UTF-8.

- - - - -
a8c27cf6 by Stefan Holdermans at 2020-05-21T12:16:08-04:00
Allow spaces in GHCi :script file names

This patch updates the user interface of GHCi so that file names passed
to the ':script' command may contain spaces escaped with a backslash.

For example:

  :script foo\ bar.script

The implementation uses a modified version of 'words' that does not
break on escaped spaces.

Fixes #18027.

- - - - -
82663959 by Stefan Holdermans at 2020-05-21T12:16:08-04:00
Add extra tests for GHCi :script syntax checks

The syntax for GHCi's ":script" command allows for only a single file
name to be passed as an argument. This patch adds a test for the cases
in which a file name is missing or multiple file names are passed.

Related to #T18027.

- - - - -
a0b79e1b by Stefan Holdermans at 2020-05-21T12:16:08-04:00
Allow GHCi :script file names in double quotes

This patch updates the user interface of GHCi so that file names passed
to the ':script' command can be wrapped in double quotes.

For example:

  :script "foo bar.script"

The implementation uses a modified version of 'words' that treats
character sequences enclosed in double quotes as single words.

Fixes #18027.

- - - - -
cf566330 by Stefan Holdermans at 2020-05-21T12:16:08-04:00
Update documentation for GHCi :script

This patch adds the fixes that allow for file names containing spaces to
be passed to GHCi's ':script' command to the release notes for 8.12 and
expands the user-guide documentation for ':script' by mentioning how
such file names can be passed.

Related to #18027.

- - - - -
0004ccb8 by Tuan Le at 2020-05-21T12:16:46-04:00
llvmGen: Consider Relocatable read-only data as not constantReferences: #18137

- - - - -
964d3ea2 by John Ericson at 2020-05-21T12:17:30-04:00
Use `Checker` for `tc_pat`

- - - - -
b797aa42 by John Ericson at 2020-05-21T12:17:30-04:00
Use `Checker` for `tc_lpat` and `tc_lpats`

- - - - -
5108e84a by John Ericson at 2020-05-21T12:17:30-04:00
More judiciously panic in `ts_pat`

- - - - -
510e0451 by John Ericson at 2020-05-21T12:17:30-04:00
Put `PatEnv` first in `GHC.Tc.Gen.Pat.Checker`

- - - - -
cb4231db by John Ericson at 2020-05-21T12:17:30-04:00
Tiny cleaup eta-reduce away a function argument

In GHC, not in the code being compiled!

- - - - -
6890c38d by John Ericson at 2020-05-21T12:17:30-04:00
Use braces with do in `SplicePat` case for consistency

- - - - -
3451584f by buggymcbugfix at 2020-05-21T12:18:06-04:00
Fix spelling mistakes and typos

- - - - -
b552e531 by buggymcbugfix at 2020-05-21T12:18:06-04:00
Add INLINABLE pragmas to Enum list producers

The INLINABLE pragmas ensure that we export stable (unoptimised) unfoldings in
the interface file so we can do list fusion at usage sites.

Related tickets: #15185, #8763, #18178.

- - - - -
e7480063 by buggymcbugfix at 2020-05-21T12:18:06-04:00
Piggyback on Enum Word methods for Word64

If we are on a 64 bit platform, we can use the efficient Enum Word
methods for the Enum Word64 instance.

- - - - -
892b0c41 by buggymcbugfix at 2020-05-21T12:18:06-04:00
Document INLINE(ABLE) pragmas that enable fusion

- - - - -
2b363ebb by Richard Eisenberg at 2020-05-21T12:18:45-04:00
MR template should ask for key part
- - - - -
a95bbd0b by Sebastian Graf at 2020-05-21T12:19:37-04:00
Make `Int`'s `mod` and `rem` strict in their first arguments

They used to be strict until 4d2ac2d (9 years ago).

It's obviously better to be strict for performance reasons.
It also blocks #18067.

NoFib results:

```
--------------------------------------------------------------------------------
        Program         Allocs    Instrs
--------------------------------------------------------------------------------
        integer          -1.1%     +0.4%
   wheel-sieve2         +21.2%    +20.7%
--------------------------------------------------------------------------------
            Min          -1.1%     -0.0%
            Max         +21.2%    +20.7%
 Geometric Mean          +0.2%     +0.2%
```

The regression in `wheel-sieve2` is due to reboxing that likely will go
away with the resolution of #18067. See !3282 for details.

Fixes #18187.

- - - - -
d3d055b8 by Galen Huntington at 2020-05-21T12:20:18-04:00
Clarify pitfalls of NegativeLiterals; see #18022.
- - - - -
1b508a9e by Alexey Kuleshevich at 2020-05-21T12:21:02-04:00
Fix wording in primops documentation to reflect the correct reasoning:

* Besides resizing functions, shrinking ones also mutate the
  size of a mutable array and because of those two `sizeofMutabeByteArray`
  and `sizeofSmallMutableArray` are now deprecated
* Change reference in documentation to the newer functions `getSizeof*`
  instead of `sizeof*` for shrinking functions
* Fix incorrect mention of "byte" instead of "small"

- - - - -
4ca0c8a1 by Andreas Klebinger at 2020-05-21T12:21:53-04:00
Don't variable-length encode magic iface constant.

We changed to use variable length encodings for many types by default,
including Word32. This makes sense for numbers but not when Word32 is
meant to represent four bytes.

I added a FixedLengthEncoding newtype to Binary who's instances
interpret their argument as a collection of bytes instead of a number.

We then use this when writing/reading magic numbers to the iface file.

I also took the libery to remove the dummy iface field.

This fixes #18180.

- - - - -
a1275081 by Krzysztof Gogolewski at 2020-05-21T12:22:35-04:00
Add a regression test for #11506

The testcase works now.
See explanation in https://gitlab.haskell.org/ghc/ghc/issues/11506#note_273202

- - - - -
8a816e5f by Krzysztof Gogolewski at 2020-05-21T12:23:55-04:00
Sort deterministically metric output

Previously, we sorted according to the test name and way,
but the metrics (max_bytes_used/peak_megabytes_allocated etc.)
were appearing in nondeterministic order.

- - - - -
566cc73f by Sylvain Henry at 2020-05-21T12:24:45-04:00
Move isDynLinkName into GHC.Types.Name

It doesn't belong into GHC.Unit.State

- - - - -
d830bbc9 by Adam Sandberg Ericsson at 2020-05-23T13:36:20-04:00
docs: fix formatting and add some links

[skip ci]

- - - - -
49301ad6 by Andrew Martin at 2020-05-23T13:37:01-04:00
Implement cstringLength# and FinalPtr

This function and its accompanying rule resolve issue #5218.
A future PR to the bytestring library will make the internal
Data.ByteString.Internal.unsafePackAddress compute string length
with cstringLength#. This will improve the status quo because it is
eligible for constant folding.

Additionally, introduce a new data constructor to ForeignPtrContents
named FinalPtr. This additional data constructor, when used in the
IsString instance for ByteString, leads to more Core-to-Core
optimization opportunities, fewer runtime allocations, and smaller
binaries.

Also, this commit re-exports all the functions from GHC.CString
(including cstringLength#) in GHC.Exts. It also adds a new test
driver. This test driver is used to perform substring matches on Core
that is dumped after all the simplifier passes. In this commit, it is
used to check that constant folding of cstringLength# works.

- - - - -
dcd6bdcc by Ben Gamari at 2020-05-23T13:37:48-04:00
simplCore: Ignore ticks in rule templates

This fixes #17619, where a tick snuck in to the template of a rule,
resulting in a panic during rule matching. The tick in question was
introduced via post-inlining, as discussed in `Note [Simplifying
rules]`. The solution we decided upon was to simply ignore ticks in the
rule template, as discussed in `Note [Tick annotations in RULE
matching]`.

Fixes #18162.
Fixes #17619.

- - - - -
82cb8913 by John Ericson at 2020-05-23T13:38:32-04:00
Fix #18145 and also avoid needless work with implicit vars

 - `forAllOrNothing` now is monadic, so we can trace whether we bind
   an explicit `forall` or not.

 - #18145 arose because the free vars calculation was needlessly
   complex. It is now greatly simplified.

 - Replaced some other implicit var code with `filterFreeVarsToBind`.

Co-authored-by: Ryan Scott <ryan.gl.scott at gmail.com>

- - - - -
a60dc835 by Ben Gamari at 2020-05-23T13:39:12-04:00
Bump process submodule

Fixes #17926.

- - - - -
856adf54 by Ben Gamari at 2020-05-23T13:40:21-04:00
users-guide: Clarify meaning of -haddock flag

Fixes #18206.

- - - - -
7ae57afd by Ben Gamari at 2020-05-23T13:41:03-04:00
git: Add ignored commits file

This can be used to tell git to ignore bulk renaming commits like the
recently-finished module hierarchy refactoring. Configured with,

    git config blame.ignoreRevsFile .git-ignore-revs

- - - - -
63d30e60 by jneira at 2020-05-24T01:54:42-04:00
Add hie-bios script for windows systems
It is a direct translation of the sh script

- - - - -
59182b88 by jneira at 2020-05-24T01:54:42-04:00
Honour previous values for CABAL and CABFLAGS
The immediate goal is let the hie-bios.bat script
set CABFLAGS with `-v0` and remove all cabal output
except the compiler arguments

- - - - -
932dc54e by jneira at 2020-05-24T01:54:42-04:00
Add specific configuration for windows in hie.yaml

- - - - -
e0eda070 by jneira at 2020-05-24T01:54:42-04:00
Remove not needed hie-bios output

- - - - -
a0ea59d6 by Sylvain Henry at 2020-05-24T01:55:24-04:00
Move Config module into GHC.Settings

- - - - -
37430251 by Sylvain Henry at 2020-05-24T01:55:24-04:00
Rename GHC.Core.Arity into GHC.Core.Opt.Arity

- - - - -
a426abb9 by Sylvain Henry at 2020-05-24T01:55:24-04:00
Rename GHC.Hs.Types into GHC.Hs.Type

See discussion in https://gitlab.haskell.org/ghc/ghc/issues/13009#note_268610

- - - - -
1c91a7a0 by Sylvain Henry at 2020-05-24T01:55:24-04:00
Bump haddock submodule

- - - - -
66bd24d1 by Ryan Scott at 2020-05-24T01:56:03-04:00
Add orderingTyCon to wiredInTyCons (#18185)

`Ordering` needs to be wired in for use in the built-in `CmpNat` and
`CmpSymbol` type families, but somehow it was never added to the list
of `wiredInTyCons`, leading to the various oddities observed
in #18185. Easily fixed by moving `orderingTyCon` from
`basicKnownKeyNames` to `wiredInTyCons`.

Fixes #18185.

- - - - -
01c43634 by Matthew Pickering at 2020-05-24T01:56:42-04:00
Remove unused hs-boot file

- - - - -
7a07aa71 by Sylvain Henry at 2020-05-24T15:22:17-04:00
Hadrian: fix cross-compiler build (#16051)

- - - - -
15ccca16 by Sylvain Henry at 2020-05-24T15:22:17-04:00
Hadrian: fix distDir per stage

- - - - -
b420fb24 by Sylvain Henry at 2020-05-24T15:22:17-04:00
Hadrian: fix hp2ps error during cross-compilation

Fixed by @alp (see https://gitlab.haskell.org/ghc/ghc/issues/16051#note_274265)

- - - - -
cd339ef0 by Joshua Price at 2020-05-24T15:22:56-04:00
Make Unicode brackets opening/closing tokens (#18225)

The tokens `[|`, `|]`, `(|`, and `|)` are opening/closing tokens as
described in GHC Proposal #229. This commit makes the unicode
variants (`⟦`, `⟧`, `⦇`, and `⦈`) act the same as their ASCII
counterparts.

- - - - -
013d7120 by Ben Gamari at 2020-05-25T09:48:17-04:00
Revert "Specify kind variables for inferred kinds in base."

As noted in !3132, this has rather severe knock-on consequences in
user-code. We'll need to revisit this before merging something along
these lines.

This reverts commit 9749fe1223d182b1f8e7e4f7378df661c509f396.

- - - - -
4c4312ed by Ben Gamari at 2020-05-25T09:48:53-04:00
Coverage: Drop redundant ad-hoc boot module check

To determine whether the module is a boot module
Coverage.addTicksToBinds was checking for a `boot` suffix in the module
source filename. This is quite ad-hoc and shouldn't be necessary; the
callsite in `deSugar` already checks that the module isn't a boot
module.

- - - - -
1abf3c84 by Ben Gamari at 2020-05-25T09:48:53-04:00
Coverage: Make tickBoxCount strict

This could otherwise easily cause a leak of (+) thunks.

- - - - -
b2813750 by Ben Gamari at 2020-05-25T09:48:53-04:00
Coverage: Make ccIndices strict

This just seems like a good idea.

- - - - -
02e278eb by Ben Gamari at 2020-05-25T09:48:53-04:00
Coverage: Don't produce ModBreaks if not HscInterpreted

emptyModBreaks contains a bottom and consequently it's important that we
don't use it unless necessary.

- - - - -
b8c014ce by Ben Gamari at 2020-05-25T09:48:53-04:00
Coverage: Factor out addMixEntry

- - - - -
53814a64 by Zubin Duggal at 2020-05-26T03:03:24-04:00
Add info about typeclass evidence to .hie files

See `testsuite/tests/hiefile/should_run/HieQueries.hs` and
`testsuite/tests/hiefile/should_run/HieQueries.stdout` for an example of this

We add two new fields, `EvidenceVarBind` and `EvidenceVarUse` to the
`ContextInfo` associated with an Identifier. These are associated with the
appropriate identifiers for the evidence variables collected when we come across
`HsWrappers`, `TcEvBinds` and `IPBinds` while traversing the AST.

Instance dictionary and superclass selector dictionaries from `tcg_insts` and
classes defined in `tcg_tcs` are also recorded in the AST as originating from
their definition span

This allows us to save a complete picture of the evidence constructed by the
constraint solver, and will let us report this to the user, enabling features
like going to the instance definition from the invocation of a class method(or
any other method taking a constraint) and finding all usages of a particular
instance.

Additionally,

- Mark NodeInfo with an origin so we can differentiate between bindings
  origininating in the source vs those in ghc
- Along with typeclass evidence info, also include information on Implicit
  Parameters
- Add a few utility functions to HieUtils in order to query the new info

Updates haddock submodule

- - - - -
6604906c by Sebastian Graf at 2020-05-26T03:04:04-04:00
Make WorkWrap.Lib.isWorkerSmallEnough aware of the old arity

We should allow a wrapper with up to 82 parameters when the original
function had 82 parameters to begin with.

I verified that this made no difference on NoFib, but then again
it doesn't use huge records...

Fixes #18122.

- - - - -
cf772f19 by Sylvain Henry at 2020-05-26T03:04:45-04:00
Enhance Note [About units] for Backpack

- - - - -
ede24126 by Takenobu Tani at 2020-05-27T00:13:55-04:00
core-spec: Modify file paths according to new module hierarchy

This patch updates file paths according to new module hierarchy [1]:

  * GHC/Core.hs                <= coreSyn/CoreSyn.hs
  * GHC/Core/Coercion.hs       <= types/Coercion.hs
  * GHC/Core/Coercion/Axiom.hs <= types/CoAxiom.hs
  * GHC/Core/Coercion/Opt.hs   <= types/OptCoercion.hs
  * GHC/Core/DataCon.hs        <= basicTypes/DataCon.hs
  * GHC/Core/FamInstEnv.hs     <= types/FamInstEnv.hs
  * GHC/Core/Lint.hs           <= coreSyn/CoreLint.hs
  * GHC/Core/Subst.hs          <= coreSyn/CoreSubst.hs
  * GHC/Core/TyCo/Rep.hs       <= types/TyCoRep.hs
  * GHC/Core/TyCon.hs          <= types/TyCon.hs
  * GHC/Core/Type.hs           <= types/Type.hs
  * GHC/Core/Unify.hs          <= types/Unify.hs
  * GHC/Types/Literal.hs       <= basicTypes/Literal.hs
  * GHC/Types/Var.hs           <= basicTypes/Var.hs

[1]: https://gitlab.haskell.org/ghc/ghc/-/wikis/Make-GHC-codebase-more-modular

[skip ci]

- - - - -
04750304 by Ben Gamari at 2020-05-27T00:14:33-04:00
eventlog: Fix racy flushing

Previously no attempt was made to avoid multiple threads writing their
capability-local eventlog buffers to the eventlog writer simultaneously.
This could result in multiple eventlog streams being interleaved. Fix
this by documenting that the EventLogWriter's write() and flush()
functions may be called reentrantly and fix the default writer to
protect its FILE* by a mutex.

Fixes #18210.

- - - - -
d6203f24 by Joshua Price at 2020-05-27T00:15:17-04:00
Make `identifier` parse unparenthesized `->` (#18060)

- - - - -
28deee28 by Ben Gamari at 2020-05-28T16:23:21-04:00
GHC.Core.Unfold: Refactor traceInline

This reduces duplication as well as fixes a bug wherein -dinlining-check
would override -ddump-inlinings. Moreover, the new variant

- - - - -
1f393e1e by Ben Gamari at 2020-05-28T16:23:21-04:00
Avoid unnecessary allocations due to tracing utilities

While ticky-profiling the typechecker I noticed that hundreds of
millions of SDocs are being allocated just in case -ddump-*-trace is
enabled. This is awful.

We avoid this by ensuring that the dump flag check is inlined into the
call site, ensuring that the tracing document needn't be allocated
unless it's actually needed.

See Note [INLINE conditional tracing utilities] for details.

Fixes #18168.

Metric Decrease:
  T9961
  haddock.Cabal
  haddock.base
  haddock.compiler

- - - - -
5f621a78 by Vladislav Zavialov at 2020-05-28T16:23:58-04:00
Add Semigroup/Monoid for Q (#18123)

- - - - -
dc5f004c by Xavier Denis at 2020-05-28T16:24:37-04:00
Fix #18071

Run the core linter on candidate instances to ensure they are
well-kinded.

Better handle quantified constraints by using a CtWanted to avoid
having unsolved constraints thrown away at the end by the solver.

- - - - -
10e6982c by Sebastian Graf at 2020-05-28T16:25:14-04:00
FloatOut: Only eta-expand dead-end RHS if arity will increase (#18231)

Otherwise we risk turning trivial RHS into non-trivial RHS, introducing
unnecessary bindings in the next Simplifier run, resulting in more
churn.

Fixes #18231.

- - - - -
08dab5f7 by Sebastian Graf at 2020-05-28T16:25:14-04:00
DmdAnal: Recognise precise exceptions from case alternatives (#18086)

Consider

```hs
m :: IO ()
m = do
  putStrLn "foo"
  error "bar"
```

`m` (from #18086) always throws a (precise or imprecise) exception or
diverges. Yet demand analysis infers `<L,A>` as demand signature instead
of `<L,A>x` for it.

That's because the demand analyser sees `putStrLn` occuring in a case
scrutinee and decides that it has to `deferAfterPreciseException`,
because `putStrLn` throws a precise exception on some control flow
paths. This will mask the `botDiv` `Divergence`of the single case alt
containing `error` to `topDiv`. Since `putStrLn` has `topDiv` itself,
the final `Divergence` is `topDiv`.

This is easily fixed: `deferAfterPreciseException` works by `lub`ing
with the demand type of a virtual case branch denoting the precise
exceptional control flow. We used `nopDmdType` before, but we can be
more precise and use `exnDmdType`, which is `nopDmdType` with `exnDiv`.

Now the `Divergence` from the case alt will degrade `botDiv` to `exnDiv`
instead of `topDiv`, which combines with the result from the scrutinee
to `exnDiv`, and all is well.

Fixes #18086.

- - - - -
aef95f11 by Ben Gamari at 2020-05-28T16:25:53-04:00
Ticky-ticky: Record DataCon name in ticker name

This makes it significantly easier to spot the nature of
allocations regressions and comes at a reasonably low cost.

- - - - -
8f021b8c by Ben Gamari at 2020-05-28T16:26:34-04:00
hadrian: Don't track GHC's verbosity argument

Teach hadrian to ignore GHC's -v argument in its recompilation check,
thus fixing #18131.

- - - - -
13d9380b by Ben Gamari at 2020-05-28T16:27:20-04:00
Rip out CmmStackInfo(updfr_space)

As noted in #18232, this field is currently completely unused and
moreover doesn't have a clear meaning.

- - - - -
f10d11fa by Andreas Klebinger at 2020-05-29T01:38:42-04:00
Fix "build/elem" RULE.

An redundant constraint prevented the rule from matching.

Fixing this allows a call to elem on a known list to be translated
into a series of equality checks, and eventually a simple case
expression.

Surprisingly this seems to regress elem for strings. To avoid
this we now also allow foldrCString to inline and add an UTF8
variant. This results in elem being compiled to a tight
non-allocating loop over the primitive string literal which
performs a linear search.

In the process this commit adds UTF8 variants for some of the
functions in GHC.CString. This is required to make this work for
both ASCII and UTF8 strings.

There are also small tweaks to the CString related rules.
We now allow ourselfes the luxury to compare the folding function
via eqExpr, which helps to ensure the rule fires before we inline
foldrCString*. Together with a few changes to allow matching on both
the UTF8 and ASCII variants of the CString functions.

- - - - -
bbeb2389 by Ben Gamari at 2020-05-29T01:39:19-04:00
CoreToStg: Add Outputable ArgInfo instance

- - - - -
0e3361ca by Simon Peyton Jones at 2020-05-29T01:39:19-04:00
Make Lint check return type of a join point

Consider
   join x = rhs in body
It's important that the type of 'rhs' is the same as the type of
'body', but Lint wasn't checking that invariant.

Now it does!  This was exposed by investigation into !3113.

- - - - -
c49f7df0 by Simon Peyton Jones at 2020-05-29T01:39:19-04:00
Do not float join points in exprIsConApp_maybe

We hvae been making exprIsConApp_maybe cleverer in recent times:

    commit b78cc64e923716ac0512c299f42d4d0012306c05
    Date:   Thu Nov 15 17:14:31 2018 +0100
    Make constructor wrappers inline only during the final phase

    commit 7833cf407d1f608bebb1d38bb99d3035d8d735e6
    Date:   Thu Jan 24 17:58:50 2019 +0100
    Look through newtype wrappers (Trac #16254)

    commit c25b135ff5b9c69a90df0ccf51b04952c2dc6ee1
    Date:   Thu Feb 21 12:03:22 2019 +0000
    Fix exprIsConApp_maybe

But alas there was still a bug, now immortalised in
  Note [Don't float join points]
in SimpleOpt.

It's quite hard to trigger because it requires a dead
join point, but it came up when compiling Cabal
Cabal.Distribution.Fields.Lexer.hs, when working on
!3113.

Happily, the fix is extremly easy.  Finding the
bug was not so easy.

- - - - -
46720997 by Ben Gamari at 2020-05-29T01:39:19-04:00
Allow simplification through runRW#

Because runRW# inlines so late, we were previously able to do very
little simplification across it. For instance, given even a simple
program like

    case runRW# (\s -> let n = I# 42# in n) of
      I# n# -> f n#

we previously had no way to avoid the allocation of the I#.

This patch allows the simplifier to push strict contexts into the
continuation of a runRW# application, as explained in
in Note [Simplification of runRW#] in GHC.CoreToStg.Prep.

Fixes #15127.

Metric Increase:
    T9961
Metric Decrease:
    ManyConstructors

Co-Authored-By: Simon Peyton-Jone <simonpj at microsoft.com>

- - - - -
277c2f26 by Ben Gamari at 2020-05-29T01:39:55-04:00
Eta expand un-saturated primops

Now since we no longer try to predict CAFfyness we have no need for the
solution to #16846. Eta expanding unsaturated primop applications is
conceptually simpler, especially in the presence of levity polymorphism.

This essentially reverts cac8dc9f51e31e4c0a6cd9bc302f7e1bc7c03beb,
as suggested in #18079.

Closes #18079.

- - - - -
f44d7ae0 by Simon Jakobi at 2020-05-29T01:40:34-04:00
base: Scrap deprecation plan for Data.Monoid.{First,Last}

See the discussion on the libraries mailing list for context:

https://mail.haskell.org/pipermail/libraries/2020-April/030357.html

- - - - -
8b494895 by Jeremy Schlatter at 2020-05-29T01:41:12-04:00
Fix typo in documentation

- - - - -
998450f4 by Gleb Popov at 2020-05-29T01:41:53-04:00
Always define USE_PTHREAD_FOR_ITIMER for FreeBSD.

- - - - -
f9a513e0 by Alp Mestanogullari at 2020-05-29T01:42:36-04:00
hadrian: introduce 'install' target

Its logic is very simple. It `need`s the `binary-dist-dir` target
and runs suitable `configure` and `make install` commands for the
user. A new `--prefix` command line argument is introduced to
specify where GHC should be installed.

- - - - -
67738db1 by Travis Whitaker at 2020-05-29T13:34:48-04:00
Build a threaded stage 1 if the bootstrapping GHC supports it.

- - - - -
aac19e6c by Peter Trommler at 2020-05-29T13:35:24-04:00
PPC NCG: No per-symbol .section ".toc" directives

All position independent symbols are collected during code generation
and emitted in one go. Prepending each symbol with a .section ".toc"
directive is redundant. This patch drops the per-symbol directives
leading to smaller assembler files.

Fixes #18250

- - - - -
4413828b by Ben Gamari at 2020-05-30T06:07:31-04:00
rts: Teach getNumProcessors to return available processors

Previously we would report the number of physical processors, which
can be quite wrong in a containerized setting. Now we rather return how
many processors are in our affinity mask when possible.

I also refactored the code to prefer platform-specific since this will
report logical CPUs instead of physical (using
`machdep.cpu.thread_count` on Darwin and `cpuset_getaffinity` on FreeBSD).

Fixes #14781.

- - - - -
1449435c by Ben Gamari at 2020-05-30T06:07:31-04:00
users-guide: Note change in getNumProcessors in users guide

- - - - -
3d960169 by Ben Gamari at 2020-05-30T06:07:31-04:00
rts: Drop compatibility shims for Windows Vista

We can now assume that the thread and processor group interfaces are
available.

- - - - -
7f8f948c by Peter Trommler at 2020-05-30T06:08:07-04:00
PPC NCG: Fix .size directive on powerpc64 ELF v1

Thanks to Sergei Trofimovich for pointing out the issue.

Fixes #18237

- - - - -
7c555b05 by Andreas Klebinger at 2020-05-30T06:08:43-04:00
Optimize GHC.Utils.Monad.

Many functions in this module are recursive and as such are marked
loop breakers. Which means they are unlikely to get an unfolding.

This is *bad*. We always want to specialize them to specific Monads.
Which requires a visible unfolding at the use site.

I rewrote the recursive ones from:

    foo f x = ... foo x' ...

to

    foo f x = go x
      where
        go x = ...

As well as giving some pragmas to make all of them available
for specialization.

The end result is a reduction of allocations of about -1.4% for
nofib/spectral/simple/Main.hs when compiled with `-O`.

-------------------------
Metric Decrease:
    T12425
    T14683
    T5631
    T9233
    T9675
    T9961
    WWRec
-------------------------

- - - - -
8b1cb5df by Ben Gamari at 2020-05-30T06:09:20-04:00
Windows: Bump Windows toolchain to 0.2

- - - - -
6947231a by Zubin Duggal at 2020-05-30T06:10:02-04:00
Simplify contexts in GHC.Iface.Ext.Ast

- - - - -
2ee4f36c by Daniel Gröber at 2020-06-01T06:32:56-04:00
Cleanup OVERWRITING_CLOSURE logic

The code is just more confusing than it needs to be. We don't need to mix
the threaded check with the ldv profiling check since ldv's init already
checks for this. Hence they can be two separate checks. Taking the sanity
checking into account is also cleaner via DebugFlags.sanity. No need for
checking the DEBUG define.

The ZERO_SLOP_FOR_LDV_PROF and ZERO_SLOP_FOR_SANITY_CHECK definitions the
old code had also make things a lot more opaque IMO so I removed those.

- - - - -
6159559b by Daniel Gröber at 2020-06-01T06:32:56-04:00
Fix OVERWRITING_CLOSURE assuming closures are not inherently used

The new ASSERT in LDV_recordDead() was being tripped up by MVars when
removeFromMVarBlockedQueue() calls OVERWRITING_CLOSURE() via
OVERWRITE_INFO().

- - - - -
38992085 by Daniel Gröber at 2020-06-01T06:32:56-04:00
Always zero shrunk mutable array slop when profiling

When shrinking arrays in the profiling way we currently don't always zero
the leftover slop. This means we can't traverse such closures in the heap
profiler. The old Note [zeroing slop] and #8402 have some rationale for why
this is so but I belive the reasoning doesn't apply to mutable
closures. There users already have to ensure multiple threads don't step on
each other's toes so zeroing should be safe.

- - - - -
b0c1f2a6 by Ben Gamari at 2020-06-01T06:33:37-04:00
testsuite: Add test for #18151

- - - - -
9a99a178 by Ben Gamari at 2020-06-01T06:33:37-04:00
testsuite: Add test for desugaring of PostfixOperators

- - - - -
2b89ca5b by Ben Gamari at 2020-06-01T06:33:37-04:00
HsToCore: Eta expand left sections

Strangely, the comment next to this code already alluded to the fact
that even simply eta-expanding will sacrifice laziness. It's quite
unclear how we regressed so far.

See #18151.

- - - - -
d412d7a3 by Kirill Elagin at 2020-06-01T06:34:21-04:00
Winferred-safe-imports: Do not exit with error

Currently, when -Winferred-safe-imports is enabled, even when it is not
turned into an error, the compiler will still exit with exit code 1 if
this warning was emitted.

Make sure it is really treated as a warning.

- - - - -
f945eea5 by Ben Gamari at 2020-06-01T06:34:58-04:00
nonmoving: Optimise log2_ceil

- - - - -
aab606e4 by Bodigrim at 2020-06-01T06:35:36-04:00
Clarify description of fromListN
- - - - -
7e5220e2 by Bodigrim at 2020-06-01T06:35:36-04:00
Apply suggestion to libraries/base/GHC/Exts.hs
- - - - -
f3fb1ce9 by fendor at 2020-06-01T06:36:18-04:00
Add `isInScope` check to `lintCoercion`

Mirrors the behaviour of `lintType`.

- - - - -
5ac4d946 by fendor at 2020-06-01T06:36:18-04:00
Lint rhs of IfaceRule

- - - - -
1cef6126 by Jeremy Schlatter at 2020-06-01T06:37:00-04:00
Fix wording in documentation

The duplicate "orphan instance" phrase here doesn't make sense, and was
probably an accident.

- - - - -
5aaf08f2 by Takenobu Tani at 2020-06-01T06:37:43-04:00
configure: Modify aclocal.m4 according to new module hierarchy

This patch updates file paths according to new module hierarchy [1]:

* Rename:
  * compiler/GHC/Parser.hs       <= compiler/parser/Parser.hs
  * compiler/GHC/Parser/Lexer.hs <= compiler/Parser/Lexer.hs

* Add:
  * compiler/GHC/Cmm/Lexer.hs

[1]: https://gitlab.haskell.org/ghc/ghc/-/wikis/Make-GHC-codebase-more-modular

- - - - -
15857ad8 by Ben Gamari at 2020-06-01T06:38:26-04:00
testsuite: Don't fail if we can't unlink __symlink_test

Afterall, it's possible we were unable to create it due to lack of
symlink permission.

- - - - -
4a7229ef by Ben Gamari at 2020-06-01T06:38:26-04:00
testsuite: Refactor ghostscript detection

Tamar reported that he saw crashes due to unhandled exceptions.

- - - - -
2ab37eaf by Ben Gamari at 2020-06-01T06:38:26-04:00
testsuite/perf_notes: Fix ill-typed assignments

- - - - -
e45d5b66 by Ben Gamari at 2020-06-01T06:38:26-04:00
testsuite/testutil: Fix bytes/str mismatch

- - - - -
7002d0cb by Ben Gamari at 2020-06-01T06:38:26-04:00
testsuite: Work around spurious mypy failure

- - - - -
11390e3a by Takenobu Tani at 2020-06-01T06:39:05-04:00
Clean up file paths for new module hierarchy

This updates comments only.
This patch replaces file references according to new module hierarchy.

See also:
* https://gitlab.haskell.org/ghc/ghc/-/wikis/Make-GHC-codebase-more-modular
* https://gitlab.haskell.org/ghc/ghc/issues/13009

- - - - -
8f2e5732 by Takenobu Tani at 2020-06-01T06:39:05-04:00
Modify file paths to module paths for new module hierarchy

This updates comments only.

This patch replaces module references according to new module
hierarchy [1][2].

For files under the `compiler/` directory, I replace them as
module paths instead of file paths. For instance,
`GHC.Unit.State` instead of `compiler/GHC/Unit/State.hs` [3].

For current and future haddock's markup, this patch encloses
the module name with "" [4].

[1]: https://gitlab.haskell.org/ghc/ghc/-/wikis/Make-GHC-codebase-more-modular
[2]: https://gitlab.haskell.org/ghc/ghc/issues/13009
[3]: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/3375#note_276613
[4]: https://haskell-haddock.readthedocs.io/en/latest/markup.html#linking-to-modules

- - - - -
68b71c4a by Tom Ellis at 2020-06-01T06:39:55-04:00
Rename the singleton tuple GHC.Tuple.Unit to GHC.Tuple.Solo

- - - - -
95da76c2 by Sylvain Henry at 2020-06-01T06:40:41-04:00
Hadrian: fix binary-dist target for cross-compilation

- - - - -
730fcd54 by Vladislav Zavialov at 2020-06-01T06:41:18-04:00
Improve parser error messages for the @-operator

Since GHC diverges from the Haskell Report by allowing the user
to define (@) as an infix operator, we better give a good
error message when the user does so unintentionally.

In general, this is rather hard to do, as some failures will be
discovered only in the renamer or the type checker:

	x :: (Integer, Integer)
	x @ (a, b) = (1, 2)

This patch does *not* address this general case.

However, it gives much better error messages when the binding
is not syntactically valid:

	pairs xs @ (_:xs') = zip xs xs'

Before this patch, the error message was rather puzzling:

	<interactive>:1:1: error: Parse error in pattern: pairs

After this patch, the error message includes a hint:

	<interactive>:1:1: error:
	    Parse error in pattern: pairs
	    In a function binding for the ‘@’ operator.
	    Perhaps you meant an as-pattern, which must not be surrounded by whitespace

- - - - -
0fde5377 by Vladislav Zavialov at 2020-06-01T06:41:18-04:00
Improve parser error messages for TypeApplications

With this patch, we always parse  f @t  as a type application,
thereby producing better error messages.

This steals two syntactic forms:

* Prefix form of the @-operator in expressions. Since the @-operator is
  a divergence from the Haskell Report anyway, this is not a major loss.

* Prefix form of @-patterns. Since we are stealing loose infix form
  anyway, might as well sacrifice the prefix form for the sake of much
  better error messages.

- - - - -
c68e7e1e by Vladislav Zavialov at 2020-06-01T06:41:18-04:00
Improve parser error messages for TemplateHaskellQuotes

While [e| |], [t| |], [d| |], and so on, steal syntax from list
comprehensions, [| |] and [|| ||] do not steal any syntax.

Thus we can improve error messages by always accepting them in the
lexer. Turns out the renamer already performs necessary validation.

- - - - -
120aedbd by Ben Gamari at 2020-06-01T16:07:02-04:00
gitlab-ci: Disable use of ld.lld on ARMv7

It turns out that lld non-deterministically fails on ARMv7. I suspect
this may be due to the a kernel regression as this only started
happening when we upgraded to 5.4. Nevertheless, easily avoided by
simply sticking with gold.

Works around #18280.

- - - - -
d6279ff0 by Ben Gamari at 2020-06-02T13:03:30-04:00
gitlab-ci: Ensure that workaround for #18280 applies to bindisttest

We need to ensure that the `configure` flags working around #18280 are
propagated to the bindisttest `configure` as well.

- - - - -
cb5c31b5 by Ben Gamari at 2020-06-03T17:55:04-04:00
gitlab-ci: Allow ARMv7 job to fail

Due to #18298.

- - - - -
32a4ae90 by John Ericson at 2020-06-04T04:34:42-04:00
Clean up boot vs non-boot disambiguating types

We often have (ModuleName, Bool) or (Module, Bool) pairs for "extended"
module names (without or with a unit id) disambiguating boot and normal
modules. We think this is important enough across the compiler that it
deserves a new nominal product type. We do this with synnoyms and a
functor named with a `Gen` prefix, matching other newly created
definitions.

It was also requested that we keep custom `IsBoot` / `NotBoot` sum type.
So we have it too. This means changing many the many bools to use that
instead.

Updates `haddock` submodule.

- - - - -
c05756cd by Niklas Hambüchen at 2020-06-04T04:35:24-04:00
docs: Add more details on InterruptibleFFI.

Details from https://gitlab.haskell.org/ghc/ghc/issues/8684
and https://github.com/takano-akio/filelock/pull/7#discussion_r280332430

- - - - -
1b975aed by Andrew Martin at 2020-06-04T04:36:03-04:00
Allow finalizeForeignPtr to be called on FinalPtr/PlainPtr.

MR 2165 (commit 49301ad6226d9a83d110bee8c419615dd94f5ded) regressed
finalizeForeignPtr by throwing exceptions when PlainPtr was encounterd.
This regression did not make it into a release of GHC. Here, the
original behavior is restored, and FinalPtr is given the same treatment
as PlainPtr.

- - - - -
2bd3929a by Luke Lau at 2020-06-04T04:36:41-04:00
Fix documentation on type families not being extracted

It looks like the location of the Names used for CoAxioms on type
families are now located at their type constructors. Previously, Docs.hs
thought the Names were located in the RHS, so the RealSrcSpan in the
instanceMap and getInstLoc didn't match up. Fixes #18241

- - - - -
6735b9d9 by Ben Gamari at 2020-06-04T04:37:21-04:00
GHC.Hs.Instances: Compile with -O0

This module contains exclusively Data instances, which are going to be
slow no matter what we do. Furthermore, they are incredibly slow to
compile with optimisation (see #9557). Consequently we compile this with
-O0.  See #18254.

- - - - -
c330331a by nineonine at 2020-06-04T04:37:59-04:00
Add test for #17669

- - - - -
cab684f0 by Ben Gamari at 2020-06-04T04:38:36-04:00
rts: Add Windows-specific implementation of rtsSleep

Previously we would use the POSIX path, which uses `nanosleep`. However,
it turns out that `nanosleep` is provided by `libpthread` on Windows. In
general we don't want to incur such a dependency. Avoid this by simply
using `Sleep` on Windows.

Fixes #18272.

- - - - -
ad44b504 by Ben Gamari at 2020-06-04T04:38:36-04:00
compiler: Disable use of process jobs with process < 1.6.9

Due to #17926.

- - - - -
6a4098a4 by Moritz Angermann at 2020-06-04T04:55:51-04:00
[linker] Adds void printLoadedObjects(void);

This allows us to dump in-memory object code locations for debugging.

Fixup printLoadedObjects prototype

- - - - -
af5e3a88 by Artem Pelenitsyn at 2020-06-05T03:18:49-04:00
base: fix sign confusion in log1mexp implementation (fix #17125)

author: claude (https://gitlab.haskell.org/trac-claude)

The correct threshold for log1mexp is -(log 2) with the current specification
of log1mexp. This change improves accuracy for large negative inputs.

To avoid code duplication, a small helper function is added;
it isn't the default implementation in Floating because it needs Ord.

This patch does nothing to address that the Haskell specification is
different from that in common use in other languages.

- - - - -
2b792fac by Simon Peyton Jones at 2020-06-05T09:27:50-04:00
Simple subsumption

This patch simplifies GHC to use simple subsumption.
  Ticket #17775

Implements GHC proposal #287
   https://github.com/ghc-proposals/ghc-proposals/blob/master/
   proposals/0287-simplify-subsumption.rst

All the motivation is described there; I will not repeat it here.
The implementation payload:
 * tcSubType and friends become noticably simpler, because it no
   longer uses eta-expansion when checking subsumption.
 * No deeplyInstantiate or deeplySkolemise

That in turn means that some tests fail, by design; they can all
be fixed by eta expansion.  There is a list of such changes below.

Implementing the patch led me into a variety of sticky corners, so
the patch includes several othe changes, some quite significant:

* I made String wired-in, so that
    "foo" :: String   rather than
    "foo" :: [Char]
  This improves error messages, and fixes #15679

* The pattern match checker relies on knowing about in-scope equality
  constraints, andd adds them to the desugarer's environment using
  addTyCsDs.  But the co_fn in a FunBind was missed, and for some reason
  simple-subsumption ends up with dictionaries there. So I added a
  call to addTyCsDs.  This is really part of #18049.

* I moved the ic_telescope field out of Implication and into
  ForAllSkol instead.  This is a nice win; just expresses the code
  much better.

* There was a bug in GHC.Tc.TyCl.Instance.tcDataFamInstHeader.
  We called checkDataKindSig inside tc_kind_sig, /before/
  solveEqualities and zonking.  Obviously wrong, easily fixed.

* solveLocalEqualitiesX: there was a whole mess in here, around
  failing fast enough.  I discovered a bad latent bug where we
  could successfully kind-check a type signature, and use it,
  but have unsolved constraints that could fill in coercion
  holes in that signature --  aargh.

  It's all explained in Note [Failure in local type signatures]
  in GHC.Tc.Solver. Much better now.

* I fixed a serious bug in anonymous type holes. IN
    f :: Int -> (forall a. a -> _) -> Int
  that "_" should be a unification variable at the /outer/
  level; it cannot be instantiated to 'a'.  This was plain
  wrong.  New fields mode_lvl and mode_holes in TcTyMode,
  and auxiliary data type GHC.Tc.Gen.HsType.HoleMode.

  This fixes #16292, but makes no progress towards the more
  ambitious #16082

* I got sucked into an enormous refactoring of the reporting of
  equality errors in GHC.Tc.Errors, especially in
      mkEqErr1
      mkTyVarEqErr
      misMatchMsg
      misMatchMsgOrCND
  In particular, the very tricky mkExpectedActualMsg function
  is gone.

  It took me a full day.  But the result is far easier to understand.
  (Still not easy!)  This led to various minor improvements in error
  output, and an enormous number of test-case error wibbles.

  One particular point: for occurs-check errors I now just say
     Can't match 'a' against '[a]'
  rather than using the intimidating language of "occurs check".

* Pretty-printing AbsBinds

Tests review

* Eta expansions
   T11305: one eta expansion
   T12082: one eta expansion (undefined)
   T13585a: one eta expansion
   T3102:  one eta expansion
   T3692:  two eta expansions (tricky)
   T2239:  two eta expansions
   T16473: one eta
   determ004: two eta expansions (undefined)
   annfail06: two eta (undefined)
   T17923: four eta expansions (a strange program indeed!)
   tcrun035: one eta expansion

* Ambiguity check at higher rank.  Now that we have simple
  subsumption, a type like
     f :: (forall a. Eq a => Int) -> Int
  is no longer ambiguous, because we could write
     g :: (forall a. Eq a => Int) -> Int
     g = f
  and it'd typecheck just fine.  But f's type is a bit
  suspicious, and we might want to consider making the
  ambiguity check do a check on each sub-term.  Meanwhile,
  these tests are accepted, whereas they were previously
  rejected as ambiguous:
     T7220a
     T15438
     T10503
     T9222

* Some more interesting error message wibbles
   T13381: Fine: one error (Int ~ Exp Int)
           rather than two (Int ~ Exp Int, Exp Int ~ Int)
   T9834:  Small change in error (improvement)
   T10619: Improved
   T2414:  Small change, due to order of unification, fine
   T2534:  A very simple case in which a change of unification order
           means we get tow unsolved constraints instead of one
   tc211: bizarre impredicative tests; just accept this for now

Updates Cabal and haddock submodules.

Metric Increase:
  T12150
  T12234
  T5837
  haddock.base
Metric Decrease:
  haddock.compiler
  haddock.Cabal
  haddock.base

Merge note: This appears to break the
`UnliftedNewtypesDifficultUnification` test. It has been marked as
broken in the interest of merging.

(cherry picked from commit 66b7b195cb3dce93ed5078b80bf568efae904cc5)

- - - - -
2dff8141 by Ryan Scott at 2020-06-05T14:21:24-04:00
Simplify bindLHsTyVarBndrs and bindHsQTyVars

Both `bindLHsTyVarBndrs` and `bindHsQTyVars` take two separate
`Maybe` arguments, which I find terribly confusing. Thankfully, it's
possible to remove one `Maybe` argument from each of these functions,
which this patch accomplishes:

* `bindHsQTyVars` takes a `Maybe SDoc` argument, which is `Just` if
  GHC should warn about any of the quantified type variables going
  unused. However, every call site uses `Nothing` in practice. This
  makes sense, since it doesn't really make sense to warn about
  unused type variables bound by an `LHsQTyVars`. For instance, you
  wouldn't warn about the `a` in `data Proxy a = Proxy` going unused.

  As a result, I simply remove this `Maybe SDoc` argument altogether.
* `bindLHsTyVarBndrs` also takes a `Maybe SDoc` argument for the same
  reasons that `bindHsQTyVars` took one. To make things more
  confusing, however, `bindLHsTyVarBndrs` also takes a separate
  `HsDocContext` argument, which is pretty-printed (to an `SDoc`) in
  warnings and error messages.

  In practice, the `Maybe SDoc` and the `HsDocContext` often contain
  the same text. See the call sites for `bindLHsTyVarBndrs` in
  `rnFamInstEqn` and `rnConDecl`, for instance. There are only a
  handful of call sites where the text differs between the
  `Maybe SDoc` and `HsDocContext` arguments:

  * In `rnHsRuleDecl`, where the `Maybe SDoc` says "`In the rule`"
    and the `HsDocContext` says "`In the transformation rule`".
  * In `rnHsTyKi`/`rn_ty`, where the `Maybe SDoc` says
    "`In the type`" but the `HsDocContext` is inhereted from the
    surrounding context (e.g., if `rnHsTyKi` were called on a
    top-level type signature, the `HsDocContext` would be
    "`In the type signature`" instead)

  In both cases, warnings/error messages arguably _improve_ by
  unifying making the `Maybe SDoc`'s text match that of the
  `HsDocContext`. As a result, I decided to remove the `Maybe SDoc`
  argument to `bindLHsTyVarBndrs` entirely and simply reuse the text
  from the `HsDocContext`. (I decided to change the phrase
  "transformation rule" to "rewrite rule" while I was in the area.)

  The `Maybe SDoc` argument has one other purpose: signaling when to
  emit "`Unused quantified type variable`" warnings. To recover this
  functionality, I replaced the `Maybe SDoc` argument with a
  boolean-like `WarnUnusedForalls` argument. The only
  `bindLHsTyVarBndrs` call site that chooses _not_ to emit these
  warnings in `bindHsQTyVars`.

- - - - -
e372331b by Ben Gamari at 2020-06-07T08:46:41-04:00
hadrian: Add missing deriveConstants dependency on ghcplatform.h

deriveConstants wants to compile C sources which #include PosixSource.h,
which itself #includes ghcplatform.h. Make sure that Hadrian knows
about this dependency.

Fixes #18290.

- - - - -
b022051a by Moritz Angermann at 2020-06-07T08:46:42-04:00
ghc-prim needs to depend on libc and libm

libm is just an empty shell on musl, and all the math functions are contained in
libc.

- - - - -
6dae6548 by Moritz Angermann at 2020-06-07T08:46:42-04:00
Disable DLL loading if without system linker

Some platforms (musl, aarch64) do not have a working dynamic linker
implemented in the libc, even though we might see dlopen.  It will
ultimately just return that this is not supported.  Hence we'll add
a flag to the compiler to flat our disable loading dlls.  This is
needed as we will otherwise try to load the shared library even
if this will subsequently fail.  At that point we have given up
looking for static options though.

- - - - -
4a158ffc by Moritz Angermann at 2020-06-07T08:46:43-04:00
Range is actually +/-2^32, not +/-2^31

See also: https://static.docs.arm.com/ihi0056/g/aaelf64.pdf

- - - - -
f1bfb806 by Ben Gamari at 2020-06-07T10:49:30-04:00
OccurAnal: Avoid exponential behavior due to where clauses

Previously the `Var` case of `occAnalApp` could in some cases (namely
in the case of `runRW#` applications) call `occAnalRhs` two. In the case
of nested `runRW#`s this results in exponential complexity. In some
cases the compilation time that resulted would be very long indeed
(see #18296).

Fixes #18296.

Metric Decrease:
    T9961
    T12150
    T12234

- - - - -
9b607671 by Takenobu Tani at 2020-06-09T08:05:46-04:00
Add link to GHC's wiki in the GHC API header

This adds a URL to point to GHC's wiki in the GHC API header.
Newcomers could easily find more information from the GHC API's
web like [1].

[1]: Current version, https://ghc.gitlab.haskell.org/ghc/doc/libraries/ghc-8.11.0.20200604/index.html

[skip ci]

- - - - -
72c7fe9a by Ryan Scott at 2020-06-09T08:06:24-04:00
Make GADT constructors adhere to the forall-or-nothing rule properly

Issue #18191 revealed that the types of GADT constructors don't quite
adhere to the `forall`-or-nothing rule. This patch serves to clean up
this sad state of affairs somewhat. The main change is not in the
code itself, but in the documentation, as this patch introduces two
sections to the GHC User's Guide:

* A "Formal syntax for GADTs" section that presents a BNF-style
  grammar for what is and isn't allowed in GADT constructor types.
  This mostly exists to codify GHC's existing behavior, but it also
  imposes a new restriction that addresses #18191: the outermost
  `forall` and/or context in a GADT constructor is not allowed to be
  surrounded by parentheses. Doing so would make these
  `forall`s/contexts nested, and GADTs do not support nested
  `forall`s/contexts at present.

* A "`forall`-or-nothing rule" section that describes exactly what
  the `forall`-or-nothing rule is all about. Surprisingly, there was
  no mention of this anywhere in the User's Guide up until now!

To adhere the new specification in the "Formal syntax for GADTs"
section of the User's Guide, the following code changes were made:

* A new function, `GHC.Hs.Type.splitLHsGADTPrefixTy`, was introduced.
  This is very much like `splitLHsSigmaTy`, except that it avoids
  splitting apart any parentheses, which can be syntactically
  significant for GADT types. See
  `Note [No nested foralls or contexts in GADT constructors]` in
  `GHC.Hs.Type`.

* `ConDeclGADTPrefixPs`, an extension constructor for `XConDecl`, was
  introduced so that `GHC.Parser.PostProcess.mkGadtDecl` can return
  it when given a prefix GADT constructor. Unlike `ConDeclGADT`,
  `ConDeclGADTPrefixPs` does not split the GADT type into its argument
  and result types, as this cannot be done until after the type is
  renamed (see `Note [GADT abstract syntax]` in `GHC.Hs.Decls` for why
  this is the case).

* `GHC.Renamer.Module.rnConDecl` now has an additional case for
  `ConDeclGADTPrefixPs` that (1) splits apart the full `LHsType` into
  its `forall`s, context, argument types, and result type, and
  (2) checks for nested `forall`s/contexts. Step (2) used to be
  performed the typechecker (in `GHC.Tc.TyCl.badDataConTyCon`) rather
  than the renamer, but now the relevant code from the typechecker
  can simply be deleted.

  One nice side effect of this change is that we are able to give a
  more accurate error message for GADT constructors that use visible
  dependent quantification (e.g., `MkFoo :: forall a -> a -> Foo a`),
  which improves the stderr in the `T16326_Fail6` test case.

Fixes #18191. Bumps the Haddock submodule.

- - - - -
a47e6442 by Ryan Scott at 2020-06-10T03:39:12-04:00
Always use rnImplicitBndrs to bring implicit tyvars into scope

This implements a first step towards #16762 by changing the renamer
to always use `rnImplicitBndrs` to bring implicitly bound type
variables into scope. The main change is in `rnFamInstEqn` and
`bindHsQTyVars`, which previously used _ad hoc_ methods of binding
their implicit tyvars.

There are a number of knock-on consequences:

* One of the reasons that `rnFamInstEqn` used an _ad hoc_ binding
  mechanism was to give more precise source locations in
  `-Wunused-type-patterns` warnings. (See
  https://gitlab.haskell.org/ghc/ghc/issues/16762#note_273343 for an
  example of this.) However, these warnings are actually a little
  _too_ precise, since implicitly bound type variables don't have
  exact binding sites like explicitly bound type variables do.
  A similar problem existed for
  "`Different names for the same type variable`" errors involving
  implicit tyvars bound by `bindHsQTyVars`.
  Therefore, we simply accept the less precise (but more accurate)
  source locations from `rnImplicitBndrs` in `rnFamInstEqn` and
  `bindHsQTyVars`. See
  `Note [Source locations for implicitly bound type variables]` in
  `GHC.Rename.HsType` for the full story.
* In order for `rnImplicitBndrs` to work in `rnFamInstEqn`, it needs
  to be able to look up names from the parent class (in the event
  that we are renaming an associated type family instance). As a
  result, `rnImplicitBndrs` now takes an argument of type
  `Maybe assoc`, which is `Just` in the event that a type family
  instance is associated with a class.
* Previously, GHC kept track of three type synonyms for free type
  variables in the renamer: `FreeKiTyVars`, `FreeKiTyVarsDups`
  (which are allowed to contain duplicates), and
  `FreeKiTyVarsNoDups` (which contain no duplicates). However, making
  is a distinction between `-Dups` and `-NoDups` is now pointless, as
  all code that returns `FreeKiTyVars{,Dups,NoDups}` will eventually
  end up being passed to `rnImplicitBndrs`, which removes duplicates.
  As a result, I decided to just get rid of `FreeKiTyVarsDups` and
  `FreeKiTyVarsNoDups`, leaving only `FreeKiTyVars`.
* The `bindLRdrNames` and `deleteBys` functions are now dead code, so
  I took the liberty of removing them.

- - - - -
24879129 by Takenobu Tani at 2020-06-10T03:39:59-04:00
Clarify leaf module names for new module hierarchy

This updates comments only.

This patch replaces leaf module names according to new module
hierarchy [1][2] as followings:

* Expand leaf names to easily find the module path:
  for instance, `Id.hs` to `GHC.Types.Id`.

* Modify leaf names according to new module hierarchy:
  for instance, `Convert.hs` to `GHC.ThToHs`.

* Fix typo:
  for instance, `GHC.Core.TyCo.Rep.hs` to `GHC.Core.TyCo.Rep`

See also !3375

[1]: https://gitlab.haskell.org/ghc/ghc/-/wikis/Make-GHC-codebase-more-modular
[2]: https://gitlab.haskell.org/ghc/ghc/issues/13009

- - - - -
92de9e25 by Ömer Sinan Ağacan at 2020-06-10T03:41:07-04:00
rts: Remove unused GET_ENTRY closure macro

This macro is not used and got broken in the meantime, as ENTRY_CODE was
deleted.

- - - - -
87102928 by Ömer Sinan Ağacan at 2020-06-10T03:41:50-04:00
Fix -fkeep-cafs flag name in users guide

- - - - -
ccd6843d by Shayne Fletcher at 2020-06-10T04:14:57-04:00
Expose impliedGFlags, impledOffGFlags, impliedXFlags

- - - - -
7a737e89 by Ömer Sinan Ağacan at 2020-06-10T04:14:58-04:00
Cross-module LambdaFormInfo passing

- Store LambdaFormInfos of exported Ids in interface files
- Use them in importing modules

This is for optimization purposes: if we know LambdaFormInfo of imported
Ids we can generate more efficient calling code, see `getCallMethod`.

Exporting (putting them in interface files or in ModDetails) and
importing (reading them from interface files) are both optional. We
don't assume known LambdaFormInfos anywhere and do not change how we
call Ids with unknown LambdaFormInfos.

Runtime, allocation, and residency numbers when building
Cabal-the-library (commit 0d4ee7ba3):

(Log and .hp files are in the MR: !2842)

|     | GHC HEAD | This patch | Diff           |
|-----|----------|------------|----------------|
| -O0 |  0:35.89 |    0:34.10 | -1.78s, -4.98% |
| -O1 |  2:24.01 |    2:23.62 | -0.39s, -0.27% |
| -O2 |  2:52.23 |    2:51.35 | -0.88s, -0.51% |

|     | GHC HEAD        | This patch      | Diff                       |
|-----|-----------------|-----------------|----------------------------|
| -O0 |  54,843,608,416 |  54,878,769,544 |  +35,161,128 bytes, +0.06% |
| -O1 | 227,136,076,400 | 227,569,045,168 | +432,968,768 bytes, +0.19% |
| -O2 | 266,147,063,296 | 266,749,643,440 | +602,580,144 bytes, +0.22% |

NOTE: Residency is measured with extra runtime args: `-i0 -h` which effectively
turn all GCs into major GCs, and do GC more often.

|     | GHC HEAD                   | This patch                   | Diff                       |
|-----|----------------------------|------------------------------|----------------------------|
| -O0 | 410,284,000 (910 samples)  | 411,745,008 (906 samples)    | +1,461,008 bytes, +0.35%   |
| -O1 | 928,580,856 (2109 samples) | 943,506,552 (2103 samples)   | +14,925,696 bytes, +1.60%  |
| -O2 | 993,951,352 (2549 samples) | 1,010,156,328 (2545 samples) | +16,204,9760 bytes, +1.63% |

NoFib results:

--------------------------------------------------------------------------------
        Program           Size    Allocs    Instrs     Reads    Writes
--------------------------------------------------------------------------------
             CS           0.0%      0.0%     +0.0%     +0.0%     +0.0%
            CSD           0.0%      0.0%      0.0%     +0.0%     +0.0%
             FS           0.0%      0.0%     +0.0%     +0.0%     +0.0%
              S           0.0%      0.0%     +0.0%     +0.0%     +0.0%
             VS           0.0%      0.0%     +0.0%     +0.0%     +0.0%
            VSD           0.0%      0.0%     +0.0%     +0.0%     +0.1%
            VSM           0.0%      0.0%     +0.0%     +0.0%     +0.0%
           anna           0.0%      0.0%     -0.3%     -0.8%     -0.0%
           ansi           0.0%      0.0%     -0.0%     -0.0%      0.0%
           atom           0.0%      0.0%     -0.0%     -0.0%      0.0%
         awards           0.0%      0.0%     -0.1%     -0.3%      0.0%
         banner           0.0%      0.0%     -0.0%     -0.0%     -0.0%
     bernouilli           0.0%      0.0%     -0.0%     -0.0%     -0.0%
   binary-trees           0.0%      0.0%     -0.0%     -0.0%     +0.0%
          boyer           0.0%      0.0%     -0.0%     -0.0%      0.0%
         boyer2           0.0%      0.0%     -0.0%     -0.0%      0.0%
           bspt           0.0%      0.0%     -0.0%     -0.2%      0.0%
      cacheprof           0.0%      0.0%     -0.1%     -0.4%     +0.0%
       calendar           0.0%      0.0%     -0.0%     -0.0%      0.0%
       cichelli           0.0%      0.0%     -0.9%     -2.4%      0.0%
        circsim           0.0%      0.0%     -0.0%     -0.0%      0.0%
       clausify           0.0%      0.0%     -0.1%     -0.3%      0.0%
  comp_lab_zift           0.0%      0.0%     -0.0%     -0.0%     +0.0%
       compress           0.0%      0.0%     -0.0%     -0.0%     -0.0%
      compress2           0.0%      0.0%     -0.0%     -0.0%      0.0%
    constraints           0.0%      0.0%     -0.1%     -0.2%     -0.0%
   cryptarithm1           0.0%      0.0%     -0.0%     -0.0%      0.0%
   cryptarithm2           0.0%      0.0%     -1.4%     -4.1%     -0.0%
            cse           0.0%      0.0%     -0.0%     -0.0%     -0.0%
   digits-of-e1           0.0%      0.0%     -0.0%     -0.0%     -0.0%
   digits-of-e2           0.0%      0.0%     -0.0%     -0.0%     -0.0%
         dom-lt           0.0%      0.0%     -0.1%     -0.2%      0.0%
          eliza           0.0%      0.0%     -0.5%     -1.5%      0.0%
          event           0.0%      0.0%     -0.0%     -0.0%     -0.0%
    exact-reals           0.0%      0.0%     -0.1%     -0.3%     +0.0%
         exp3_8           0.0%      0.0%     -0.0%     -0.0%     -0.0%
         expert           0.0%      0.0%     -0.3%     -1.0%     -0.0%
 fannkuch-redux           0.0%      0.0%     +0.0%     +0.0%     +0.0%
          fasta           0.0%      0.0%     -0.0%     -0.0%     +0.0%
            fem           0.0%      0.0%     -0.0%     -0.0%      0.0%
            fft           0.0%      0.0%     -0.0%     -0.0%      0.0%
           fft2           0.0%      0.0%     -0.0%     -0.0%      0.0%
       fibheaps           0.0%      0.0%     -0.0%     -0.0%     +0.0%
           fish           0.0%      0.0%      0.0%     -0.0%     +0.0%
          fluid           0.0%      0.0%     -0.4%     -1.2%     +0.0%
         fulsom           0.0%      0.0%     -0.0%     -0.0%      0.0%
         gamteb           0.0%      0.0%     -0.1%     -0.3%      0.0%
            gcd           0.0%      0.0%     -0.0%     -0.0%      0.0%
    gen_regexps           0.0%      0.0%     -0.0%     -0.0%     -0.0%
         genfft           0.0%      0.0%     -0.0%     -0.0%      0.0%
             gg           0.0%      0.0%     -0.0%     -0.0%     +0.0%
           grep           0.0%      0.0%     -0.0%     -0.0%     -0.0%
         hidden           0.0%      0.0%     -0.1%     -0.4%     -0.0%
            hpg           0.0%      0.0%     -0.2%     -0.5%     +0.0%
            ida           0.0%      0.0%     -0.0%     -0.0%     +0.0%
          infer           0.0%      0.0%     -0.3%     -0.8%     -0.0%
        integer           0.0%      0.0%     -0.0%     -0.0%     +0.0%
      integrate           0.0%      0.0%     -0.0%     -0.0%      0.0%
   k-nucleotide           0.0%      0.0%     -0.0%     -0.0%     +0.0%
          kahan           0.0%      0.0%     -0.0%     -0.0%     +0.0%
        knights           0.0%      0.0%     -2.2%     -5.4%      0.0%
         lambda           0.0%      0.0%     -0.6%     -1.8%      0.0%
     last-piece           0.0%      0.0%     -0.0%     -0.0%      0.0%
           lcss           0.0%      0.0%     -0.0%     -0.1%      0.0%
           life           0.0%      0.0%     -0.0%     -0.1%      0.0%
           lift           0.0%      0.0%     -0.2%     -0.6%     +0.0%
         linear           0.0%      0.0%     -0.0%     -0.0%     -0.0%
      listcompr           0.0%      0.0%     -0.0%     -0.0%      0.0%
       listcopy           0.0%      0.0%     -0.0%     -0.0%      0.0%
       maillist           0.0%      0.0%     -0.1%     -0.3%     +0.0%
         mandel           0.0%      0.0%     -0.0%     -0.0%      0.0%
        mandel2           0.0%      0.0%     -0.0%     -0.0%     -0.0%
           mate          +0.0%      0.0%     -0.0%     -0.0%     -0.0%
        minimax           0.0%      0.0%     -0.2%     -1.0%      0.0%
        mkhprog           0.0%      0.0%     -0.1%     -0.2%     -0.0%
     multiplier           0.0%      0.0%     -0.0%     -0.0%     -0.0%
         n-body           0.0%      0.0%     -0.0%     -0.0%     +0.0%
       nucleic2           0.0%      0.0%     -0.1%     -0.2%      0.0%
           para           0.0%      0.0%     -0.0%     -0.0%     -0.0%
      paraffins           0.0%      0.0%     -0.0%     -0.0%      0.0%
         parser           0.0%      0.0%     -0.2%     -0.7%      0.0%
        parstof           0.0%      0.0%     -0.0%     -0.0%     +0.0%
            pic           0.0%      0.0%     -0.0%     -0.0%      0.0%
       pidigits           0.0%      0.0%     +0.0%     +0.0%     +0.0%
          power           0.0%      0.0%     -0.2%     -0.6%     +0.0%
         pretty           0.0%      0.0%     -0.0%     -0.0%     -0.0%
         primes           0.0%      0.0%     -0.0%     -0.0%      0.0%
      primetest           0.0%      0.0%     -0.0%     -0.0%     -0.0%
         prolog           0.0%      0.0%     -0.3%     -1.1%      0.0%
         puzzle           0.0%      0.0%     -0.0%     -0.0%      0.0%
         queens           0.0%      0.0%     -0.0%     -0.0%     +0.0%
        reptile           0.0%      0.0%     -0.0%     -0.0%      0.0%
reverse-complem           0.0%      0.0%     -0.0%     -0.0%     +0.0%
        rewrite           0.0%      0.0%     -0.7%     -2.5%     -0.0%
           rfib           0.0%      0.0%     -0.0%     -0.0%      0.0%
            rsa           0.0%      0.0%     -0.0%     -0.0%      0.0%
            scc           0.0%      0.0%     -0.1%     -0.2%     -0.0%
          sched           0.0%      0.0%     -0.0%     -0.0%     -0.0%
            scs           0.0%      0.0%     -1.0%     -2.6%     +0.0%
         simple           0.0%      0.0%     +0.0%     -0.0%     +0.0%
          solid           0.0%      0.0%     -0.0%     -0.0%      0.0%
        sorting           0.0%      0.0%     -0.6%     -1.6%      0.0%
  spectral-norm           0.0%      0.0%     +0.0%      0.0%     +0.0%
         sphere           0.0%      0.0%     -0.0%     -0.0%     -0.0%
         symalg           0.0%      0.0%     -0.0%     -0.0%     +0.0%
            tak           0.0%      0.0%     -0.0%     -0.0%      0.0%
      transform           0.0%      0.0%     -0.0%     -0.0%      0.0%
       treejoin           0.0%      0.0%     -0.0%     -0.0%      0.0%
      typecheck           0.0%      0.0%     -0.0%     -0.0%     +0.0%
        veritas          +0.0%      0.0%     -0.2%     -0.4%     +0.0%
           wang           0.0%      0.0%     -0.0%     -0.0%      0.0%
      wave4main           0.0%      0.0%     -0.0%     -0.0%     -0.0%
   wheel-sieve1           0.0%      0.0%     -0.0%     -0.0%     -0.0%
   wheel-sieve2           0.0%      0.0%     -0.0%     -0.0%     +0.0%
           x2n1           0.0%      0.0%     -0.0%     -0.0%     -0.0%
--------------------------------------------------------------------------------
            Min           0.0%      0.0%     -2.2%     -5.4%     -0.0%
            Max          +0.0%      0.0%     +0.0%     +0.0%     +0.1%
 Geometric Mean          -0.0%     -0.0%     -0.1%     -0.3%     +0.0%

Metric increases micro benchmarks tracked in #17686:

Metric Increase:
    T12150
    T12234
    T12425
    T13035
    T5837
    T6048
    T9233

Co-authored-by: Andreas Klebinger <klebinger.andreas at gmx.at>

- - - - -
3b22b14a by Shayne Fletcher at 2020-06-10T04:15:01-04:00
Give Language a Bounded instance

- - - - -
9454511b by Simon Peyton Jones at 2020-06-10T04:17:06-04:00
Optimisation in Unique.Supply

This patch switches on -fno-state-hack in GHC.Types.Unique.Supply.

It turned out that my fixes for #18078 (coercion floating) changed the
optimisation pathway for mkSplitUniqSupply in such a way that we had
an extra allocation inside the inner loop.  Adding -fno-state-hack
fixed that -- and indeed the loop in mkSplitUniqSupply is a classic
example of the way in which -fno-state-hack can be bad; see #18238.

Moreover, the new code is better than the old.  They allocate
the same, but the old code ends up with a partial application.
The net effect is that the test
    perf/should_run/UniqLoop
runs 20% faster!   From 2.5s down to 2.0s.  The allocation numbers
are the same -- but elapsed time falls. Good!

The bad thing about this is that it's terribly delicate.  But
at least it's a good example of such delicacy in action.

There is a long Note [Optimising the unique supply] which now
explains all this.

- - - - -
6d49d5be by Simon Peyton Jones at 2020-06-10T04:17:06-04:00
Implement cast worker/wrapper properly

The cast worker/wrapper transformation transforms
   x = e |> co
into
   y = e
   x = y |> co

This is done by the simplifier, but we were being
careless about transferring IdInfo from x to y,
and about what to do if x is a NOINLNE function.
This resulted in a series of bugs:
     #17673, #18093, #18078.

This patch fixes all that:

* Main change is in GHC.Core.Opt.Simplify, and
  the new prepareBinding function, which does this
  cast worker/wrapper transform.
  See Note [Cast worker/wrappers].

* There is quite a bit of refactoring around
  prepareRhs, makeTrivial etc.  It's nicer now.

* Some wrappers from strictness and cast w/w, notably those for
  a function with a NOINLINE, should inline very late. There
  wasn't really a mechanism for that, which was an existing bug
  really; so I invented a new finalPhase = Phase (-1).  It's used
  for all simplifier runs after the user-visible phase 2,1,0 have
  run.  (No new runs of the simplifier are introduced thereby.)

  See new Note [Compiler phases] in GHC.Types.Basic;
  the main changes are in GHC.Core.Opt.Driver

* Doing this made me trip over two places where the AnonArgFlag on a
  FunTy was being lost so we could end up with (Num a -> ty)
  rather than (Num a => ty)
    - In coercionLKind/coercionRKind
    - In contHoleType in the Simplifier

  I fixed the former by defining mkFunctionType and using it in
  coercionLKind/RKind.

  I could have done the same for the latter, but the information
  is almost to hand.  So I fixed the latter by
    - adding sc_hole_ty to ApplyToVal (like ApplyToTy),
    - adding as_hole_ty to ValArg (like TyArg)
    - adding sc_fun_ty to StrictArg
  Turned out I could then remove ai_type from ArgInfo.  This is
  just moving the deck chairs around, but it worked out nicely.

  See the new Note [AnonArgFlag] in GHC.Types.Var

* When looking at the 'arity decrease' thing (#18093) I discovered
  that stable unfoldings had a much lower arity than the actual
  optimised function.  That's what led to the arity-decrease
  message.  Simple solution: eta-expand.

  It's described in Note [Eta-expand stable unfoldings]
  in GHC.Core.Opt.Simplify

* I also discovered that unsafeCoerce wasn't being inlined if
  the context was boring.  So (\x. f (unsafeCoerce x)) would
  create a thunk -- yikes!  I fixed that by making inlineBoringOK
  a bit cleverer: see Note [Inline unsafeCoerce] in GHC.Core.Unfold.

  I also found that unsafeCoerceName was unused, so I removed it.

I made a test case for #18078, and a very similar one for #17673.

The net effect of all this on nofib is very modest, but positive:

--------------------------------------------------------------------------------
        Program           Size    Allocs   Runtime   Elapsed  TotalMem
--------------------------------------------------------------------------------
           anna          -0.4%     -0.1%     -3.1%     -3.1%      0.0%
 fannkuch-redux          -0.4%     -0.3%     -0.1%     -0.1%      0.0%
       maillist          -0.4%     -0.1%     -7.8%     -1.0%    -14.3%
      primetest          -0.4%    -15.6%     -7.1%     -6.6%      0.0%
--------------------------------------------------------------------------------
            Min          -0.9%    -15.6%    -13.3%    -14.2%    -14.3%
            Max          -0.3%      0.0%    +12.1%    +12.4%      0.0%
 Geometric Mean          -0.4%     -0.2%     -2.3%     -2.2%     -0.1%

All following metric decreases are compile-time allocation decreases
between -1% and -3%:

Metric Decrease:
  T5631
  T13701
  T14697
  T15164

- - - - -
32fd37f5 by Luke Lau at 2020-06-10T04:17:22-04:00
Fix lookupGlobalOccRn_maybe sometimes reporting an error

In some cases it was possible for lookupGlobalOccRn_maybe to return an
error, when it should be returning a Nothing. If it called
lookupExactOcc_either when there were no matching GlobalRdrElts in the
otherwise case, it would return an error message. This could be caused
when lookupThName_maybe in Template Haskell was looking in different
namespaces (thRdrNameGuesses), guessing different namespaces that the
name wasn't guaranteed to be found in.

However, by addressing this some more accurate errors were being lost in
the conversion to Maybes. So some of the lookup* functions have been
shuffled about so that errors should always be ignored in
lookup*_maybes, and propagated otherwise.

This fixes #18263

- - - - -
9b283e1b by Roland Senn at 2020-06-10T04:17:34-04:00
Initialize the allocation counter in GHCi to 0 (Fixes #16012)

According to the documentation for the function `getAllocationCounter` in
[System.Mem](http://hackage.haskell.org/package/base-4.14.0.0/docs/System-Mem.html)
initialize the allocationCounter also in GHCi to 0.

- - - - -
8d07c48c by Sylvain Henry at 2020-06-10T04:17:36-04:00
test: fix conc038

We had spurious failures of conc038 test on CI with stdout:

```
 newThread started
-mainThread
-Haskell: 2
 newThread back again
+mainThread
 1 sec later

 shutting down
+Haskell: 2
```

- - - - -
4c7e9689 by Sebastian Graf at 2020-06-11T10:37:38+02:00
Release Notes: Add news from the pattern-match checker [skip ci]

- - - - -
3445b965 by Sylvain Henry at 2020-06-13T02:13:01-04:00
Only test T16190 with the NCG

T16190 is meant to test a NCG feature. It has already caused spurious
failures in other MRs (e.g. !2165) when LLVM is used.

- - - - -
2517a51c by Sylvain Henry at 2020-06-13T02:13:01-04:00
DynFlags refactoring VIII (#17957)

* Remove several uses of `sdocWithDynFlags`, especially in GHC.Llvm.*

* Add LlvmOpts datatype to store Llvm backend options

* Remove Outputable instances (for LlvmVar, LlvmLit, LlvmStatic and
  Llvm.MetaExpr) which require LlvmOpts.

* Rename ppMetaExpr into ppMetaAnnotExpr (pprMetaExpr is now used in place of `ppr :: MetaExpr -> SDoc`)

- - - - -
7a02599a by Sylvain Henry at 2020-06-13T02:13:02-04:00
Remove unused code

- - - - -
72d08610 by Sylvain Henry at 2020-06-13T02:13:02-04:00
Refactor homeUnit

* rename thisPackage into homeUnit
* document and refactor several Backpack things

- - - - -
8dc71f55 by Sylvain Henry at 2020-06-13T02:13:02-04:00
Rename unsafeGetUnitInfo into unsafeLookupUnit

- - - - -
f6be6e43 by Sylvain Henry at 2020-06-13T02:13:02-04:00
Add allowVirtualUnits field in PackageState

Instead of always querying DynFlags to know whether we are allowed to
use virtual units (i.e. instantiated on-the-fly, cf Note [About units]
in GHC.Unit), we store it once for all in
`PackageState.allowVirtualUnits`.

This avoids using DynFlags too much (cf #17957) and is preliminary work
for #14335.

- - - - -
e7272d53 by Sylvain Henry at 2020-06-13T02:13:02-04:00
Enhance UnitId use

* use UnitId instead of String to identify wired-in units
* use UnitId instead of Unit in the backend (Unit are only use by
  Backpack to produce type-checked interfaces, not real code)
* rename lookup functions for consistency
* documentation

- - - - -
9c5572cd by Sylvain Henry at 2020-06-13T02:13:02-04:00
Remove LinkerUnitId type alias

- - - - -
d345edfe by Sylvain Henry at 2020-06-13T02:13:02-04:00
Refactor WiredMap

* Remove WiredInUnitId and WiredUnitId type aliases

- - - - -
3d171cd6 by Sylvain Henry at 2020-06-13T02:13:03-04:00
Document and refactor `mkUnit` and `mkUnitInfoMap`

- - - - -
d2109b4f by Sylvain Henry at 2020-06-13T02:13:03-04:00
Remove PreloadUnitId type alias

- - - - -
f50c19b8 by Sylvain Henry at 2020-06-13T02:13:03-04:00
Rename listUnitInfoMap into listUnitInfo

There is no Map involved

- - - - -
ed533ec2 by Sylvain Henry at 2020-06-13T02:13:03-04:00
Rename Package into Unit

The terminology changed over time and now package databases contain
"units" (there can be several units compiled from a single Cabal
package: one per-component, one for each option set, one per
instantiation, etc.). We should try to be consistent internally and use
"units": that's what this renaming does. Maybe one day we'll fix the UI
too (e.g. replace -package-id with -unit-id, we already have
-this-unit-id and ghc-pkg has -unit-id...) but it's not done in this
patch.

* rename getPkgFrameworkOpts into getUnitFrameworkOpts
* rename UnitInfoMap into ClosureUnitInfoMap
* rename InstalledPackageIndex into UnitInfoMap
* rename UnusablePackages into UnusableUnits
* rename PackagePrecedenceIndex into UnitPrecedenceMap
* rename PackageDatabase into UnitDatabase
* rename pkgDatabase into unitDatabases
* rename pkgState into unitState
* rename initPackages into initUnits
* rename renamePackage into renameUnitInfo
* rename UnusablePackageReason into UnusableUnitReason
* rename getPackage* into getUnit*
* etc.

- - - - -
202728e5 by Sylvain Henry at 2020-06-13T02:13:03-04:00
Make ClosureUnitInfoMap uses UnitInfoMap

- - - - -
55b4263e by Sylvain Henry at 2020-06-13T02:13:03-04:00
Remove ClosureUnitInfoMap

- - - - -
653d17bd by Sylvain Henry at 2020-06-13T02:13:03-04:00
Rename Package into Unit (2)

* rename PackageState into UnitState
* rename findWiredInPackages into findWiredInUnits
* rename lookupModuleInAll[Packages,Units]
* etc.

- - - - -
ae900605 by Sylvain Henry at 2020-06-13T02:13:03-04:00
Move dump_mod_map into initUnits

- - - - -
598cc1dd by Sylvain Henry at 2020-06-13T02:13:03-04:00
Move wiring of homeUnitInstantiations outside of mkUnitState

- - - - -
437265eb by Sylvain Henry at 2020-06-13T02:13:03-04:00
Avoid timing module map dump in initUnits

- - - - -
9400aa93 by Sylvain Henry at 2020-06-13T02:13:03-04:00
Remove preload parameter of mkUnitState

* Remove preload parameter (unused)
* Don't explicitly return preloaded units: redundant because already
  returned as "preloadUnits" field of UnitState

- - - - -
266bc3d9 by Sylvain Henry at 2020-06-13T02:13:03-04:00
DynFlags: refactor unwireUnit

- - - - -
9e715c1b by Sylvain Henry at 2020-06-13T02:13:03-04:00
Document getPreloadUnitsAnd

- - - - -
bd5810dc by Sylvain Henry at 2020-06-13T02:13:03-04:00
DynFlags: remove useless add_package parameter

- - - - -
36e1daf0 by Sylvain Henry at 2020-06-13T02:13:03-04:00
DynFlags: make listVisibleModuleNames take a UnitState

- - - - -
5226da37 by Sylvain Henry at 2020-06-13T02:13:03-04:00
Refactor and document add_package

- - - - -
4b53aac1 by Sylvain Henry at 2020-06-13T02:13:03-04:00
Refactor and document closeUnitDeps

- - - - -
42c054f6 by Sylvain Henry at 2020-06-13T02:13:03-04:00
DynFlags: findWiredInUnits

- - - - -
a444d01b by Sylvain Henry at 2020-06-13T02:13:03-04:00
DynFlags: reportCycles, reportUnusable

- - - - -
8408d521 by Sylvain Henry at 2020-06-13T02:13:03-04:00
DynFlags: merge_databases

- - - - -
fca2d25f by Sylvain Henry at 2020-06-13T02:13:03-04:00
DynFlags: add UnitConfig datatype

Avoid directly querying flags from DynFlags to build the UnitState.
Instead go via UnitConfig so that we could reuse this to make another
UnitState for plugins.

- - - - -
4274688a by Sylvain Henry at 2020-06-13T02:13:03-04:00
Move distrustAll into mkUnitState

- - - - -
28d804e1 by Sylvain Henry at 2020-06-13T02:13:03-04:00
Create helper upd_wired_in_home_instantiations

- - - - -
ac964c83 by Sylvain Henry at 2020-06-13T02:13:03-04:00
Put database cache in UnitConfig

- - - - -
bfd0a78c by Sylvain Henry at 2020-06-13T02:13:03-04:00
Don't return preload units when we set DyNFlags

Preload units can be retrieved in UnitState when needed (i.e. in GHCi)

- - - - -
1fbb4bf5 by Sylvain Henry at 2020-06-13T02:13:03-04:00
NCGConfig: remove useless ncgUnitId field

- - - - -
c10ff7e7 by Sylvain Henry at 2020-06-13T02:13:03-04:00
Doc: fix some comments

- - - - -
456e17f0 by Sylvain Henry at 2020-06-13T02:13:03-04:00
Bump haddock submodule and allow metric decrease

Metric Decrease:
    T12150
    T12234
    T5837

Metric Increase:
    T16190

- - - - -
42953902 by Simon Peyton Jones at 2020-06-13T02:13:03-04:00
Trim the demand for recursive product types

Ticket #18304 showed that we need to be very careful
when exploring the demand (esp usage demand) on recursive
product types.

This patch solves the problem by trimming the demand on such types --
in effect, a form of "widening".

See the Note [Trimming a demand to a type] in DmdAnal, which explains
how I did this by piggy-backing on an existing mechansim for trimming
demands becuase of GADTs.  The significant payload of this patch is
very small indeed:

* Make GHC.Core.Opt.WorkWrap.Utils.typeShape use RecTcChecker to
  avoid looking through recursive types.

But on the way

* I found that ae_rec_tc was entirely inoperative and did nothing.
  So I removed it altogether from DmdAnal.

* I moved some code around in DmdAnal and Demand.
  (There are no actual changes in dmdFix.)

* I changed the API of DmsAnal.dmdAnalRhsLetDown to return
  a StrictSig rather than a decorated Id

* I removed the dead function peelTsFuns from Demand

Performance effects:

Nofib: 0.0% changes.  Not surprising, because they don't
       use recursive products

Perf tests

T12227:
  1% increase in compiler allocation, becuase $cto gets w/w'd.
  It did not w/w before because it takes a deeply nested
  argument, so the worker gets too many args, so we abandon w/w
  altogether (see GHC.Core.Opt.WorkWrap.Utils.isWorkerSmallEnough)

  With this patch we trim the demands.  That is not strictly
  necessary (since these Generic type constructors are like
  tuples -- they can't cause a loop) but the net result is that
  we now w/w $cto which is fine.

UniqLoop:
  16% decrease in /runtime/ allocation. The UniqSupply is a
  recursive product, so currently we abandon all strictness on
  'churn'.  With this patch 'churn' gets useful strictness, and
  we w/w it.  Hooray

Metric Decrease:
    UniqLoop

Metric Increase:
    T12227

- - - - -
87d504f4 by Viktor Dukhovni at 2020-06-13T02:13:05-04:00
Add introductory prose for Data.Traversable

- - - - -
9f09b608 by Oleg Grenrus at 2020-06-13T02:13:07-04:00
Fix #12073: Add MonadFix Q instance

- - - - -
220c2d34 by Ben Gamari at 2020-06-13T02:13:07-04:00
testsuite: Increase size of T12150

As noted in #18319, this test was previously very fragile. Increase its
size to make it more likely that its fails with its newly-increased
acceptance threshold.

Metric Increase:
    T12150

- - - - -
8bba1c26 by Ben Gamari at 2020-06-13T04:59:06-04:00
gitlab-ci: Always push perf notes

Previously we ci.sh would run with `set -e` implying that we wouldn't
push perf notes if the testsuite were to fail, even if it *only* failed
due to perf notes. This rendered the whole performance testing story
quite fragile as a single regressing commit would cause every successive
commit to fail since a new baseline would not be uploaded.

Fix this by ensuring that we always push performance notes.

- - - - -
7a773f16 by Ben Gamari at 2020-06-13T15:10:55-04:00
gitlab-ci: Eliminate redundant push of CI metrics

- - - - -
a31218f7 by Ryan Scott at 2020-06-13T15:58:37-04:00
Use HsForAllTelescope to avoid inferred, visible foralls

Currently, `HsForAllTy` permits the combination of `ForallVis` and
`Inferred`, but you can't actually typecheck code that uses it
(e.g., `forall {a} ->`). This patch refactors `HsForAllTy` to use a
new `HsForAllTelescope` data type that makes a type-level distinction
between visible and invisible `forall`s such that visible `forall`s
do not track `Specificity`. That part of the patch is actually quite
small; the rest is simply changing consumers of `HsType` to
accommodate this new type.

Fixes #18235. Bumps the `haddock` submodule.

- - - - -
c0e6dee9 by Tamar Christina at 2020-06-14T09:07:44-04:00
winio: Add Atomic Exchange PrimOp and implement Atomic Ptr exchanges.

The initial version was rewritten by Tamar Christina.
It was rewritten in large parts by Andreas Klebinger.

Co-authored-by: Andreas Klebinger <klebinger.andreas at gmx.at>

- - - - -
9a7462fb by Ben Gamari at 2020-06-14T15:35:23-04:00
codeGen: Don't discard live case binders in unsafeEqualityProof logic

Previously CoreToStg would unconditionally discard cases of the form:

    case unsafeEqualityProof of wild { _ -> rhs }

and rather replace the whole thing with `rhs`. However, in some cases
(see #18227) the case binder is still live, resulting in unbound
occurrences in `rhs`. Fix this by only discarding the case if the case
binder is dead.

Fixes #18227.

- - - - -
e4137c48 by Ben Gamari at 2020-06-14T15:35:23-04:00
testsuite: Add tests for #18227

T18227A is the original issue which gave rise to the ticket and depends
upon bytestring. T18227B is a minimized reproducer.

- - - - -
8bab9ff1 by Ben Gamari at 2020-06-14T15:35:59-04:00
hadrian: Fix rts include and library paths

Fixes two bugs:

 * (?) and (<>) associated in a surprising way
 * We neglected to include libdw paths in the rts configure flags

- - - - -
bd761185 by Ben Gamari at 2020-06-14T15:35:59-04:00
hadrian: Drop redundant GHC arguments

Cabal should already be passing this arguments to GHC.

- - - - -
01f7052c by Peter Trommler at 2020-06-14T15:36:38-04:00
FFI: Fix pass small ints in foreign call wrappers

The Haskell calling convention requires integer parameters smaller
than wordsize to be promoted to wordsize (where the upper bits are
don't care). To access such small integer parameter read a word from
the parameter array and then cast that word to the small integer
target type.

Fixes #15933

- - - - -
502647f7 by Krzysztof Gogolewski at 2020-06-14T15:37:14-04:00
Fix "ndecreasingIndentation" in manual (#18116)

- - - - -
9a9cc089 by Simon Jakobi at 2020-06-15T13:10:00-04:00
Use foldl' in unionManyUniqDSets

- - - - -
761dcb84 by Moritz Angermann at 2020-06-15T13:10:36-04:00
Load .lo as well.

Some archives contain so called linker objects, with the affectionate
.lo suffic.  For example the musl libc.a will come in that form.  We
still want to load those objects, hence we should not discard them and
look for .lo as well.  Ultimately we might want to fix this proerly by
looking at the file magic.

- - - - -
cf01477f by Vladislav Zavialov at 2020-06-15T13:11:20-04:00
User's Guide: KnownNat evidence is Natural

This bit of documentation got outdated after commit
1fcede43d2b30f33b7505e25eb6b1f321be0407f

- - - - -
d0dcbfe6 by Jan Hrček at 2020-06-16T20:36:38+02:00
Fix typos and formatting in user guide

- - - - -
56a9e95f by Jan Hrček at 2020-06-16T20:36:38+02:00
Resolve TODO

- - - - -
3e884d14 by Jan Hrček at 2020-06-16T20:36:38+02:00
Rename TcHoleErrors to GHC.Tc.Errors.Hole

- - - - -
d23fc678 by Stefan Schulze Frielinghaus at 2020-06-17T15:31:09-04:00
hadrian: Build with threaded runtime if available

See #16873.

- - - - -
0639dc10 by Sylvain Henry at 2020-06-17T15:31:53-04:00
T16190: only measure bytes_allocated

Just adding `{-# LANGUAGE BangPatterns #-}` makes the two other metrics
fluctuate by 13%.

- - - - -
4cab6897 by Adam Sandberg Ericsson at 2020-06-17T15:32:44-04:00
docs: fix formatting in users guide

- - - - -
eb8115a8 by Sylvain Henry at 2020-06-17T15:33:23-04:00
Move CLabel assertions into smart constructors (#17957)

It avoids using DynFlags in the Outputable instance of Clabel to check
assertions at pretty-printing time.

- - - - -
7faa4509 by Ben Gamari at 2020-06-17T15:43:31-04:00
base: Bump to 4.15.0.0

- - - - -
20616959 by Ben Gamari at 2020-06-17T15:43:31-04:00
configure: Use grep -q instead of --quiet

The latter is apparently not supported by busybox.

- - - - -
40fa237e by Krzysztof Gogolewski at 2020-06-17T16:21:58-04:00
Linear types (#15981)

This is the first step towards implementation of the linear types proposal
(https://github.com/ghc-proposals/ghc-proposals/pull/111).

It features

* A language extension -XLinearTypes
* Syntax for linear functions in the surface language
* Linearity checking in Core Lint, enabled with -dlinear-core-lint
* Core-to-core passes are mostly compatible with linearity
* Fields in a data type can be linear or unrestricted; linear fields
  have multiplicity-polymorphic constructors.
  If -XLinearTypes is disabled, the GADT syntax defaults to linear fields

The following items are not yet supported:

* a # m -> b syntax (only prefix FUN is supported for now)
* Full multiplicity inference (multiplicities are really only checked)
* Decent linearity error messages
* Linear let, where, and case expressions in the surface language
  (each of these currently introduce the unrestricted variant)
* Multiplicity-parametric fields
* Syntax for annotating lambda-bound or let-bound with a multiplicity
* Syntax for non-linear/multiple-field-multiplicity records
* Linear projections for records with a single linear field
* Linear pattern synonyms
* Multiplicity coercions (test LinearPolyType)

A high-level description can be found at
https://ghc.haskell.org/trac/ghc/wiki/LinearTypes/Implementation
Following the link above you will find a description of the changes made to Core.
This commit has been authored by

* Richard Eisenberg
* Krzysztof Gogolewski
* Matthew Pickering
* Arnaud Spiwack

With contributions from:

* Mark Barbone
* Alexander Vershilov

Updates haddock submodule.

- - - - -
6cb84c46 by Krzysztof Gogolewski at 2020-06-17T16:22:03-04:00
Various performance improvements

This implements several general performance improvements to GHC,
to offset the effect of the linear types change.

General optimisations:
- Add a `coreFullView` function which iterates `coreView` on the
  head. This avoids making function recursive solely because the
  iterate `coreView` themselves. As a consequence, this functions can
  be inlined, and trigger case-of-known constructor (_e.g._
  `kindRep_maybe`, `isLiftedRuntimeRep`, `isMultiplicityTy`,
  `getTyVar_maybe`, `splitAppTy_maybe`, `splitFunType_maybe`,
  `tyConAppTyCon_maybe`). The common pattern about all these functions
  is that they are almost always used as views, and immediately
  consumed by a case expression. This commit also mark them asx `INLINE`.
- In `subst_ty` add a special case for nullary `TyConApp`, which avoid
  allocations altogether.
- Use `mkTyConApp` in `subst_ty` for the general `TyConApp`. This
  required quite a bit of module shuffling.
  case. `myTyConApp` enforces crucial sharing, which was lost during
  substitution. See also !2952 .
- Make `subst_ty` stricter.
- In `eqType` (specifically, in `nonDetCmpType`), add a special case,
  tested first, for the very common case of nullary `TyConApp`.
  `nonDetCmpType` has been made `INLINE` otherwise it is actually a
  regression. This is similar to the optimisations in !2952.

Linear-type specific optimisations:
- Use `tyConAppTyCon_maybe` instead of the more complex `eqType` in
  the definition of the pattern synonyms `One` and `Many`.
- Break the `hs-boot` cycles between `Multiplicity.hs` and `Type.hs`:
  `Multiplicity` now import `Type` normally, rather than from the
  `hs-boot`. This way `tyConAppTyCon_maybe` can inline properly in the
  `One` and `Many` pattern synonyms.
- Make `updateIdTypeAndMult` strict in its type and multiplicity
- The `scaleIdBy` gets a specialised definition rather than being an
  alias to `scaleVarBy`
- `splitFunTy_maybe` is given the type `Type -> Maybe (Mult, Type,
  Type)` instead of `Type -> Maybe (Scaled Type, Type)`
- Remove the `MultMul` pattern synonym in favour of a view `isMultMul`
  because pattern synonyms appear not to inline well.
- in `eqType`, in a `FunTy`, compare multiplicities last: they are
  almost always both `Many`, so it helps failing faster.
- Cache `manyDataConTy` in `mkTyConApp`, to make sure that all the
  instances of `TyConApp ManyDataConTy []` are physically the same.

This commit has been authored by
* Richard Eisenberg
* Krzysztof Gogolewski
* Arnaud Spiwack

Metric Decrease:
    haddock.base
    T12227
    T12545
    T12990
    T1969
    T3064
    T5030
    T9872b

Metric Increase:
    haddock.base
    haddock.Cabal
    haddock.compiler
    T12150
    T12234
    T12425
    T12707
    T13035
    T13056
    T15164
    T16190
    T18304
    T1969
    T3064
    T3294
    T5631
    T5642
    T5837
    T6048
    T9020
    T9233
    T9675
    T9872a
    T9961
    WWRec

- - - - -
57db91d8 by Sylvain Henry at 2020-06-17T16:22:03-04:00
Remove integer-simple

integer-simple uses lists of words (`[Word]`) to represent big numbers
instead of ByteArray#:

   * it is less efficient than the newer ghc-bignum native backend

   * it isn't compatible with the big number representation that is now
     shared by all the ghc-bignum backends (based on the one that was
     used only in integer-gmp before).

As a consequence, we simply drop integer-simple

- - - - -
9f96bc12 by Sylvain Henry at 2020-06-17T16:22:03-04:00
ghc-bignum library

ghc-bignum is a newer package that aims to replace the legacy
integer-simple and integer-gmp packages.

* it supports several backends. In particular GMP is still supported and
  most of the code from integer-gmp has been merged in the "gmp"
  backend.

* the pure Haskell "native" backend is new and is much faster than the
  previous pure Haskell implementation provided by integer-simple

* new backends are easier to write because they only have to provide a
  few well defined functions. All the other code is common to all
  backends. In particular they all share the efficient small/big number
  distinction previously used only in integer-gmp.

* backends can all be tested against the "native" backend with a simple
  Cabal flag. Backends are only allowed to differ in performance, their
  results should be the same.

* Add `integer-gmp` compat package: provide some pattern synonyms and
  function aliases for those in `ghc-bignum`. It is intended to avoid
  breaking packages that depend on `integer-gmp` internals.

Update submodules: text, bytestring

Metric Decrease:
    Conversions
    ManyAlternatives
    ManyConstructors
    Naperian
    T10359
    T10547
    T10678
    T12150
    T12227
    T12234
    T12425
    T13035
    T13719
    T14936
    T1969
    T4801
    T4830
    T5237
    T5549
    T5837
    T8766
    T9020
    parsing001
    space_leak_001
    T16190
    haddock.base

On ARM and i386, T17499 regresses (+6% > 5%).
On x86_64 unregistered, T13701 sometimes regresses (+2.2% > 2%).

Metric Increase:
    T17499
    T13701

- - - - -
96aa5787 by Sylvain Henry at 2020-06-17T16:22:03-04:00
Update compiler

Thanks to ghc-bignum, the compiler can be simplified:

* Types and constructors of Integer and Natural can be wired-in. It
  means that we don't have to query them from interfaces. It also means
  that numeric literals don't have to carry their type with them.

* The same code is used whatever ghc-bignum backend is enabled. In
  particular, conversion of bignum literals into final Core expressions
  is now much more straightforward. Bignum closure inspection too.

* GHC itself doesn't depend on any integer-* package anymore

* The `integerLibrary` setting is gone.

- - - - -
0f67e344 by Sylvain Henry at 2020-06-17T16:22:03-04:00
Update `base` package

* GHC.Natural isn't implemented in `base` anymore. It is provided by
  ghc-bignum in GHC.Num.Natural. It means that we can safely use Natural
  primitives in `base` without fearing issues with built-in rewrite
  rules (cf #15286)

* `base` doesn't conditionally depend on an integer-* package anymore,
  it depends on ghc-bignum

* Some duplicated code in integer-* can now be factored in GHC.Float

* ghc-bignum tries to use a uniform naming convention so most of the
  other changes are renaming

- - - - -
aa9e7b71 by Sylvain Henry at 2020-06-17T16:22:03-04:00
Update `make` based build system

* replace integer-* package selection with ghc-bignum backend selection

- - - - -
f817d816 by Sylvain Henry at 2020-06-17T16:22:04-04:00
Update testsuite

* support detection of slow ghc-bignum backend (to replace the detection
  of integer-simple use). There are still some test cases that the
  native backend doesn't handle efficiently enough.

* remove tests for GMP only functions that have been removed from
  ghc-bignum

* fix test results showing dependent packages (e.g. integer-gmp) or
  showing suggested instances

* fix test using Integer/Natural API or showing internal names

- - - - -
dceecb09 by Sylvain Henry at 2020-06-17T16:22:04-04:00
Update Hadrian

* support ghc-bignum backend selection in flavours and command-line

* support ghc-bignum "--check" flag (compare results of selected backend
  against results of the native one) in flavours and command-line (e.g.
  pass --bignum=check-gmp" to check the "gmp" backend)

* remove the hack to workaround #15286

* build GMP only when the gmp backend is used

* remove hacks to workaround `text` package flags about integer-*. We
  fix `text` to use ghc-bignum unconditionally in another patch

- - - - -
fa4281d6 by Sylvain Henry at 2020-06-17T16:22:04-04:00
Bump bytestring and text submodules

- - - - -
1a3f6f34 by Adam Sandberg Ericsson at 2020-06-18T23:03:36-04:00
docs: mention -hiedir in docs for -outputdir

[skip ci]

- - - - -
729bcb02 by Sylvain Henry at 2020-06-18T23:04:17-04:00
Hadrian: fix build on Mac OS Catalina (#17798)

- - - - -
95e18292 by Andreas Klebinger at 2020-06-18T23:04:58-04:00
Relax allocation threshold for T12150.

This test performs little work, so the most minor allocation
changes often cause the test to fail.

Increasing the threshold to 2% should help with this.

- - - - -
8ce6c393 by Sebastian Graf at 2020-06-18T23:05:36-04:00
hadrian: Bump pinned cabal.project to an existent index-state

- - - - -
08c1cb0f by Ömer Sinan Ağacan at 2020-06-18T23:06:21-04:00
Fix uninitialized field read in Linker.c

Valgrind report of the bug when running the test `linker_unload`:

    ==29666== Conditional jump or move depends on uninitialised value(s)
    ==29666==    at 0x369C5B4: setOcInitialStatus (Linker.c:1305)
    ==29666==    by 0x369C6C5: mkOc (Linker.c:1347)
    ==29666==    by 0x36C027A: loadArchive_ (LoadArchive.c:522)
    ==29666==    by 0x36C0600: loadArchive (LoadArchive.c:626)
    ==29666==    by 0x2C144CD: ??? (in /home/omer/haskell/ghc_2/testsuite/tests/rts/linker/linker_unload.run/linker_unload)
    ==29666==
    ==29666== Conditional jump or move depends on uninitialised value(s)
    ==29666==    at 0x369C5B4: setOcInitialStatus (Linker.c:1305)
    ==29666==    by 0x369C6C5: mkOc (Linker.c:1347)
    ==29666==    by 0x369C9F6: preloadObjectFile (Linker.c:1507)
    ==29666==    by 0x369CA8D: loadObj_ (Linker.c:1536)
    ==29666==    by 0x369CB17: loadObj (Linker.c:1557)
    ==29666==    by 0x3866BC: main (linker_unload.c:33)

The problem is `mkOc` allocates a new `ObjectCode` and calls
`setOcInitialStatus` without initializing the `status` field.
`setOcInitialStatus` reads the field as first thing:

    static void setOcInitialStatus(ObjectCode* oc) {
        if (oc->status == OBJECT_DONT_RESOLVE)
          return;

        if (oc->archiveMemberName == NULL) {
            oc->status = OBJECT_NEEDED;
        } else {
            oc->status = OBJECT_LOADED;
        }
    }

`setOcInitialStatus` is unsed in two places for two different purposes:
in `mkOc` where we don't have the `status` field initialized yet (`mkOc`
is supposed to initialize it), and `loadOc` where we do have `status`
field initialized and we want to update it. Instead of splitting the
function into two functions which are both called just once I inline the
functions in the use sites and remove it.

Fixes #18342

- - - - -
da18ff99 by Tamar Christina at 2020-06-18T23:07:03-04:00
fix windows bootstrap due to linker changes

- - - - -
2af0ec90 by Sylvain Henry at 2020-06-18T23:07:47-04:00
DynFlags: store default depth in SDocContext (#17957)

It avoids having to use DynFlags to reach for pprUserLength.

- - - - -
d4a0be75 by Sylvain Henry at 2020-06-18T23:08:35-04:00
Move tablesNextToCode field into Platform

tablesNextToCode is a platform setting and doesn't belong into DynFlags
(#17957). Doing this is also a prerequisite to fix #14335 where we deal
with two platforms (target and host) that may have different platform
settings.

- - - - -
788e0f38 by Ben Gamari at 2020-06-23T18:42:59-04:00
rts: Clear bd->free in the DEBUG RTS

In the non-DEBUG RTS we initialize `bd->free` lazily (e.g. when
the mutator starts allocating into the block in stg_gc_noregs).
However, in the past we have had bugs where code looked at
the `free` field of blocks that the mutator never allocated into.
We set the free pointer to NULL to catch this.

This would help to catch #16862.

- - - - -


18 changed files:

- .ghcid
- + .git-ignore-revs
- .gitlab-ci.yml
- + .gitlab/ci.sh
- − .gitlab/darwin-init.sh
- .gitlab/linters/check-cpp.py
- .gitlab/merge_request_templates/merge-request.md
- − .gitlab/prepare-system.sh
- − .gitlab/push-test-metrics.sh
- + .gitlab/test-metrics.sh
- − .gitlab/win32-init.sh
- .gitmodules
- CODEOWNERS
- HACKING.md
- aclocal.m4
- boot
- + compiler/GHC.hs
- + compiler/GHC/Builtin/Names.hs


The diff was not included because it is too large.


View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ef0b2280c98618f625914b867bce037c4c814cad...788e0f38d8e2dacd808052c321371d6d67098f5f

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ef0b2280c98618f625914b867bce037c4c814cad...788e0f38d8e2dacd808052c321371d6d67098f5f
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/20200623/44524312/attachment-0001.html>


More information about the ghc-commits mailing list