[Git][ghc/ghc][wip/zap-coercions] 1325 commits: rts: Correct handling of LARGE ARR_WORDS in LDV profiler

Ben Gamari gitlab at gitlab.haskell.org
Fri Mar 27 15:17:50 UTC 2020



Ben Gamari pushed to branch wip/zap-coercions at Glasgow Haskell Compiler / GHC


Commits:
a586b33f by Matthew Pickering at 2019-06-27T10:42:29-04:00
rts: Correct handling of LARGE ARR_WORDS in LDV profiler

This implements the correct fix for #11627 by skipping over the slop
(which is zeroed) rather than adding special case logic for LARGE
ARR_WORDS which runs the risk of not performing a correct census by
ignoring any subsequent blocks.

This approach implements similar logic to that in Sanity.c

- - - - -
ed4cbd93 by Matthew Pickering at 2019-06-27T10:42:29-04:00
rts: Correct assertion in LDV_recordDead

It is possible that void_total is exactly equal to not_used and the
other assertions for this check for <= rather than <.

- - - - -
07cffc49 by Matthew Pickering at 2019-06-27T10:42:29-04:00
rts: Do not traverse nursery for dead closures in LDV profile

It is important that `heapCensus` and `LdvCensusForDead` traverse the
same areas.

`heapCensus` increases the `not_used` counter which tracks how many
closures are live but haven't been used yet.

`LdvCensusForDead` increases the `void_total` counter which tracks how
many dead closures there are.

The `LAG` is then calculated by substracting the `void_total` from
`not_used` and so it is essential that `not_used >= void_total`. This
fact is checked by quite a few assertions.

However, if a program has low maximum residency but allocates a lot in
the nursery then these assertions were failing (see #16753 and #15903)
because `LdvCensusForDead` was observing dead closures from the nursery
which totalled more than the `not_used`. The same closures were not
counted by `heapCensus`.

Therefore, it seems that the correct fix is to make `LdvCensusForDead`
agree with `heapCensus` and not traverse the nursery for dead closures.

Fixes #16100 #16753 #15903 #8982

- - - - -
c1f67887 by Roland Senn at 2019-06-27T10:43:10-04:00
Improve doc for :type-at. (#14780)

- - - - -
52f10216 by Roland Zumkeller at 2019-06-27T10:43:47-04:00
configure: prefer cc over gcc

Fixes #16857.

- - - - -
90e0ab7d by Sylvain Henry at 2019-06-27T10:44:25-04:00
Fix Happy deps for Stack (#16825)

- - - - -
d35cec7a by Fraser Tweedale at 2019-06-27T10:45:01-04:00
getExecutablePath: get path from sysctl on FreeBSD

- - - - -
2a68b8b7 by nineonine at 2019-06-27T10:45:39-04:00
Fix #16805 by formatting warning message

- - - - -
217258d0 by Ben Gamari at 2019-06-27T10:46:18-04:00
testsuite: Add more type annotations to perf_notes

- - - - -
4ec233ec by Sylvain Henry at 2019-06-27T23:58:37-04:00
Fix GCC warnings with __clear_cache builtin (#16867)

- - - - -
ef6d9a50 by Artem Pelenitsyn at 2019-06-27T23:59:15-04:00
typo in the docs for DynFlags.hs
- - - - -
11bac115 by Travis Whitaker at 2019-06-28T15:25:05-04:00
Correct closure observation, construction, and mutation on weak memory machines.

Here the following changes are introduced:
    - A read barrier machine op is added to Cmm.
    - The order in which a closure's fields are read and written is changed.
    - Memory barriers are added to RTS code to ensure correctness on
      out-or-order machines with weak memory ordering.

Cmm has a new CallishMachOp called MO_ReadBarrier. On weak memory machines, this
is lowered to an instruction that ensures memory reads that occur after said
instruction in program order are not performed before reads coming before said
instruction in program order. On machines with strong memory ordering properties
(e.g. X86, SPARC in TSO mode) no such instruction is necessary, so
MO_ReadBarrier is simply erased. However, such an instruction is necessary on
weakly ordered machines, e.g. ARM and PowerPC.

Weam memory ordering has consequences for how closures are observed and mutated.
For example, consider a closure that needs to be updated to an indirection. In
order for the indirection to be safe for concurrent observers to enter, said
observers must read the indirection's info table before they read the
indirectee. Furthermore, the entering observer makes assumptions about the
closure based on its info table contents, e.g. an INFO_TYPE of IND imples the
closure has an indirectee pointer that is safe to follow.

When a closure is updated with an indirection, both its info table and its
indirectee must be written. With weak memory ordering, these two writes can be
arbitrarily reordered, and perhaps even interleaved with other threads' reads
and writes (in the absence of memory barrier instructions). Consider this
example of a bad reordering:

- An updater writes to a closure's info table (INFO_TYPE is now IND).
- A concurrent observer branches upon reading the closure's INFO_TYPE as IND.
- A concurrent observer reads the closure's indirectee and enters it. (!!!)
- An updater writes the closure's indirectee.

Here the update to the indirectee comes too late and the concurrent observer has
jumped off into the abyss. Speculative execution can also cause us issues,
consider:

- An observer is about to case on a value in closure's info table.
- The observer speculatively reads one or more of closure's fields.
- An updater writes to closure's info table.
- The observer takes a branch based on the new info table value, but with the
  old closure fields!
- The updater writes to the closure's other fields, but its too late.

Because of these effects, reads and writes to a closure's info table must be
ordered carefully with respect to reads and writes to the closure's other
fields, and memory barriers must be placed to ensure that reads and writes occur
in program order. Specifically, updates to a closure must follow the following
pattern:

- Update the closure's (non-info table) fields.
- Write barrier.
- Update the closure's info table.

Observing a closure's fields must follow the following pattern:

- Read the closure's info pointer.
- Read barrier.
- Read the closure's (non-info table) fields.

This patch updates RTS code to obey this pattern. This should fix long-standing
SMP bugs on ARM (specifically newer aarch64 microarchitectures supporting
out-of-order execution) and PowerPC. This fixes issue #15449.

Co-Authored-By: Ben Gamari <ben at well-typed.com>

- - - - -
bd660ede by Ben Gamari at 2019-06-28T15:25:30-04:00
rts: Assert that LDV profiling isn't used with parallel GC

I'm not entirely sure we are careful about ensuring this; this is a
last-ditch check.

- - - - -
82693938 by Moritz Angermann at 2019-07-02T16:18:05-04:00
Add _GLOBAL_OFFSET_TABLE_ support

This adds lookup logic for _GLOBAL_OFFSET_TABLE_ as well as
relocation logic for R_ARM_BASE_PREL and R_ARM_GOT_BREL which
the gnu toolchain (gas, gcc, ...) prefers to produce.  Apparently
recent llvm toolchains will produce those as well.

- - - - -
348e3f8e by Edward Amsden at 2019-07-02T16:18:05-04:00
Lookup _GLOBAL_OFFSET_TABLE by symbol->addr when doing relocations

- - - - -
e9abcad4 by Moritz Angermann at 2019-07-02T16:18:05-04:00
No atomics on arm32; this will just yield stubs.

As such the internal linker will fail for them.  The alternative
would be to implement them as stubs in the linker and have them
barf when called.

> Not all operations are supported by all target processors. If a
  particular operation cannot be implemented on the target processor,
  a warning is generated and a call an external function is
  generated. The external function carries the same name as the
  built-in version, with an additional suffix ‘_n’ where n is the size
  of the data type.

(https://gcc.gnu.org/onlinedocs/gcc/_005f_005fsync-Builtins.html)

- - - - -
023a2bc7 by Ben Gamari at 2019-07-02T16:18:05-04:00
Apply suggestion to rts/linker/elf_got.c
- - - - -
0bed9647 by Ben Gamari at 2019-07-02T16:18:05-04:00
Apply suggestion to rts/linker/Elf.c
- - - - -
cef80c0b by nineonine at 2019-07-02T16:18:44-04:00
Fix #15843 by extending Template Haskell AST for tuples to support sections

- - - - -
294b55dc by Eric Wolf at 2019-07-02T16:19:21-04:00
Add test for #16575

just use the test to show the defective behaviour, so we can see
the difference, when it gets fixed

- - - - -
60b9eab9 by Ömer Sinan Ağacan at 2019-07-02T16:19:59-04:00
Fix stage 1 warnings

- - - - -
df3e5b74 by David Eichmann at 2019-07-02T16:20:36-04:00
Hadrian: disable cloud build cache for symlinks #16800

This is a temporary workaround shake not supporting symlinks
when using cloud/cached builds.

- - - - -
acd79558 by Abhiroop Sarkar at 2019-07-03T09:33:39-04:00
Add support for SIMD operations in the NCG

This adds support for constructing vector types from Float#, Double# etc
and performing arithmetic operations on them

Cleaned-Up-By: Ben Gamari <ben at well-typed.com>

- - - - -
973c61b5 by Ben Gamari at 2019-07-03T09:34:16-04:00
gitlab-ci: Fix doc-tarball job

Previously we used the deb9-debug job which used the `validate` build
flavour which disabled `BUILD_SPHINX_PDF`. Fix this.

Fixes #16890.

- - - - -
a25f6f55 by Ryan Scott at 2019-07-03T09:34:54-04:00
Bump template-haskell version to 2.16.0.0

Commit cef80c0b9edca3d21b5c762f51dfbab4c5857d8a debuted a breaking
change to `template-haskell`, so in order to guard against it
properly with CPP, we need to bump the `template-haskell` version
number accordingly.

- - - - -
f7a2e709 by Ben Gamari at 2019-07-04T15:29:49-04:00
Bump parsec submodule to 3.1.14.0

- - - - -
d7f7e1ed by Siddharth Bhat at 2019-07-04T21:22:00-04:00
Make printer untag when chasing a pointer in a RET_FUN frame

This is to mimic what `Scav.c` does. This should fix a crash in
the printer.

- - - - -
675d27fc by Ben Gamari at 2019-07-04T21:22:35-04:00
gitlab: Reduce size of template headings

- - - - -
679427f8 by Vladislav Zavialov at 2019-07-04T21:23:10-04:00
Produce all DerivInfo in tcTyAndClassDecls

Before this refactoring:

* DerivInfo for data family instances was returned from tcTyAndClassDecls
* DerivInfo for data declarations was generated with mkDerivInfos and added at a
  later stage of the pipeline in tcInstDeclsDeriv

After this refactoring:

* DerivInfo for both data family instances and data declarations is returned from
  tcTyAndClassDecls in a single list.

This uniform treatment results in a more convenient arrangement to fix #16731.

- - - - -
53aa59f3 by Simon Peyton Jones at 2019-07-04T21:23:49-04:00
Add a missing zonk (fixes #16902)

In the eager unifier, when unifying (tv1 ~ tv2),
when we decide to swap them over, to unify (tv2 ~ tv1),
I'd forgotten to ensure that tv1's kind was fully zonked,
which is an invariant of uUnfilledTyVar2.

That could lead us to build an infinite kind, or (in the
case of #16902) update the same unification variable twice.

Yikes.

Now we get an error message rather than non-termination,
which is much better.  The error message is not great,
but it's a very strange program, and I can't see an easy way
to improve it, so for now I'm just committing this fix.

Here's the decl
 data F (a :: k) :: (a ~~ k) => Type where
    MkF :: F a

and the rather error message of which I am not proud

  T16902.hs:11:10: error:
    • Expected a type, but found something with kind ‘a1’
    • In the type ‘F a’

- - - - -
ed662901 by Daniel Gröber at 2019-07-04T21:24:26-04:00
rts: Fix -hT option with profiling rts

In dumpCensus we switch/case on doHeapProfile twice. The second switch
tries to barf on unknown doHeapProfile modes but HEAP_BY_CLOSURE_TYPE is
checked by the first switch and not included in the second.

So when trying to pass -hT to the profiling rts it barfs.

This commit simply merges the two switches into one which fixes this
problem.

- - - - -
80afdf6b by Simon Peyton Jones at 2019-07-04T21:25:05-04:00
Fix over-eager implication constraint discard

Ticket #16247 showed that we were discarding an implication
constraint that had empty ic_wanted, when we still needed to
keep it so we could check whether it had a bad telescope.

Happily it's a one line fix.  All the rest is comments!

- - - - -
f002250a by Andreas Klebinger at 2019-07-04T21:25:43-04:00
Dont gather ticks when only striping them in STG.

Adds stripStgTicksTopE which only returns the stripped expression.
So far we also allocated a list for the stripped ticks which was
never used.

Allocation difference is as expected very small but present.
About 0.02% difference when compiling with -O.

- - - - -
a76b233d by Artem Pelenitsyn at 2019-07-05T07:06:55-04:00
Make all submodules have absolute URLs

The relative URLs were a workaround to let most contributors fork from
Github due to a weakness in the haskell.org server.

This workaround is no longer needed. And relative submodule URLs are
an impediment to forking which makes contributions harder than they
should be.

The URLs are chosen to clone from https, because this makes sure that
anybody, even not a registered Gitlab user, can clone a fork
recursively.

- - - - -
62b82135 by Ryan Scott at 2019-07-05T07:07:38-04:00
More sensible SrcSpans for recursive pattern synonym errors (#16900)

Attach the `SrcSpan` of the first pattern synonym binding involved in
the recursive group when throwing the corresponding error message,
similarly to how it is done for type synonyms.

Fixes #16900.

- - - - -
2fd1ed54 by nineonine at 2019-07-05T07:08:17-04:00
Fix #16895 by checking whether infix expression operator is a variable

- - - - -
03f5adcd by David Eichmann at 2019-07-08T07:07:10-04:00
Bump Shake and copy instead of hard link from cloud cache

This is important as in hard link mode shake  makes all such files
read only to avoid accidentally modifying cache files via the
hard link. It turns out, many Hadrian rules attempt read access
to such files and hence fail in the hard link mode. These
rules could be refactored to avoid write access, but using
copy instead of hard link a much simpler solution.

- - - - -
5af815f2 by Kevin Buhr at 2019-07-08T07:07:11-04:00
Add test for old issue w/ bad source locations for warnings in .lhs files (#515)

- - - - -
6a03d77b by Ryan Scott at 2019-07-09T11:52:45-04:00
Use an empty data type in TTG extension constructors (#15247)

To avoid having to `panic` any time a TTG extension constructor is
consumed, this MR introduces an uninhabited 'NoExtCon' type and uses
that in every extension constructor's type family instance where it
is appropriate. This also introduces a 'noExtCon' function which
eliminates a 'NoExtCon', much like 'Data.Void.absurd' eliminates
a 'Void'.

I also renamed the existing `NoExt` type to `NoExtField` to better
distinguish it from `NoExtCon`. Unsurprisingly, there is a lot of
code churn resulting from this.

Bumps the Haddock submodule. Fixes #15247.

- - - - -
b05c8423 by Phuong Trinh at 2019-07-09T22:55:41-04:00
Fix #16511: changes in interface dependencies should trigger recompilation

If the union of dependencies of imported modules change, the `mi_deps`
field of the interface files should change as well. Because of that, we
need to check for changes in this in recompilation checker which we are
not doing right now. This adds a checks for that.

- - - - -
fb43bddc by John Ericson at 2019-07-09T22:56:18-04:00
Fix two more `#ifndef` for the linter

- - - - -
0472f0f6 by John Ericson at 2019-07-09T22:56:18-04:00
Remove most uses of TARGET platform macros

These prevent multi-target builds. They were gotten rid of in 3 ways:

1. In the compiler itself, replacing `#if` with runtime `if`. In these
cases, we care about the target platform still, but the target platform
is dynamic so we must delay the elimination to run time.

2. In the compiler itself, replacing `TARGET` with `HOST`. There was
just one bit of this, in some code splitting strings representing lists
of paths. These paths are used by GHC itself, and not by the compiled
binary. (They are compiler lookup paths, rather than RPATHS or something
that does matter to the compiled binary, and thus would legitamentally
be target-sensative.) As such, the path-splitting method only depends on
where GHC runs and not where code it produces runs. This should have
been `HOST` all along.

3. Changing the RTS. The RTS doesn't care about the target platform,
full stop.

4. `includes/stg/HaskellMachRegs.h` This file is also included in the
genapply executable. This is tricky because the RTS's host platform
really is that utility's target platform. so that utility really really
isn't multi-target either. But at least it isn't an installed part of
GHC, but just a one-off tool when building the RTS. Lying with the
`HOST` to a one-off program (genapply) that isn't installed doesn't seem so bad.
It's certainly better than the other way around of lying to the RTS
though not to genapply. The RTS is more important, and it is installed,
*and* this header is installed as part of the RTS.

- - - - -
24782b89 by John Ericson at 2019-07-09T22:56:18-04:00
Deduplicate "unique subdir" code between GHC and Cabal

The code, including the generated module with the version, is now in
ghc-boot. Config.hs reexports stuff as needed, ghc-pkg doesn't need any
tricks at all.

- - - - -
42ff8653 by Ben Gamari at 2019-07-09T22:56:53-04:00
testsuite: Fix #16818

Renames performance metrics to include whether they are compile-time or
runtime metrics.

- - - - -
18ac9ad4 by Alp Mestanogullari at 2019-07-09T22:57:31-04:00
Hadrian: implement key-value settings for builder options

They take the general form `foo.bar.baz [+]= some values`, where
`=` completely overrides the arguments for a builder and `+=` extends
them. We currenly only support settings for updating the GHC and C
compiler options, of the form:

```
  {stage0, ..., stage3 or *}.{package name or *}
                            .ghc.{c, hs, link, deps, toolargs or *}.opts

  {stage0, ..., stage3 or *}.{package name or *}
                            .cc.{c, deps or *}.opts
```

The supported settings and their use is covered in the new section
of `hadrian/doc/user-settings.md`, while the implementation is explained
in a new Note [Hadrian settings].

Most of the logic is implemented in a new module, `Settings.Parser`, which
contains key-value assignment/extension parsers as well as utilities for
specifying allowed settings at a high-level, generating a `Predicate` from
such a description or generating the list of possible completions for a given
string.

The additions to the `Settings` module make use of this to describe the
settings that Hadrian currently supports, and apply all such
key-value settings (from the command line and `<root>/hadrian.settings`)
to the flavour that Hadrian is going to proceed with.

This new setting system comes with support for generating Bash completions,
implemented in `hadrian/completion.sh` and Hadrian's `autocomplete` target:

> source hadrian/completion.sh
> hadrian/build.sh stage1.base.ghc.<TAB>
stage1.base.ghc.c.opts     stage1.base.ghc.hs.opts
stage1.base.ghc.*.opts     stage1.base.ghc.deps.opts
stage1.base.ghc.link.opts  stage1.base.ghc.toolargs.opts

- - - - -
7f8bf98e by Alp Mestanogullari at 2019-07-09T22:58:09-04:00
Hadrian: fix source-dist rule

The first problem was that the list of files/dirs to embed or ignore was not
up-to-date. The second problem was that the 'Cwd' option used when running the
Tar builder in the source-dist rule didn't actually change the current directory
and was therefore failing. Finally, the source-dist rule did not pre-generate
Haskell modules derived from .x (alex) and .y (happy) files, like the Make
build system does -- this is now fixed.

We might be doing too much work for that last step (we seem to be building
many things until we get to generating the source distribution), but extracting
the distribution and running

    ./configure && hadrian/build.sh --flavour=quickest -j

from there does work for me now.

- - - - -
d7423f10 by Ömer Sinan Ağacan at 2019-07-09T22:58:48-04:00
Testsuite tweaks and refactoring

- Rename requires_th to req_th for consistency with other req functions
  (e.g. req_interp, req_profiling etc.)

- req_th (previously requires_th) now checks for interpreter (via
  req_interp). With this running TH tests are skipped when running the
  test suite with stage=1.

- Test tweaks:
    - T9360a, T9360b: Use req_interp
    - recomp009, T13938, RAE_T32a: Use req_th

- Fix check-makefiles linter: it now looks for Makefiles instead of .T
  files (which are actually Python files)

- - - - -
897a59a5 by Ömer Sinan Ağacan at 2019-07-09T22:59:26-04:00
Minor refactoring in CoreSimpl

When `join_ids` is empty `extendVarSetList existing_joins join_ids` is
already no-op, so no need to check whether `join_ids` is empty or not
before extending the joins set.

- - - - -
85da17e5 by Eric Wolf at 2019-07-09T23:00:03-04:00
Add testcase T16804 for #16804

slightly larger testcase for :type-at and :uses
so we can see changes, if #16804 is done.

- - - - -
8fcc931c by Eric Wolf at 2019-07-09T23:00:03-04:00
T16804: adjust src spans

- - - - -
a35e0916 by Ben Gamari at 2019-07-09T23:00:42-04:00
hadrian/doc: Add some discussion of compilation stages

This documents some of the lore surrounding the nature and naming of
GHC's stage numbers.

- - - - -
d2e290d3 by Simon Peyton Jones at 2019-07-09T23:01:24-04:00
Fix erroneous float in CoreOpt

The simple optimiser was making an invalid transformation
to join points -- yikes.  The fix is easy.

I also added some documentation about the fact that GHC uses
a slightly more restrictive version of join points than does
the paper.

Fix #16918

- - - - -
cb5271ac by Kevin Buhr at 2019-07-11T17:46:19-04:00
Add regression test for old panic on inlining undeclared identifier (#495)

- - - - -
01ec8549 by Andreas Klebinger at 2019-07-11T17:46:57-04:00
Special case a few common patterns in unionLists.

In particular we very often pass one empty list and in these
cases we want to avoid the overhead of computing `xs ++ []`.

This should fix #14759 and #16911.

- - - - -
b507aceb by Ryan Scott at 2019-07-11T17:47:41-04:00
Don't typecheck too much (or too little) in DerivingVia (#16923)

Previously, GHC would typecheck the `via` type once per class in a
`deriving` clause, which caused the problems observed in #16923.
This patch restructures some of the functionality in `TcDeriv` and
`TcHsType` to avoid this problem. We now typecheck the `via` type
exactly once per `deriving` clause and *then* typecheck all of the
classes in the clause.
See `Note [Don't typecheck too much in DerivingVia]` in `TcDeriv`
for the full details.

- - - - -
8449c5b6 by nineonine at 2019-07-11T17:48:18-04:00
Allow reusing temporary object files generated by GHCi by writing to -odir in case -fwrite-interface was specified (#16670)

- - - - -
d5c899d1 by Ben Gamari at 2019-07-11T17:48:54-04:00
head.hackage: Run build on head.hackage's master branch

The GitLab CI infrastructure is now in the master branch.

- - - - -
8a209384 by Ben Gamari at 2019-07-11T17:48:54-04:00
head.hackage: Run builds with -dcore-lint

- - - - -
e4c73514 by Simon Peyton Jones at 2019-07-12T02:20:01-04:00
Fix kind-checking for data/newtypes

In one spot in kcConDecl we were passing in the return
kind signature rether than the return kind. e.g. #16828

   newtype instance Foo :: Type -> Type where
     MkFoo :: a -> Foo a

We were giving kcConDecl the kind (Type -> Type), whereas it
was expecting the ultimate return kind, namely Type.

This "looking past arrows" was being done, independently,
in several places, but we'd missed one.  This patch moves it all
to one place -- the new function kcConDecls (note the plural).

I also took the opportunity to rename
  tcDataFamHeader  to   tcDataFamInstHeader

(The previous name was consistently a source of confusion.)

- - - - -
de3935a6 by Shayne Fletcher at 2019-07-12T02:20:43-04:00
Add shake 0.18.3 to extra deps

- - - - -
a31b24a5 by Ashley Yakeley at 2019-07-13T16:35:41-04:00
base: Data.Fixed: make HasResolution poly-kinded (#10055, #15622)

- - - - -
688a1b89 by Alp Mestanogullari at 2019-07-13T16:36:18-04:00
compiler: trace SysTools commands to emit start/stop eventlog markers

This patch was motivated by some performance characterization work done
for #16822, where we suspected that GHC was spending a lot of time waiting
on the linker to be done. (That turned out to be true.)

The tracing is taken care of by ErrUtils.withTiming, so this patch just defines
and uses a little wrapper around that function in all the helpers for
calling the various systools (C compiler, linker, unlit, ...).

With this patch, assuming a GHC executable linked against an eventlog-capable
RTS (RTS ways that contain the debug, profiling or eventlog way units), we can
measure how much time is spent in each of the SysTools when building hello.hs
by simply doing:

  ghc hello.hs -ddump-timings +RTS -l

The event names are "systool:{cc, linker, as, unlit, ...}".

- - - - -
348cc8eb by Andreas Klebinger at 2019-07-13T16:36:57-04:00
Add two CmmSwitch optimizations.

Move switch expressions into a local variable when generating switches.
This avoids duplicating the expression if we translate the switch
to a tree search. This fixes #16933.

Further we now check if all branches of a switch have the same
destination, replacing the switch with a direct branch if that
is the case.

Both of these patterns appear in the ENTER macro used by the RTS
but are unlikely to occur in intermediate Cmm generated by GHC.

Nofib result summary:

--------------------------------------------------------------------------------
        Program           Size    Allocs   Runtime   Elapsed  TotalMem
--------------------------------------------------------------------------------
            Min          -0.0%     -0.0%    -15.7%    -15.6%      0.0%
            Max          -0.0%      0.0%     +5.4%     +5.5%      0.0%
 Geometric Mean          -0.0%     -0.0%     -1.0%     -1.0%     -0.0%

Compiler allocations go up slightly: +0.2%

Example output before and after the change taken from RTS code below.

All but one of the memory loads `I32[_c3::I64 - 8]` are eliminated.
Instead the data is loaded once from memory in block c6.

Also the switch in block `ud` in the original code has been
eliminated completely.

Cmm without this commit:

```
stg_ap_0_fast() { //  [R1]
        { []
        }
    {offset
      ca: _c1::P64 = R1;   // CmmAssign
          goto c2;   // CmmBranch
      c2: if (_c1::P64 & 7 != 0) goto c4; else goto c6;
      c6: _c3::I64 = I64[_c1::P64];
          if (I32[_c3::I64 - 8] < 26 :: W32) goto ub; else goto ug;
      ub: if (I32[_c3::I64 - 8] < 15 :: W32) goto uc; else goto ue;
      uc: if (I32[_c3::I64 - 8] < 8 :: W32) goto c7; else goto ud;
      ud: switch [8 .. 14] (%MO_SS_Conv_W32_W64(I32[_c3::I64 - 8])) {
              case 8, 9, 10, 11, 12, 13, 14 : goto c4;
          }
      ue: if (I32[_c3::I64 - 8] >= 25 :: W32) goto c4; else goto uf;
      uf: if (%MO_SS_Conv_W32_W64(I32[_c3::I64 - 8]) != 23) goto c7; else goto c4;
      c4: R1 = _c1::P64;
          call (P64[Sp])(R1) args: 8, res: 0, upd: 8;
      ug: if (I32[_c3::I64 - 8] < 28 :: W32) goto uh; else goto ui;
      uh: if (I32[_c3::I64 - 8] < 27 :: W32) goto c7; else goto c8;
      ui: if (I32[_c3::I64 - 8] < 29 :: W32) goto c8; else goto c7;
      c8: _c1::P64 = P64[_c1::P64 + 8];
          goto c2;
      c7: R1 = _c1::P64;
          call (_c3::I64)(R1) args: 8, res: 0, upd: 8;
    }
}
```

Cmm with this commit:

```
stg_ap_0_fast() { //  [R1]
        { []
        }
    {offset
      ca: _c1::P64 = R1;
          goto c2;
      c2: if (_c1::P64 & 7 != 0) goto c4; else goto c6;
      c6: _c3::I64 = I64[_c1::P64];
          _ub::I64 = %MO_SS_Conv_W32_W64(I32[_c3::I64 - 8]);
          if (_ub::I64 < 26) goto uc; else goto uh;
      uc: if (_ub::I64 < 15) goto ud; else goto uf;
      ud: if (_ub::I64 < 8) goto c7; else goto c4;
      uf: if (_ub::I64 >= 25) goto c4; else goto ug;
      ug: if (_ub::I64 != 23) goto c7; else goto c4;
      c4: R1 = _c1::P64;
          call (P64[Sp])(R1) args: 8, res: 0, upd: 8;
      uh: if (_ub::I64 < 28) goto ui; else goto uj;
      ui: if (_ub::I64 < 27) goto c7; else goto c8;
      uj: if (_ub::I64 < 29) goto c8; else goto c7;
      c8: _c1::P64 = P64[_c1::P64 + 8];
          goto c2;
      c7: R1 = _c1::P64;
          call (_c3::I64)(R1) args: 8, res: 0, upd: 8;
    }
}
```

- - - - -
232002c4 by James Foster at 2019-07-13T16:37:34-04:00
Make HsInstances and DynFlags compile with -O0 for Stage0 to speed up Hadrian builds (fixes #16936)

- - - - -
a7176fa1 by Ömer Sinan Ağacan at 2019-07-13T16:38:13-04:00
Minor refactoring in CmmBuildInfoTables

- Replace `catMaybes (map ...)` with `mapMaybe ...`
- Remove a list->set->list conversion

- - - - -
ff04eb59 by John Ericson at 2019-07-14T01:19:22-04:00
Remove purely external primops

The compiler doesn't create uses nor compiles the uses that exist
specially. These are just plain C-- FFI.

These `await*` ones are especially important to so convert because "true"
primops are hard to make platform-specific currently.

The other exports are part of this commit so this module always exports
something, which avoids silly CPP elsewhere. More will be added later
once `foreign import prim` is extended.

- - - - -
f9b00038 by Matthew Pickering at 2019-07-14T01:19:58-04:00
hadrian: Build debug rts with -O0 -g3 and disable rts stripping

Fixes #16920

- - - - -
f508b7ce by Ben Gamari at 2019-07-14T01:20:34-04:00
Don't package settings in bindist

Since !712 the `settings` file is produced by the build system instead
of autoconf. However, this introduced a subtle bug where we would fail
to rebuild the `settings` file with what we have learned from the
install-time `configure` invocation. Fix this by not packaging
`settings` in the bindist tarball. The build system will take care of
the rest.

Also fix a bug where the value of `UseLibdw` was not being persisted to
the install time `configure`.

- - - - -
e7ed53c9 by John Ericson at 2019-07-14T01:21:11-04:00
Remove LLVM_TARGET platform macros

Instead following @angerman's suggestion put them in the config file.
Maybe we could re-key llvm-targets someday, but this is good for now.

- - - - -
bd9fc1b2 by John Ericson at 2019-07-14T01:21:48-04:00
Make CPP linter skip certain files

 - docs which document the lint and need to contain the unutterable

 - vendored code which is outside our purview

- - - - -
d7c6c471 by John Ericson at 2019-07-14T01:21:48-04:00
Expunge #ifdef and #ifndef from the codebase

These are unexploded minds as far as the linter is concerned. I don't
want to hit in my MRs by mistake!

I did this with `sed`, and then rolled back some changes in the docs,
config.guess, and the linter itself.

- - - - -
fce8f240 by xplorld at 2019-07-14T08:32:48-04:00
rename type parameter in `instance Applicative ((->) a)`, fixing #16928

- - - - -
78ed46f3 by Niklas Hambüchen at 2019-07-14T08:33:26-04:00
primops: haddock: Fix typo in referenced function.

Found by @lehins.
- - - - -
a39a3cd6 by Ben Gamari at 2019-07-15T00:14:40-04:00
gitlab-ci: Disable submodule linter for now

- - - - -
0670f98a by Arnaud Spiwack at 2019-07-15T09:23:15+02:00
Add a note in the simplifier about in-scope set as a substitution

See also the discussion at #16592

- - - - -
284a2f44 by Vladislav Zavialov at 2019-07-15T18:29:05-04:00
Decouple AddAnn from P

- - - - -
1befd2c0 by Vladislav Zavialov at 2019-07-15T18:29:05-04:00
PV is not P (#16611)

- - - - -
5728d9fa by Artem Pelenitsyn at 2019-07-16T02:40:08-04:00
Sort out Hadrian colored output flags (fix #16397)

Hadrian used to have a separate flag --progress-colour to control
colored output during the build. After introduction of a Shake flag
with similar purpose Hadrian's flag became redundant. The commit removes
--progress-colour and switches to Shake's flag. The only difference
between the two is that Hadrian has special default mode when it tries
to determine if the terminal support colored output. The user can
override it using (Shake's) `--[no-]color`.

- - - - -
db948dae by Ben Gamari at 2019-07-16T02:40:43-04:00
Revert "Add support for SIMD operations in the NCG"

Unfortunately this will require more work; register allocation is
quite broken.

This reverts commit acd795583625401c5554f8e04ec7efca18814011.

- - - - -
373c9cb3 by Daniel Gröber at 2019-07-16T02:41:23-04:00
rts: Divorce init of Heap profiler from CCS profiler

Currently initProfiling gets defined by Profiling.c only if PROFILING is
defined. Otherwise the ProfHeap.c defines it.

This is just needlessly complicated so in this commit I make Profiling and
ProfHeap into properly seperate modules and call their respective init
functions from RtsStartup.c.

- - - - -
52f755aa by Daniel Gröber at 2019-07-16T02:41:23-04:00
rts: Rename the nondescript initProfiling2 to refreshProfilingCCSs

- - - - -
0a9b77b8 by John Ericson at 2019-07-17T12:20:26-04:00
Create {Int,Word}32Rep

This prepares the way for making Int32# and Word32# the actual size they
claim to be.

Updates binary submodule for (de)serializing the new runtime reps.

- - - - -
8add024f by Sebastian Graf at 2019-07-17T12:20:27-04:00
Make GHC-in-GHCi work on Windows

By not building anything in the dynamic way on Windows, where we don't
have a working story for DLLs yet.

Also the ghcid command needs to call bash on the hadrian/ghci.sh script
explicitly as the path gets interpreted differently otherwise.

- - - - -
d48da6ff by Ben Gamari at 2019-07-18T20:55:11-04:00
gitlab-ci: Run slow validate in -debug job

Otherwise we don't compile the stage2 compiler with DEBUG, meaning the
testsuite isn't checked with assertions.

Metric Increase:
    haddock.Cabal

- - - - -
272246bf by Ben Gamari at 2019-07-18T20:55:11-04:00
testsuite: More type checking fixes

- - - - -
c7bcd017 by Ben Gamari at 2019-07-18T20:55:11-04:00
Add HasDebugCallStack to unionLists

This should help identify a few cases where this is throwing warnings

- - - - -
3cec2af6 by Ben Gamari at 2019-07-18T20:55:11-04:00
testsuite: Mark static-plugins as broken in profiled ways

See #16803.

- - - - -
e8adffb5 by Ben Gamari at 2019-07-18T20:55:11-04:00
testsuite: Set -dinitial-unique when reversing uniques

Otherwise the unique counter starts at 0, causing us to immediately
underflow.

- - - - -
b9e9d8c9 by Ben Gamari at 2019-07-18T20:55:11-04:00
testsuite: Fix req_th

- - - - -
d238d306 by Ben Gamari at 2019-07-18T20:55:11-04:00
Fix formatting of --info's "Debug on" field

As noted in #16914, the value `True` was used instead of `YES` here, in
contrast to the other boolean fields emitted by `--info`. This confused
the testsuite driver and broke the `ghc_debugged` testsuite predicate.

- - - - -
eb8c40e3 by Ben Gamari at 2019-07-18T20:55:11-04:00
testsuite: Mark hWaitForInput-accurate-stdin as broken in all threaded ways

Previously it was not marked as broken in profthreaded

- - - - -
b16cabc1 by Ben Gamari at 2019-07-18T20:55:11-04:00
testsuite: Print output from hp2ps

- - - - -
b62a2dfb by Ben Gamari at 2019-07-18T20:55:11-04:00
testsuite: Fix some ints used as bools

- - - - -
b3df1efb by Ben Gamari at 2019-07-18T20:55:11-04:00
testsuite: Skip forking tests in profiled ways

As noted in #11645 and #8862, forking and profiling don't go well
together.

Bumps hpc and unix submodules.

- - - - -
49dcbf86 by Ben Gamari at 2019-07-18T20:55:11-04:00
testsuite: Mark test-hole-plugin as req_th

This requires code loading and therefore can't be run in the profiled
ways when GHC is dynamically linked.

- - - - -
ce8ffd80 by Ben Gamari at 2019-07-18T20:55:11-04:00
testsuite: Unmark recomp007 as broken

Fixed in #14759.

- - - - -
82abc479 by Ben Gamari at 2019-07-18T20:55:11-04:00
testsuite: Mark T4808 as broken in threaded2 way

As noted in #16909.

- - - - -
73703d9b by Artem Pelenitsyn at 2019-07-19T18:06:22-04:00
Hide "Loading package environment" message with -v0 (fix #16879)

- - - - -
9372ff92 by Vladislav Zavialov at 2019-07-19T18:06:57-04:00
Drop the orphan roles check (#16941)

9366e019 introduced a check for orphan roles to fix #8485

6ab5da99 changed the lookup code and made the check redundant.

Now it is removed.

- - - - -
69adb253 by Richard Eisenberg at 2019-07-19T18:07:37-04:00
Fix #16870 by improving documentation (only)

- - - - -
f1980a1e by Sebastian Graf at 2019-07-19T18:08:15-04:00
Make generated ghc-stage<n> scripts executable

- - - - -
bec17997 by James Foster at 2019-07-19T18:08:51-04:00
users-guide: corrected -fmax-relevant-binds reverse to be -fno-max-relevant-binds
- - - - -
257d1fd8 by Ryan Scott at 2019-07-19T18:09:28-04:00
Don't maintainer-clean libraries/ghc-boot/ghc.mk (#16953)

This makes the `maintainer-clean` rule in `ghc.mk` slightly more
sophisticated so that it does not remove the version-controlled
file `libraries/ghc-boot/ghc.mk`, which was checked into version
control in commit 24782b89907ab36fb5aef3a17584f4c10f1e2690.

Fixes #16953.

- - - - -
ff996555 by Richard Eisenberg at 2019-07-19T18:10:06-04:00
Add module doc for Plugins.

This was requested in #15650.

- - - - -
08ad7ef4 by Baldur Blöndal at 2019-07-20T07:51:22-04:00
Added do-notation examples for Functor, Applicative and Monad combinators.

- - - - -
7b42ece5 by Alfredo Di Napoli at 2019-07-20T07:52:01-04:00
Line wrap when pp long expressions (fixes #16874)

This commit fixes #16874 by using `fsep` rather than `sep` when pretty
printing long patterns and expressions.

- - - - -
3676375f by Andreas Klebinger at 2019-07-20T07:52:39-04:00
Bump nofib submodule.

- - - - -
4dfd6a5f by Matthew Pickering at 2019-07-20T07:53:15-04:00
hadrian: Remove RTS -Waggregate-return warning

This was removed from make in 077b92fa39839a8e83cd87398435424403cf6486
- - - - -
5042ba9d by Andreas Klebinger at 2019-07-21T05:03:04-04:00
Expose the GhcPrelude module.

This makes it simpler to load Modules importing it
when using ghc-the-package.

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

- - - - -
67ee741b by Ivan Kasatenko at 2019-07-21T05:03:40-04:00
Do not ignore events deletion when events to be added are provided (#16916)

Kqueue/kevent implementation used to ignore events to be unsubscribed
from when events to be subscribed to were provided. This resulted in a
lost notification subscription, when GHC runtime didn't listen for any
events, yet the kernel considered otherwise and kept waking up the IO
manager thread.

This commit fixes this issue by always adding and removing all of the
provided subscriptions.

- - - - -
32be4461 by Roland Senn at 2019-07-21T05:04:17-04:00
Fix #8487: Debugger confuses variables

To display the free variables for a single breakpoint, GHCi pulls out the
information from the fields `modBreaks_breakInfo` and `modBreaks_vars`
of the `ModBreaks` data structure. For a specific breakpoint this gives 2
lists of types 'Id` (`Var`) and `OccName`. They are used to create the Id's
for the free variables and must be kept in sync:
If we remove an element from the Names list, then we also must remove the
corresponding element from the OccNames list.

- - - - -
4854a349 by Ben Gamari at 2019-07-21T05:04:53-04:00
ghc-cabal: Use fromFlagOrDefault instead of fromFlag

As fromFlag is partial. The only case where we used fromFlag is when
determining whether to strip libraries; we now assume that we shouldn't.

- - - - -
4c7a8462 by Xavier Denis at 2019-07-23T11:43:59-04:00
Make sure to load interfaces when running :instances

- - - - -
f9af30f8 by Ömer Sinan Ağacan at 2019-07-23T11:44:38-04:00
Remove fix-submodules.py

Now that we have absolute paths for submodules (since a76b233d) we no
longer need this script.

- - - - -
6ade71fb by Alp Mestanogullari at 2019-07-23T23:06:36-04:00
Hadrian: run the testsuite in Windows CI job

Since MR !1025 fixed the Windows build, allowing us to build a binary
distribution, we can now run the testsuite in that CI job.

This required fixing 'createFileLink': it should not try to create
symlinks on Windows (that requires admin priviledges, which Hadrian can't
assume). We now instead fall back to copying.

This patch also removes some duplicated logic for iserv in the test rules,
where we handle our dependency on the iserv binaries in a special way.

- - - - -
3dbcc368 by Richard Eisenberg at 2019-07-23T23:07:13-04:00
Simon and I like to work in hsSyn, too.

- - - - -
b95b6380 by John Ericson at 2019-07-24T16:49:53-04:00
Make stage 1 GHC target independent

Now that the target macros are not being used, we remove them. This
prevents target hardcoding regressions.

- - - - -
d0f8ed20 by Ben Gamari at 2019-07-24T16:50:28-04:00
gitlab-ci: Fix source tarball job

* Use show! in source tarball job. Since we aren't actually building
  anything in this job `show` won't
  work.

* Fix Docker image name

* Make `version` file contain only version string

- - - - -
90dd2ea0 by Vladislav Zavialov at 2019-07-24T23:11:22-04:00
ASSERT(vis_flag==ForallInvis) in hsScopedTvs

- - - - -
e07f0e2b by Vladislav Zavialov at 2019-07-24T23:11:57-04:00
Drop unused helpers 'mkTyClGroup' and 'emptyTyClGroup'

- - - - -
cb495b3c by Ryan Scott at 2019-07-25T17:25:26-04:00
Make DefUses = OrdList DefUse

Before, `type DefUses = [DefUse]`. But lists are a terrible choice of
data structure here, as we frequently append to the right of a
`DefUses`, which yields some displeasing asymptotics. Let's instead
use `OrdList`, which has constant-time appending to the right.

This is one step on the way to #10347.

- - - - -
b9c99df1 by Ömer Sinan Ağacan at 2019-07-25T17:26:03-04:00
Printer: add an empty line between bindings in Rec STG binding groups

Before:

    Rec {
    x2_r10T :: Lib.Bar
    [GblId, Unf=OtherCon []] =
        CCS_DONT_CARE Lib.Bar! [x3_r10U];
    x3_r10U :: Lib.Foo
    [GblId, Unf=OtherCon []] =
        CCS_DONT_CARE Lib.Foo! [x1_r10p x2_r10T];
    end Rec }

After:

    Rec {
    x2_r10T :: Lib.Bar
    [GblId, Unf=OtherCon []] =
        CCS_DONT_CARE Lib.Bar! [x3_r10U];

    x3_r10U :: Lib.Foo
    [GblId, Unf=OtherCon []] =
        CCS_DONT_CARE Lib.Foo! [x1_r10p x2_r10T];
    end Rec }

- - - - -
30b6f391 by Ryan Scott at 2019-07-26T00:57:02-04:00
Banish reportFloatingViaTvs to the shadow realm (#15831, #16181)

GHC used to reject programs of this form:

```
newtype Age = MkAge Int
  deriving Eq via Const Int a
```

That's because an earlier implementation of `DerivingVia` would
generate the following instance:

```
instance Eq Age where
  (==) = coerce @(Const Int a -> Const Int a -> Bool)
                @(Age         -> Age         -> Bool)
                (==)
```

Note that the `a` in `Const Int a` is not bound anywhere, which
causes all sorts of issues. I figured that no one would ever want to
write code like this anyway, so I simply banned "floating" `via` type
variables like `a`, checking for their presence in the aptly named
`reportFloatingViaTvs` function.

`reportFloatingViaTvs` ended up being implemented in a subtly
incorrect way, as #15831 demonstrates. Following counsel with the
sage of gold fire, I decided to abandon `reportFloatingViaTvs`
entirely and opt for a different approach that would _accept_
the instance above. This is because GHC now generates this instance
instead:

```
instance forall a. Eq Age where
  (==) = coerce @(Const Int a -> Const Int a -> Bool)
                @(Age         -> Age         -> Bool)
                (==)
```

Notice that we now explicitly quantify the `a` in
`instance forall a. Eq Age`, so everything is peachy scoping-wise.
See `Note [Floating `via` type variables]` in `TcDeriv` for the full
scoop.

A pleasant benefit of this refactoring is that it made it much easier
to catch the problem observed in #16181, so this patch fixes that
issue too.

Fixes #15831. Fixes #16181.

- - - - -
aae0457f by nineonine at 2019-07-26T00:57:39-04:00
Change behaviour of -ddump-cmm-verbose to dump each Cmm pass output to a separate file and add -ddump-cmm-verbose-by-proc to keep old behaviour (#16930)

- - - - -
00d9d284 by Vladislav Zavialov at 2019-07-26T00:58:15-04:00
TemplateHaskell: reifyType (#16976)

- - - - -
ea08fa37 by Vladislav Zavialov at 2019-07-26T00:58:15-04:00
reifyTypeOfThing: panic on impossible cases

- - - - -
7c9fb2f0 by Adam Sandberg Eriksson at 2019-07-26T09:49:14-04:00
ghc-heap: implement WEAK closure type #16974

- - - - -
26314386 by nineonine at 2019-07-26T09:49:51-04:00
Add regression test for #16946

- - - - -
cd11f81f by Fumiaki Kinoshita at 2019-07-28T19:47:50-04:00
base: add Functor, Applicative, Monad, Alternative, MonadPlus, Generic and Generic1 instances to Kleisli

- - - - -
c1a06d49 by Dale Wijnand at 2019-07-28T19:48:27-04:00
hadrian: relink to the flavours doc in the ghc repo
- - - - -
9f8cdb35 by Richard Eisenberg at 2019-07-29T19:32:16-04:00
Add Note [RuntimeRep and PrimRep] in RepType

Also adds Note [Getting from RuntimeRep to PrimRep], which
deocuments a related thorny process.

This Note addresses #16964, which correctly observes that
documentation for this thorny design is lacking.

Documentation only.

- - - - -
86f47b8e by Dale Wijnand at 2019-07-29T19:32:52-04:00
hadrian: Drop a stale limitation tracking issue

https://github.com/snowleopard/hadrian/issues/187 was superseded by
https://github.com/snowleopard/hadrian/issues/669, which has also
been closed.

So, optimistically, dropping this as a limitation issue.
- - - - -
9c8a211a by Andreas Klebinger at 2019-07-30T01:33:50-04:00
Expand the preallocated Int range to [-16,255]

Effects as I measured them:

RTS Size: +0.1%
Compile times: -0.5%
Runtine nofib: -1.1%

Nofib runtime result seems to mostly come from the `CS` benchmark
which is very sensible to alignment changes so this is likely over
represented.

However the compile time changes are realistic.

This is related to #16961.

- - - - -
2829f6da by Simon Peyton Jones at 2019-07-30T01:34:27-04:00
Apply a missing substitution in mkEtaWW (#16979)

The `mkEtaWW` case for newtypes forgot to apply the substitution to
the newtype coercion, resulting in the Core Lint errors observed
in #16979. Easily fixed.

Fixes #16979.

Co-authored-by: Ryan Scott <ryan.gl.scott at gmail.com>

- - - - -
371dadfb by Ben Gamari at 2019-07-31T04:27:59-04:00
Break up TyCoRep

This breaks up the monstrous TyCoReps module into several new modules by
topic:

 * TyCoRep: Contains the `Coercion`, `Type`, and related type
   definitions and a few simple predicates but nothing further

 * TyCoPpr: Contains the the pretty-printer logic

 * TyCoFVs: Contains the free variable computations (and
   `tyConAppNeedsKindSig`, although I suspect this should change)

 * TyCoSubst: Contains the substitution logic for types and coercions

 * TyCoTidy: Contains the tidying logic for types

While we are able to eliminate a good number of `SOURCE` imports (and
make a few others smaller) with this change, we must introduce one new
`hs-boot` file for `TyCoPpr` so that `TyCoRep` can define `Outputable`
instances for the types it defines.

Metric Increase:
    haddock.Cabal
    haddock.compiler

- - - - -
b6fa7fe3 by Ben Gamari at 2019-07-31T04:27:59-04:00
gitignore: Add .mypy_cache

- - - - -
88410e77 by Ben Gamari at 2019-07-31T04:27:59-04:00
Move tyConAppNeedsKindSig to Type

Previously it was awkwardly in TyCoFVs (and before that in TyCoRep).
Type seems like a sensible place for it to live.

- - - - -
787fab43 by Ben Gamari at 2019-07-31T04:27:59-04:00
Work around redundant import issue

As mentioned in #16997, GHC currently complains about this import.
In general I'm reluctant to paper over things like this but in the case
of an hs-boot file I think adding an import list is the right thing to
do regardless of the bug.

- - - - -
5e04841c by Ben Gamari at 2019-07-31T13:53:58-04:00
gitlab-ci: Fix it after upgrade

It seems that the regular expression parser changed in GitLab 12.1 and
now does now support forward slashes in the RE, even when escaped.

- - - - -
986643cb by Ivan Kasatenko at 2019-08-01T13:49:50-04:00
Fix T16916 CI failures (#16966)

1. Slightly increased the waiting time for the tested effect to be more
   profound.

2. Introduced measuring of the actual time spent waiting and adjusing
   CPU time by it to compensate for threadDelay waiting time
   inconsistencies.

- - - - -
95521140 by Andreas Klebinger at 2019-08-02T08:14:10-04:00
Add StandaloneDeriving example for DerivingVia.

[skip-ci]

- - - - -
1b9d32b8 by Ryan Scott at 2019-08-02T08:14:47-04:00
Rip out 9-year-old pattern variable hack (#17007)

GHC had an ad hoc validity check in place to rule out pattern
variables bound by type synonyms, such as in the following example:

```hs
type ItemColID a b = Int  -- Discards a,b

get :: ItemColID a b -> ItemColID a b
get (x :: ItemColID a b) = x :: ItemColID a b
```

This hack is wholly unnecessary nowadays, since OutsideIn(X) is more
than capable of instantiating `a` and `b` to `Any`. In light of this,
let's rip out this validity check.

Fixes #17007.

- - - - -
93bed40a by Ryan Scott at 2019-08-02T08:15:25-04:00
Use injectiveVarsOfType to catch dodgy type family instance binders (#17008)

Previously, we detected dodgy type family instances binders by
expanding type synonyms (via `exactTyCoVarsOfType`) and looking for
type variables on the RHS that weren't mentioned on the (expanded)
LHS. But this doesn't account for type families (like the example
in #17008), so we instead use `injectiveVarsOfType` to only count
LHS type variables that are in injective positions. That way, the `a`
in `type instance F (x :: T a) = a` will not count if `T` is a type
synonym _or_ a type family.

Along the way, I moved `exactTyCoVarsOfType` to `TyCoFVs` to live
alongside its sibling functions that also compute free variables.

Fixes #17008.

- - - - -
c902f56b by Krzysztof Gogolewski at 2019-08-02T08:16:03-04:00
Remove build.nix.sh

This file refers to shell.nix, which was removed in
430e6fedfda and c00d2f59d.

- - - - -
5e960287 by Adam Sandberg Eriksson at 2019-08-02T08:16:45-04:00
docs: fixs -prof links in rts-flags section

- - - - -
0c5cd771 by Alp Mestanogullari at 2019-08-02T22:20:14-04:00
compiler: emit finer grained codegen events to eventlog

- - - - -
0ecacb1e by Alp Mestanogullari at 2019-08-02T22:20:14-04:00
Add Note [withTiming] in compiler/main/ErrUtils.hs

- - - - -
4664bafc by Ben Gamari at 2019-08-02T22:20:50-04:00
rts: Always truncate output files

Previously there were numerous places in the RTS where we would fopen
with the "w" flag string. This is wrong as it will not truncate the
file. Consequently if we write less data than the previous length of the
file we will leave garbage at its end.

Fixes #16993.

- - - - -
e3cbe319 by Ben Gamari at 2019-08-02T22:21:26-04:00
Packages: Add timing for package database initialization

- - - - -
a5227080 by Alp Mestanogullari at 2019-08-02T22:22:06-04:00
Hadrian: make settings, platformConstants, etc dependencies of lib:ghc

This fixes #17003, where a user directly asked for the 'docs-haddock' target
without building a complete stage 2 GHC first. Since haddock only depends on
lib:ghc, the stage 2 GHC executable wasn't built, and neither were the
settings, platformConstants, llvm-passes and llvm-targets files, since they
are declared to be dependencies of exe:ghc.

This makes sense in general since all GHC API users (haddock is one) will likely
want those files to be there.

- - - - -
7e404afd by Ben Gamari at 2019-08-04T18:16:51-04:00
gitlab-ci: Manually set SPHINXBUILD on Windows

For some reason configure seems unable to find it on its own. Let's try
giving it a hint.

Addresses #16398.

- - - - -
8a061d18 by Matthew Pickering at 2019-08-04T18:17:28-04:00
Update .gitignore

Add some files generated by hadrian and some tooling files

- - - - -
7d8d0012 by Simon Peyton Jones at 2019-08-04T18:18:08-04:00
Don't float unlifted join points to top level

Ticket #16978 showed that we were floating a recursive,
unlifted join point to top level.  It's very much a corner
case:

    joinrec j :: Int#
            j = jump j
    in ...

But somehow it showed up in a real program.

For non-recursive bindings in SetLevels.lvlBind we were already
(correctly) checking for unlifted bindings, but when I wrote
that code I didn't think that a /recursive/ binding could be
unlifted but /join-points/ can be!

Actually I don't think that SetLevels should be floating
join points at all.  SetLevels really floats things to move
stuff out of loops and save allocation; but none of that applies
to join points.  The only reason to float join points is in
cases like
   join j1 x = join j2 y = ...
               in ...
which we might want to swizzle to
   join j2 x y = ... in
   join j1 x = ...
   in ...
because now j1 looks small and might be inlined away altogether.
But this is a very local float perhaps better done in the simplifier.

Still: this patch fixes the crash, and does so in a way that is
harmless if/when we change our strategy for floating join points.

- - - - -
3b31a94d by Ben Gamari at 2019-08-04T18:18:08-04:00
testsuite: Add testsuite for #16978

- - - - -
2e031806 by Ben Gamari at 2019-08-04T18:18:45-04:00
configure: Search for LLVM executables with two-number versions

Fedora uses the naming llc-7.0 while Debian uses llc-7. Ensure that both
are found.

Fixes #16990.

- - - - -
6e5dfcd2 by Ben Gamari at 2019-08-04T18:19:21-04:00
testsuite: Rework tracking of fragile tests

Breaks fragile tests into two groups, allowing us to easily preserve
stdout/stderr of failing fragile tests.

- - - - -
ea16f6cb by Simon Peyton Jones at 2019-08-06T20:24:41-04:00
Remove dead parameter from coreToStgApp

- - - - -
0c1ccf3c by James Foster at 2019-08-06T20:25:18-04:00
hadrian: Refactor file patterns for future Shake changes (fixes #17005)

Shake will be moving from its current implementation of ?== to one from
System.FilePattern. Support for `//` is being dropped, leaving only `*`
and `**` as special forms. This commit converts the existing file
patterns in Hadrian to the new format. It also removes all occurances
of <//> and changes the user-settings docs to remove references to //
and add **.

The conversion is as follows:

- //a ==> **/a

- a// ==> a/**

- a//b ==> a/**/b

- - - - -
c83e39bf by Matthew Pickering at 2019-08-06T20:25:54-04:00
Remove old/broken(?) .ghci script

I was attempting to load hadrian into ghci by using
`cabal new-repl exe:hadrian` but it failed because it tried
to use this `.ghci` configuration.

I'm not sure who used this script but you should really use the new-repl
method.

- - - - -
6f116005 by Ömer Sinan Ağacan at 2019-08-06T20:26:32-04:00
Introduce a type for "platform word size", use it instead of Int

We introduce a PlatformWordSize type and use it in platformWordSize
field.

This removes to panic/error calls called when platform word size is not
32 or 64. We now check for this when reading the platform config.

- - - - -
2073745c by mniip at 2019-08-07T10:18:07-04:00
Add a -fprint-axiom-incomps option (#15546)

Supply branch incomps when building an IfaceClosedSynFamilyTyCon

`pprTyThing` now has access to incomps. This also causes them to be
written out to .hi files, but that doesn't pose an issue other than a
more faithful bijection between `tyThingToIfaceDecl` and `tcIfaceDecl`.

The machinery for displaying axiom incomps was already present but not
in use. Since this is now a thing that pops up in ghci's :info the
format was modified to look like a haskell comment.

Documentation and a test for the new feature included.

Test Plan: T15546

Reviewers: simonpj, bgamari, goldfire

Reviewed By: simonpj

Subscribers: rwbarton, carter

GHC Trac Issues: #15546

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

- - - - -
bca79345 by mniip at 2019-08-07T10:18:07-04:00
Fix test

- - - - -
3d32286d by mniip at 2019-08-07T10:18:07-04:00
Explicitly number equations when printing axiom incompatibilities

- - - - -
ca8efc49 by mniip at 2019-08-07T10:18:07-04:00
Fix documentation

- - - - -
2c1b1ad7 by mniip at 2019-08-07T10:18:07-04:00
Fix test

- - - - -
8e2fe575 by Zubin Duggal at 2019-08-07T10:18:44-04:00
Fix bug preventing information about patterns from being serialized in .hie files

- - - - -
f1d0e49f by Ben Gamari at 2019-08-07T10:19:21-04:00
testsuite: Add tests for #16943

- - - - -
83ca42de by Ben Gamari at 2019-08-07T10:19:21-04:00
Revert "Make scanr a good producer and consumer"

This reverts commit 4e1dfc3767167dddd0e151a2df8305b12aa0f49c.

Due to #16943.

- - - - -
81860281 by Joachim Breitner at 2019-08-10T14:39:27-04:00
Consolidate `TablesNextToCode` and `GhcUnreigsterised` in configure (#15548)

`TablesNextToCode` is now a substituted by configure, where it has the
correct defaults and error handling. Nowhere else needs to duplicate
that, though we may want the compiler to to guard against bogus settings
files.

I renamed it from `GhcEnableTablesNextToCode` to `TablesNextToCode` to:

 - Help me guard against any unfixed usages

 - Remove any lingering connotation that this flag needs to be combined
   with `GhcUnreigsterised`.

Original reviewers:

Original subscribers: TerrorJack, rwbarton, carter

Original Differential Revision: https://phabricator.haskell.org/D5082

- - - - -
422ffce0 by Ben Gamari at 2019-08-10T14:40:03-04:00
Add timing on loadInterface

AndreasK recently mentioned that he thought that interface file loading
may be a non-trivial cost. Let's measure.

- - - - -
0424de2d by Ömer Sinan Ağacan at 2019-08-10T14:40:46-04:00
Add test for #16893

- - - - -
672cbab2 by Ömer Sinan Ağacan at 2019-08-10T14:41:26-04:00
Reformat comments in StgSyn

This does not make any changes in the contents -- formatting only.

Previously the comments were too noisy and I've always found it very
hard to read. Hopefully it's easier to read now.

- - - - -
328a0efa by Sebastian Graf at 2019-08-13T17:30:15-04:00
Add Foldable, Traversable instances for Uniq(D)FM

The `UniqDFM` is deterministic, of course, while we provide an unsafe
`NonDetUniqFM` wrapper for `UniqFM` to opt into nondeterministic instances.

- - - - -
b1d29c67 by Tamar Christina at 2019-08-13T17:30:50-04:00
Fix binary distribution
- - - - -
a38104b4 by Andreas Klebinger at 2019-08-14T16:55:42-04:00
Rework the Binary Integer instance.

We used to serialise large integers as strings. Now they are serialized
as a list of Bytes.

This changes the size for a Integer in the higher 64bit range from 77 to
9 bytes when written to disk.

The impact on the general case is small (<1% for interface files) as we
don't use many Integers. But for code that uses many this should be a
nice benefit.

- - - - -
aa4d8b07 by Andreas Klebinger at 2019-08-14T16:56:20-04:00
Use os.devnull instead of '/dev/null' in the testsuite driver.

The later caused issues on windows by being translated into
"\\dev\\null" and python then trying to open this non-existant file.

So we now use os.devnull inside python and convert it to "/dev/null"
when calling out to the shell, which is bound to run in a unix like
environment.

This fixes an issue a test producing unexpected stderr output failed
with a framework failure instead of showing a diff of the output.

- - - - -
6329c70a by Richard Eisenberg at 2019-08-14T17:47:25-04:00
GHCi supports not-necessarily-lifted join points

Fixes #16509.

See Note [Not-necessarily-lifted join points] in ByteCodeGen,
which tells the full story.

This commit also adds some comments and cleans some code
in the byte-code generator, as I was exploring around trying
to understand it.

(This commit removes an old test -- this is really a GHCi problem,
not a pattern-synonym problem.)

test case: ghci/scripts/T16509

- - - - -
ca71d551 by James Foster at 2019-08-15T12:01:43-04:00
Remove unused imports of the form 'import foo ()' (Fixes #17065)

These kinds of imports are necessary in some cases such as
importing instances of typeclasses or intentionally creating
dependencies in the build system, but '-Wunused-imports' can't
detect when they are no longer needed. This commit removes the
unused ones currently in the code base (not including test files
or submodules), with the hope that doing so may increase
parallelism in the build system by removing unnecessary
dependencies.

- - - - -
95837c0f by Tobias Dammers at 2019-08-15T22:13:13-04:00
Add test cases for #16615

- - - - -
8d076841 by Tobias Dammers at 2019-08-15T22:13:13-04:00
Make add_info attach unfoldings (#16615)

- - - - -
14208853 by Sylvain Henry at 2019-08-15T22:13:52-04:00
Cmm: constant folding `quotRem x 2^N`

`quot` and `rem` are implemented efficiently when the second argument
is a constant power of 2. This patch uses the same implementations for
`quotRem` primop.

- - - - -
47e16237 by Ömer Sinan Ağacan at 2019-08-15T22:14:31-04:00
Document types of LitNumbers, minor refactoring in Literal.hs

- - - - -
ac73c1b1 by Sylvain Henry at 2019-08-18T05:16:40-04:00
Faster exactLog2

Make `exactLog2` faster (use `countLeadingZeros` and Int32 bit-ops).

On my Core i7-9700k Criterion reports ~50% speedup (from 16 to 8ns).

- - - - -
1230d6f9 by Ömer Sinan Ağacan at 2019-08-18T05:17:20-04:00
Typo fix in CoreToStg

- - - - -
d0716279 by Ryan Scott at 2019-08-18T05:18:01-04:00
Fix #17067 by making data family type constructors actually injective

`TcTyClsDecls.tcFamDecl1` was using `NotInjective` when creating data
family type constructors, which is just plain wrong. This tweaks it
to use `Injective` instead.

Fixes #17067.

- - - - -
993804bf by Sam Halliday at 2019-08-18T16:39:21-04:00
expose ModuleInfo.minf_rdr_env for tooling authors

- - - - -
5b713aa3 by Ömer Sinan Ağacan at 2019-08-18T16:40:03-04:00
Fix COMPACT_NFDATA closure size, more CNF sanity checking

We now do a shallow closure check on objects in compact regions.

See the new comment on why we can't do a "normal" closure check.

- - - - -
ac7c738b by Richard Lupton at 2019-08-19T02:11:59-04:00
Generalized MonadUtils folds to Foldable (#16969)

- - - - -
3a1efe1a by Richard Lupton at 2019-08-19T02:12:00-04:00
Re-export foldlM and foldrM from Data.Foldable in MonadUtils (#16969)

- - - - -
2a394246 by Richard Lupton at 2019-08-19T02:12:00-04:00
Use Foldable instance of Bag for specialised Bag folds (#16969)

- - - - -
ac79dfe9 by Richard Lupton at 2019-08-19T02:12:00-04:00
Remove Bag fold specialisations (#16969)

- - - - -
5e40356f by Ben Gamari at 2019-08-19T02:12:36-04:00
gitlab-ci: Update bootstrap compiled used for Darwin builds

- - - - -
d5055248 by Ben Gamari at 2019-08-22T09:25:08-04:00
gitlab-ci: Add Windows full build during the nightly pipeline

- - - - -
a33bad2d by Sylvain Henry at 2019-08-22T09:25:47-04:00
Doc: add Haddocks for quotRemWord2 primop

- - - - -
605bce26 by James Foster at 2019-08-22T18:47:20-04:00
Add documentation for Hadrian expressions

This commit adds documentation on Hadrian's 'Expr' type and
references the documentation in hadrian/README.md

- - - - -
8f32d2bc by TDecki at 2019-08-22T18:47:57-04:00
base: Reintroduce fusion for scanr

While avoiding #16943.

- - - - -
c3e26ab3 by Ömer Sinan Ağacan at 2019-08-22T22:19:26-04:00
Remove special case in SRT generation with -split-sections

Previously we were using an empty ModuleSRTInfo for each Cmm group with
-split-section. As far as I can see this has no benefits, and
simplifying this makes another patch simpler (!1304).

We also remove some outdated comments: we no longer generate one
module-level SRT.

- - - - -
a8300520 by Ömer Sinan Ağacan at 2019-08-23T12:04:15+03:00
Make non-streaming LLVM and C backends streaming

This adds a Stream.consume function, uses it in LLVM and C code
generators, and removes the use of Stream.collect function which was
used to collect streaming Cmm generation results into a list.

LLVM and C backends now properly use streamed Cmm generation, instead of
collecting Cmm groups into a list before generating LLVM/C code.

- - - - -
47070144 by Andreas Klebinger at 2019-08-23T19:26:42-04:00
Use variable length encoding for Binary instances.

Use LEB128 encoding for Int/Word variants. This reduces
the size of interface files significantly. (~19%).

Also includes a few small optimizations to make unboxing
work better that I have noticed while looking at the core.

- - - - -
cff44d86 by Sergei Trofimovich at 2019-08-23T19:27:21-04:00
configure.ac: fix '--disable-dwarf-debug'

Before the change
    ./configure --disable-dwarf-debug
enabled DWARF debugging unconditionally.

This happened due to use of 5-argument form of `AC_ARG_ENABLE`
without actually checking the passed  `$enableval` parameter:

```
AC_ARG_ENABLE(dwarf-unwind,
    [AC_HELP_STRING([--enable-dwarf-unwind],
        [Enable DWARF unwinding support in the runtime system via elfutils' libdw [default=no]])],
    [AC_CHECK_LIB(dw, dwfl_attach_state,
      [UseLibdw=YES],
      [AC_MSG_ERROR([Cannot find system libdw (required by --enable-dwarf-unwind)])])]
    [UseLibdw=NO]
)
```

Note:

- `[UseLibdw=NO]` is called when `--{enable,disable}-dwarf-unwind`
  is not passed at all as a parameter (ok).
- `[AC_CHECK_LIB(dw, dwfl_attach_state, [UseLibdw=YES],` is called
  for both:

  * `--enable-dwarf-unwind` being passed: `$enableval = "yes"` (ok).
  *  --disable-dwarf-unwind` being passed: `$enableval = "no"` (bad).

The change is to use 3-argument `AC_ARG_ENABLE` and check for passed
value as `"$enable_dwarf_unwind" = "yes"`.

Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org>

- - - - -
10763ce0 by Ömer Sinan Ağacan at 2019-08-27T10:45:02+03:00
Some more documentation for typePrimRep1 stuff

[skip ci]

- - - - -
89487be2 by Ömer Sinan Ağacan at 2019-08-27T15:21:50-04:00
Some tweaks in GHC.Compact haddocks

- - - - -
ee2fad9e by Andreas Klebinger at 2019-08-27T15:22:28-04:00
Remove redundant OPTIONS_GHC in BlockLayout.hs

- - - - -
1c7ec449 by Ömer Sinan Ağacan at 2019-08-28T12:51:12+03:00
Return results of Cmm streams in backends

This generalizes code generators (outputAsm, outputLlvm, outputC, and
the call site codeOutput) so that they'll return the return values of
the passed Cmm streams.

This allows accumulating data during Cmm generation and returning it to
the call site in HscMain.

Previously the Cmm streams were assumed to return (), so the code
generators returned () as well.

This change is required by !1304 and !1530.

Skipping CI as this was tested before and I only updated the commit
message.

[skip ci]

- - - - -
a308b435 by Sebastian Graf at 2019-08-28T11:33:49-04:00
Fix #17112

The `mkOneConFull` function of the pattern match checker used to try to
guess the type arguments of the data type's type constructor by looking
at the ambient type of the match. This doesn't work well for Pattern
Synonyms, where the result type isn't even necessarily a TyCon
application, and it shows in #11336 and #17112.

Also the effort seems futile; why try to try hard when the type checker
has already done the hard lifting? After this patch, we instead supply
the type constructors arguments as an argument to the function and
lean on the type-annotated AST.

- - - - -
137c24e1 by Ryan Scott at 2019-08-28T22:36:40-04:00
Balance parentheses in GHC 8.10.1 release notes

[ci skip]

- - - - -
66282ba5 by luca at 2019-08-28T22:37:19-04:00
Remove Unused flag -ddump-shape [skip ci]

- - - - -
bf9dfe1c by Ömer Sinan Ağacan at 2019-08-29T04:28:35-04:00
Fix LLVM version check yet again

There were two problems with LLVM version checking:

- The parser would only parse x and x.y formatted versions. E.g. 1.2.3
  would be rejected.

- The version check was too strict and would reject x.y formatted
  versions. E.g. when we support version 7 it'd reject 7.0 ("LLVM
  version 7.0") and only accept 7 ("LLVM version 7").

We now parse versions with arbitrarily deep minor numbering (x.y.z.t...)
and accept versions as long as the major version matches the supported
version (e.g. 7.1, 7.1.2, 7.1.2.3 ...).

- - - - -
fc746e98 by Ben Gamari at 2019-08-29T04:29:13-04:00
gitlab-ci: Fix URL of Darwin's cabal-install tarball

This was inadvertently referring to the cabal-install-latest/ directory
which is volatile.

- - - - -
304067a0 by Ömer Sinan Ağacan at 2019-08-29T09:38:25-04:00
Small optimization in the SRT algorithm

Noticed by @simonmar in !1362:

    If the srtEntry is Nothing, then it should be safe to omit
    references to this SRT from other SRTs, even if it is a static
    function.

When updating SRT map we don't omit references to static functions (see
Note [Invalid optimisation: shortcutting]), but there's no reason to add
an SRT entry for a static function if the function is not CAFFY.

(Previously we'd add SRT entries for static functions even when they're
not CAFFY)

Using 9151b99e I checked sizes of all SRTs when building GHC and
containers:

- GHC: 583736 (HEAD), 581695 (this patch). 2041 less SRT entries.
- containers: 2457 (HEAD), 2381 (this patch). 76 less SRT entries.

- - - - -
78afc2c9 by Sergei Trofimovich at 2019-08-30T06:14:44-04:00
configure.ac: add --enable-numa switch

Before the change ./configure detected numa support automatically
withoun a nice way to disable autodetection.

The change adds `--enable-numa` / `--disable-numa` switch to
override the default. If `--enable-numa` is passed and `libnuma`
is not present then configure will fail.

Reported-by: Sergey Alirzaev
Bug: https://github.com/gentoo-haskell/gentoo-haskell/issues/955
Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org>

- - - - -
c0956c14 by Vladislav Zavialov at 2019-08-30T06:15:21-04:00
Remove HsUtils/userHsLTyVarBndrs

This patch removes 'userHsLTyVarBndrs' and 'userHsTyVarBndrs' from HsUtils.
These helper functions were not used anywhere.

- - - - -
7e6aeb13 by Eric Wolf at 2019-08-31T10:25:39+02:00
Add additional step to T16804

Add another small test step

Use the same identifier name in different
scopes and see, if ':uses' handles that.

Add another test step

to check wether local bindings with the
same identifier name might get confused

Add easier to understand test output

Fix annotated lines from file correctly

- - - - -
e56251f6 by Ömer Sinan Ağacan at 2019-08-31T17:55:13-04:00
Remove redundant special case in STG pretty-printer

This special case existed for no reason, and made things inconsistent.

Before

    Boolean.$bT :: Boolean.Boolean
    [GblId, Str=m, Unf=OtherCon []] =
        CAF_ccs  \ u  []  Boolean.$bT1;

After

    Boolean.$bF :: Boolean.Boolean
    [GblId, Str=m, Unf=OtherCon []] =
        \u [] Boolean.$bF1;

The cost-centre is now hidden when not profiling, as is the case with
other types of closures.

- - - - -
cfab4abe by Gershom Bazerman at 2019-09-01T00:34:05-04:00
cap max stack size at 32 bit limit (#17019)

- - - - -
9acba780 by John Ericson at 2019-09-01T22:44:45-04:00
Use C99 Fixed width types to avoid hack in base's configure

Define MD5Context in terms of `uint*_t` and don't use `HsFFI.h`.

- - - - -
11679e5b by Ömer Sinan Ağacan at 2019-09-02T13:17:49+03:00
Few tweaks in -ddump-debug output, minor refactoring

- Fixes crazy indentation in -ddump-debug output
- We no longer dump empty sections in -ddump-debug when a code block
  does not have any generated debug info
- Minor refactoring in Debug.hs and AsmCodeGen.hs

- - - - -
f96d57b8 by John Ericson at 2019-09-05T18:50:19-04:00
Make the C-- O and C types constructors with DataKinds

The tightens up the kinds a bit. I use type synnonyms to avoid adding
promotion ticks everywhere.

- - - - -
b55ee979 by John Ericson at 2019-09-05T18:50:56-04:00
Make sure all boolean settings entries use `YES` / `NO`

Some where using `True` / `False`, a legacy of when they were in
`Config.hs`. See #16914 / d238d3062a9858 for a similar problem.

Also clean up the configure variables names for consistency and clarity
while we're at it. "Target" makes clear we are talking about outputted
code, not where GHC itself runs.

- - - - -
821bece9 by Ömer Sinan Ağacan at 2019-09-07T04:50:21-04:00
Minor refactoring in deriveConstants

Mainly we now generate this

    data PlatformConstants = PlatformConstants {
          pc_CONTROL_GROUP_CONST_291 :: Int,
          pc_STD_HDR_SIZE :: Int,
          pc_PROF_HDR_SIZE :: Int,
          pc_BLOCK_SIZE :: Int,
      }

instead of

    data PlatformConstants = PlatformConstants {
        pc_platformConstants :: ()
        , pc_CONTROL_GROUP_CONST_291 :: Int
        , pc_STD_HDR_SIZE :: Int
        , pc_PROF_HDR_SIZE :: Int
        , pc_BLOCK_SIZE :: Int
        ...
      }

The first field has no use and according to (removed) comments it was to
make code generator's work easier.. if anything this version is simpler
because it has less repetition (the commas in strings are gone).

- - - - -
b0fdd7fe by Alp Mestanogullari at 2019-09-07T04:50:59-04:00
hadrian: fix _build/ghc-stage1 to make it callable from any directory

- - - - -
51379b89 by Ömer Sinan Ağacan at 2019-09-08T21:40:32-04:00
Add a new flag -dno-typeable-binds for debugging

See the user manual entry -- this helps when debugging as generated Core
gets smaller without these bindings.

- - - - -
d0b45ac6 by Moritz Kiefer at 2019-09-08T21:41:12-04:00
Fix GHC version guard for Int32Rep/Word32Rep

Those constructors have been added after GHC 8.8. The version guards
in `binary` are correct, see https://github.com/kolmodin/binary/pull/167/files.

- - - - -
4cf91d1a by Daniel Gröber at 2019-09-09T05:42:33-04:00
Use lazyness for FastString's z-encoding memoization

Having an IORef in FastString to memoize the z-encoded version is
unecessary because there is this amazing thing Haskell can do natively,
it's called "lazyness" :)

We simply remove the UNPACK and strictness annotations from the constructor
field corresponding to the z-encoding, making it lazy, and store the
(pure) z-encoded string there.

The only complication here is 'hasZEncoding' which allows cheking if a
z-encoding was computed for a given string. Since this is only used for
compiler performance statistics though it's not actually necessary to have
the current per-string granularity.

Instead I add a global IORef counter to the FastStringTable and use
unsafePerformIO to increment the counter whenever a lazy z-encoding is
forced.

- - - - -
f5e2fde4 by Daniel Gröber at 2019-09-09T05:42:33-04:00
Update FastString docstrings

1) FastStrings are always UTF-8 encoded now.
2) Clarify what is meant by "hashed"
3) Add mention of lazy z-enc

- - - - -
270fbe85 by Ryan Scott at 2019-09-09T05:43:12-04:00
Replace queryCygwinTerminal with Win32's isMinTTYHandle

`SysTools.Terminal.queryCygwinTerminal` now exists in the `Win32`
library under the name `isMinTTYHandle` since `Win32-2.5.0.0`.
(GHC 8.4.4 ships with `Win32-2.6.1.0`, so this is well within GHC's
support window.) We can therefore get replace `queryCygwinTerminal`
with `isMinTTYHandle` and delete quite a bit of code from
`SysTools.Terminal` in the process.

Along the way I needed to replace some uses of `#if defined x` with
`#if defined(x)` to please the CI linters.

- - - - -
447864a9 by Sylvain Henry at 2019-09-10T00:04:50+02:00
Module hierarchy: StgToCmm (#13009)

Add StgToCmm module hierarchy. Platform modules that are used in several
other places (NCG, LLVM codegen, Cmm transformations) are put into
GHC.Platform.

- - - - -
60c26403 by Niklas Hambüchen at 2019-09-11T09:44:23-04:00
linker: Move -optl flags to end of linker invocation.

Until now, giving `-optl` linker flags to `ghc` on the command line placed
them in the wrong place in the `ld` command line:

They were given before all the Haskell libararies, when they should appear after.

Background:
Most linkers like `ld.bfd` and `ld.gold`, but not the newer LLVM `lld`, work in
a way where the order of `-l` flags given matters; earlier `-lmylib1` flags are
supposed to create "holes" for linker symbols that are to be filled with later
`lmylib2` flags that "fill the holes" for these symbols.

As discovered in
https://github.com/haskell/cabal/pull/5451#issuecomment-518001240,
the `-optl` flags appeared before e.g. the

    -lHStext-1.2.3.1
    -lHSbinary-0.8.6.0
    -lHScontainers-0.6.0.1

flags that GHC added at the very end.

Haskell libraries typically depend on C libraries, so `-lHS*` flags will create
holes for the C libraries to fill in, but that only works when those libraries'
`-l` flags are given **after** the `-lHS*` flags; until now they were given
before, which was wrong.

This meant that Cabal's `--ld-options` flag and `ld-options` `.cabal` file field
were pretty ineffective, unless you used the `--ld-option=--start-group` hack as
(https://github.com/haskell/cabal/pull/5451#issuecomment-406761676) that
convinces the classical linkers to not be dependent on the order of linker flags
given.

This commit fixes the problem by simply flipping the order, putting `-optl`
flags at the end, after Haskell libraries.

The code change is effectively only `args1 ++ args` -> `args ++ args1`
but the commit also renames the variables for improved clarity.

Simple way to test it:

    ghc --make Main.hs -fforce-recomp -v -optl-s

on a `Main.hs` like:

    import qualified Data.Set as Set
    main = print $ Set.fromList "hello"

- - - - -
7032a913 by John Ericson at 2019-09-11T09:45:02-04:00
Remove COMPILING_GHC

It is no longer used. I guess we are sharing fewer headers with the RTS
than the comment claims. That's a relief!

- - - - -
58569a5b by Peter Trommler at 2019-09-11T09:45:47-04:00
testsuite: check for RTS linker

Fixes #16833

- - - - -
df6fbe03 by Luke Lau at 2019-09-11T09:46:36-04:00
Bump Hadrian's QuickCheck dependency

- - - - -
d9e637df by John Ericson at 2019-09-11T09:47:26-04:00
Remove dead `ncgDebugIsOn` and `NCG_DEBUG`

Haven't been used since 16206a6603e87e15d61c57456267c5f7ba68050e.

- - - - -
7ef6fe8f by Ben Gamari at 2019-09-11T09:48:03-04:00
SetLevels: Fix potential panic in lvlBind

3b31a94d introduced a use of isUnliftedType which can panic in the case
of levity-polymorphic types. Fix this by introducing mightBeUnliftedType
which returns whether the type is *guaranteed* to be lifted.

- - - - -
c76cc0c6 by Ömer Sinan Ağacan at 2019-09-11T19:40:06-04:00
Refactor bad coercion checking in a few places

We do bad coercion checking in a few places in the compiler, but they
all checked it differently:

- CoreToStg.coreToStgArgs:

  Disallowed lifted-to-unlifted, disallowed changing prim reps even when
  the sizes are the same.

- StgCmmExpr.cgCase:

  Checked primRepSlot equality. This disallowed Int to Int64 coercions
  on 64-bit systems (and Int to Int32 on 32-bit) even though those are
  fine.

- CoreLint:

  Only place where we do this right. Full rules are explained in Note
  [Bad unsafe coercion].

This patch implements the check explained in Note [Bad unsafe coercion]
in CoreLint and uses it in CoreToStg.coreToStgArgs and
StgCmmExpr.cgCase.

This fixes #16952 and unblocks !1381 (which fixes #16893).

This is the most conservative and correct change I came up with that
fixes #16952.

One remaining problem with coercion checking is that it's currently done
in seemingly random places. What's special about CoreToStg.coreToStgArgs
and StgCmmExpr.cgCase? My guess is that adding assertions to those
places caught bugs before so we left assertions in those places. I think
we should remove these assertions and do coercion checking in CoreLint
and StgLint only (#17041).

- - - - -
3a7d3923 by Tamar Christina at 2019-09-11T19:40:53-04:00
Windows: make openTempFile fully atomic.

- - - - -
98b0d6ee by Pranay Sashank at 2019-09-12T04:52:33-04:00
Print the correct system memory in use with +RTS -s (#17158)

Use `stats.max_mem_in_use_bytes` to print the memory usage instead of
`stats.max_live_bytes` which prints maximum residency.

Fixes (#17158).

- - - - -
a06629b4 by John Ericson at 2019-09-12T04:53:13-04:00
Do not throw away backpack instantiations for module lookup cache

Currently, there is only one home package so this probably doesn't
matter. But if we support multiple home packages, they could differ only
in arguments (same indef component being applied).

It looks like it used to be this way before
4e8a0607140b23561248a41aeaf837224aa6315b, but that commit doesn't seem
to comment on this change in the particular. (It's main purpose is
creating the InstalledUnitId and recategorizing the UnitId expressions
accordingly.)

Trying this as a separate commit for testing purposes. I leave it to
others to decide whether this is a good change on its own.

- - - - -
09fa5654 by John Ericson at 2019-09-12T04:53:51-04:00
Remove unused `#include`s from parser/cutils.c

Looks like these have been unused since
7c665f9ce0980ee7c81a44c8f861686395637453.

- - - - -
2b37a79d by Sebastian Graf at 2019-09-12T14:05:29-04:00
Bump Cabal submodule to 3.1

-------------------------
Metric Increase:
    haddock.Cabal
    T4029
-------------------------

- - - - -
86753475 by Ningning Xie at 2019-09-12T14:06:07-04:00
Fix StandaloneDeriving

If I understand correctly, `deriving instance _ => Eq (Foo a)`
is equivalent to `data Foo a deriving Eq`, rather than
`data Foo a deriving Foo`.
- - - - -
a733002a by Ben Gamari at 2019-09-13T03:09:47-04:00
Update mailmap

- - - - -
5b64aee2 by Simon Peyton Jones at 2019-09-13T03:10:26-04:00
Fix scoping of implicit parameters

There was an outright bug in TcInteract.solveOneFromTheOther
which meant that we did not always pick the innermost
implicit parameter binding, causing #17104.

The fix is easy, just a rearrangement of conditional tests

- - - - -
47b12660 by Tamar Christina at 2019-09-13T03:11:06-04:00
Windows: Fix hsc2hs non-deterministic failures.

- - - - -
e3a7592b by Alp Mestanogullari at 2019-09-13T03:11:50-04:00
Add a test to make sure we don't regress on #17140 in the future

- - - - -
6f3cd50e by Zubin Duggal at 2019-09-13T11:24:51-04:00
Explain how to update HieAst [skip ci]

- - - - -
71428a43 by Zubin Duggal at 2019-09-13T11:24:51-04:00
Address review comments [skip CI]

- - - - -
ccb4e646 by John Ericson at 2019-09-13T11:25:29-04:00
Compiler should always get fingerprinting impl from base

07ee15915d5a0d6d1aeee137541eec6e9c153e65 started the transition, but the
job was never finished.

- - - - -
c45c89d6 by Ben Gamari at 2019-09-13T11:26:05-04:00
gitlab: Add issue template for documentation issues

Fixes #17180.

- - - - -
a0e220b7 by John Ericson at 2019-09-13T11:26:43-04:00
Remove empty NCG.h

- - - - -
046ca133 by Andrew Martin at 2019-09-13T15:43:16-04:00
Add predicates for testing if IOError is ResourceVanished.

This adds isResourceVanished, resourceVanishedErrorType, and
isResourceVanishedErrorType to System.IO.Error, resolving #14730.

- - - - -
bd079345 by taylorfausak at 2019-09-14T06:25:27-04:00
Fix CONLIKE typo
- - - - -
cf7e78a3 by Ben Gamari at 2019-09-15T23:46:36-04:00
Rename GHC.StgToCmm.Con -> GHC.StgToCmm.DataCon

Incredibly, Windows disallows the manipulation of any file matching
Con(\..*)?. The `GHC.StgToCmm.Con` was introduced in the renamings in
447864a9, breaking the Windows build. Work around this by renaming it to
`GHC.StgToCmm.DataCon`

Fixes #17187.

- - - - -
7208160d by Sylvain Henry at 2019-09-15T23:47:22-04:00
Fix Hadrian build with Stack (#17189)

Broken by 2b37a79d61e9b3787873dc9f7458ef2bde4809b0

- - - - -
b5ae3868 by Sylvain Henry at 2019-09-16T13:32:22-04:00
Allow validation with Hadrian built with Stack [skip ci]

- - - - -
7915afc6 by Sebastian Graf at 2019-09-16T13:33:05-04:00
Encode shape information in `PmOracle`

Previously, we had an elaborate mechanism for selecting the warnings to
generate in the presence of different `COMPLETE` matching groups that,
albeit finely-tuned, produced wrong results from an end user's
perspective in some cases (#13363).

The underlying issue is that at the point where the `ConVar` case has to
commit to a particular `COMPLETE` group, there's not enough information
to do so and the status quo was to just enumerate all possible complete
sets nondeterministically.  The `getResult` function would then pick the
outcome according to metrics defined in accordance to the user's guide.
But crucially, it lacked knowledge about the order in which affected
clauses appear, leading to the surprising behavior in #13363.

In !1010 we taught the term oracle to reason about literal values a
variable can certainly not take on. This MR extends that idea to
`ConLike`s and thereby fixes #13363: Instead of committing to a
particular `COMPLETE` group in the `ConVar` case, we now split off the
matching constructor incrementally and record the newly covered case as
a refutable shape in the oracle. Whenever the set of refutable shapes
covers any `COMPLETE` set, the oracle recognises vacuosity of the
uncovered set.

This patch goes a step further: Since at this point the information
in value abstractions is merely a cut down representation of what the
oracle knows, value abstractions degenerate to a single `Id`, the
semantics of which is determined by the oracle state `Delta`.
Value vectors become lists of `[Id]` given meaning to by a single
`Delta`, value set abstractions (of which the uncovered set is an
instance) correspond to a union of `Delta`s which instantiate the
same `[Id]` (akin to models of formula).

Fixes #11528 #13021, #13363, #13965, #14059, #14253, #14851, #15753, #17096, #17149

-------------------------
Metric Decrease:
    ManyAlternatives
    T11195
-------------------------

- - - - -
ae4415b9 by Matthew Pickering at 2019-09-17T19:21:10-04:00
eventlog: Add biographical and retainer profiling traces

This patch adds a new eventlog event which indicates the start of
a biographical profiler sample. These are different to normal events as
they also include the timestamp of when the census took place. This is
because the LDV profiler only emits samples at the end of the run.

Now all the different profiling modes emit consumable events to the
eventlog.

- - - - -
9c21b2fd by Richard Eisenberg at 2019-09-17T19:22:00-04:00
Fix #13571 by adding an extension flag check

Test case: indexed-types/should_fail/T13571

- - - - -
8039b125 by Simon Peyton Jones at 2019-09-17T19:22:50-04:00
Comments only

- - - - -
1c3af277 by Simon Peyton Jones at 2019-09-17T19:23:37-04:00
Improve error message for out-of-scope variables + VTA

As #13834 and #17150 report, we get a TERRIBLE error message when you
have an out of scope variable applied in a visible type application:
     (outOfScope @Int True)

This very simple patch improves matters.

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

- - - - -
c77fc3b2 by John Ericson at 2019-09-17T19:24:20-04:00
Deduplicate `HaskellMachRegs.h` and `RtsMachRegs.h` headers

Until 0472f0f6a92395d478e9644c0dbd12948518099f there was a meaningful
host vs target distinction (though it wasn't used right, in genapply).
After that, they did not differ in meaningful ways, so it's best to just
only keep one.

- - - - -
c3eaaca6 by Simon Peyton Jones at 2019-09-19T09:03:19-04:00
Add a missing update of sc_hole_ty (#16312)

In simplCast I totally failed to keep the sc_hole_ty field of
ApplyToTy (see Note [The hole type in ApplyToTy]) up to date.
When a cast goes by, of course the hole type changes.

Amazingly this has not bitten us before, but #16312 finally
triggered it.  Fortunately the fix is simple.

Fixes #16312.

- - - - -
de1723b2 by Ben Gamari at 2019-09-19T09:03:19-04:00
Simplify: Lazy pattern match

- - - - -
d9c6b86e by Richard Eisenberg at 2019-09-19T09:04:03-04:00
Refactor kindGeneralize and friends

This commit should have no change in behavior.(*)

The observation was that Note [Recipe for checking a signature]
says that every metavariable in a type-checked type must either
  (A) be generalized
  (B) be promoted
  (C) be zapped.
Yet the code paths for doing these were all somewhat separate.
This led to some steps being skipped. This commit shores this
all up. The key innovation is TcHsType.kindGeneralizeSome, with
appropriate commentary.

This commit also sets the stage for #15809, by turning the
WARNing about bad level-numbers in generalisation into an
ASSERTion. The actual fix for #15809 will be in a separate
commit.

Other changes:
 * zonkPromoteType is now replaced by kindGeneralizeNone.
   This might have a small performance degradation, because
   zonkPromoteType zonked and promoted all at once. The new
   code path promotes first, and then zonks.

 * A call to kindGeneralizeNone was added in tcHsPartialSigType.
   I think this was a lurking bug, because it did not follow
   Note [Recipe for checking a signature]. I did not try to
   come up with an example showing the bug. This is the (*)
   above.

   Because of this change, there is an error message regression
   in partial-sigs/should_fail/T14040a. This problem isn't really
   a direct result of this refactoring, but is a symptom of
   something deeper. See #16775, which addresses the deeper
   problem.

 * I added a short-cut to quantifyTyVars, in case there's
   nothing to quantify.

 * There was a horribly-outdated Note that wasn't referred
   to. Gone now.

 * While poking around with T14040a, I discovered a small
   mistake in the Coercion.simplifyArgsWorker. Easy to fix,
   happily.

 * See new Note [Free vars in coercion hole] in TcMType.
   Previously, we were doing the wrong thing when looking
   at a coercion hole in the gather-candidates algorithm.
   Fixed now, with lengthy explanation.

Metric Decrease:
  T14683

- - - - -
f594a68a by Richard Eisenberg at 2019-09-19T09:04:03-04:00
Use level numbers for generalisation

This fixes #15809, and is covered in
Note [Use level numbers for quantification] in TcMType.

This patch removes the "global tyvars" from the
environment, a nice little win.

- - - - -
c675d08f by Richard Eisenberg at 2019-09-19T09:04:03-04:00
Test #17077.

- - - - -
912afaf4 by Ben Gamari at 2019-09-19T09:04:39-04:00
CoreUtils: Use mightBeUnliftedType in exprIsTopLevelBindable

Also add reference from isUnliftedType to mightBeUnliftedType.

- - - - -
baf47661 by Sebastian Graf at 2019-09-19T09:05:20-04:00
Extract PmTypes module from PmExpr and PmOracle

Apparently ghc-lib-parser's API blew up because the newly induced cyclic
dependency between TcRnTypes and PmOracle pulled in the other half of
GHC into the relevant strongly-connected component.

This patch arranges it so that PmTypes exposes mostly data type
definitions and type class instances to be used within PmOracle, without
importing the any of the possibly offending modules DsMonad, TcSimplify
and FamInst.

- - - - -
2a8867cf by Sebastian Graf at 2019-09-19T09:05:58-04:00
Add a regression test for #11822

The particular test is already fixed, but the issue seems to have
multiple different test cases lumped together.

- - - - -
52173990 by Ben Gamari at 2019-09-19T09:06:36-04:00
testsuite: Add testcase for #17206

- - - - -
b3e5c731 by Alp Mestanogullari at 2019-09-19T21:42:17-04:00
ErrUtils: split withTiming into withTiming and withTimingSilent

'withTiming' becomes a function that, when passed '-vN' (N >= 2) or
'-ddump-timings', will print timing (and possibly allocations) related
information. When additionally built with '-eventlog' and executed with
'+RTS -l', 'withTiming' will also emit both 'traceMarker' and 'traceEvent'
events to the eventlog.

'withTimingSilent' on the other hand will never print any timing information,
under any circumstance, and will only emit 'traceEvent' events to the eventlog.
As pointed out in !1672, 'traceMarker' is better suited for things that we
might want to visualize in tools like eventlog2html, while 'traceEvent'
is better suited for internal events that occur a lot more often and that we
don't necessarily want to visualize.

This addresses #17138 by using 'withTimingSilent' for all the codegen bits
that are expressed as a bunch of small computations over streams of codegen
ASTs.

- - - - -
4853d962 by Ben Gamari at 2019-09-19T21:42:55-04:00
users guide: Fix link to let generalization blog post

Fixes #17200.

- - - - -
51192964 by Sylvain Henry at 2019-09-20T05:14:34-04:00
Module hierarchy: Hs (#13009)

Add GHC.Hs module hierarchy replacing hsSyn.

Metric Increase:
    haddock.compiler

- - - - -
2f8ce45a by Ben Gamari at 2019-09-20T05:15:11-04:00
testsuite: Add test for #17202

- - - - -
f257bf73 by Matthew Pickering at 2019-09-20T05:15:52-04:00
hadrian/ghci.sh: Enable building in parallel

- - - - -
070f7b85 by Matthew Pickering at 2019-09-20T05:15:52-04:00
Remove trailing whitespace

- - - - -
5390b553 by Matthew Pickering at 2019-09-20T05:15:52-04:00
Pass -j to ghc-in-ghci CI job

- - - - -
1b7e1d31 by John Ericson at 2019-09-20T05:16:36-04:00
Remove pointless partiality in `Parser.ajs`

- - - - -
17554248 by Simon Peyton Jones at 2019-09-20T10:50:21+01:00
Fix PmOracle.addVarCoreCt in-scope set

PmOracle.addVarCoreCt was giving a bogus (empty) in-scope set to
exprIsConApp_maybe, which resulted in a substitution-invariant
failure (see MR !1647 discussion).

This patch fixes it, by taking the free vars of the expression.

- - - - -
0dad81ca by Simon Peyton Jones at 2019-09-20T10:50:21+01:00
Fix bogus type of case expression

Issue #17056 revealed that we were sometimes building a case
expression whose type field (in the Case constructor) was bogus.

Consider a phantom type synonym
   type S a = Int
and we want to form the case expression
   case x of K (a::*) -> (e :: S a)
We must not make the type field of the Case constructor be (S a)
because 'a' isn't in scope.  We must instead expand the synonym.

Changes in this patch:

* Expand synonyms in the new function CoreUtils.mkSingleAltCase.

* Use mkSingleAltCase in MkCore.wrapFloat, which was the proximate
  source of the bug (when called by exprIsConApp_maybe)

* Use mkSingleAltCase elsewhere

* Documentation
    CoreSyn   new invariant (6) in Note [Case expression invariants]
    CoreSyn   Note [Why does Case have a 'Type' field?]
    CoreUtils Note [Care with the type of a case expression]

* I improved Core Lint's error reporting, which was pretty
  confusing in this case, because it didn't mention that the offending
  type was the return type of a case expression.

* A little bit of cosmetic refactoring in CoreUtils

- - - - -
1ea8c451 by Sebastian Graf at 2019-09-21T09:52:34-04:00
PredType for type constraints in the pattern match checker instead of EvVar

Using EvVars for capturing type constraints implied side-effects in DsM
when we just wanted to *construct* type constraints.

But giving names to type constraints is only necessary when passing
Givens to the type checker, of which the majority of the pattern match
checker should be unaware.

Thus, we simply generate `newtype TyCt = TyCt PredType`, which are
nicely stateless. But at the same time this means we have to allocate
EvVars when we want to query the type oracle! So we keep the type oracle
state as `newtype TyState = TySt (Bag EvVar)`, which nicely makes a
distinction between new, unchecked `TyCt`s and the inert set in
`TyState`.

- - - - -
ded96fb3 by Ömer Sinan Ağacan at 2019-09-21T09:53:29-04:00
Document MIN_PAYLOAD_SIZE and mark-compact GC mark bits

This updates the documentation of the MIN_PAYLOAD_SIZE constant and adds
a new Note [Mark bits in mark-compact collector] explaning why the
mark-compact collector uses two bits per objet and why we need
MIN_PAYLOAD_SIZE.

- - - - -
a7867c79 by Sebastian Graf at 2019-09-21T14:56:58+01:00
Get rid of PmFake

The pattern match oracle can now cope with the abundance of information
that ViewPatterns, NPlusKPats, overloaded lists, etc. provide.

No need to have PmFake anymore!

Also got rid of a spurious call to `allCompleteMatches`, which we used to call
*for every constructor* match. Naturally this blows up quadratically for
programs like `ManyAlternatives`.

-------------------------
Metric Decrease:
    ManyAlternatives

Metric Increase:
    T11822
-------------------------

- - - - -
fa66e3e5 by Alp Mestanogullari at 2019-09-21T23:31:08-04:00
Fix haddocks for marker events in Debug.Trace
- - - - -
da12da79 by Daniel Gröber at 2019-09-22T14:34:56+02:00
rts: retainer: Remove cStackSize debug counter

This can only ever be one since 5f1d949ab9 ("Remove explicit recursion in
retainer profiling"), so it's pointless.

- - - - -
3ebaa4b5 by Daniel Gröber at 2019-09-22T15:17:53+02:00
rts: Remove bitrotten retainer debug code

The `defined(DEBUG_RETAINER) == true` branch doesn't even compile anymore
because 1) retainerSet was renamed to RetainerSet and 2) even if I fix that
the context in Rts.h seems to have changed such that it's not in scope. If
3) I fix that 'flip' is still not in scope :)  At that point I just gave up.

- - - - -
63023dc2 by Daniel Gröber at 2019-09-22T15:18:09+02:00
rts: Fix outdated references to 'ldvTime'

This got renamed to 'era' in dbef766ce7 ("[project @ 2001-11-26 16:54:21 by
simonmar] Profiling cleanup").

- - - - -
ead05f80 by Daniel Gröber at 2019-09-22T15:18:09+02:00
rts: retainer: Turn global traversal state into a struct

Global state is ugly and hard to test. Since the profiling code isn't quite
as performance critical as, say, GC we should prefer better code here.

I would like to move the 'flip' bit into the struct too but that's
complicated by the fact that the defines which use it directly are also
called from ProfHeap where the traversalState is not easily
available. Maybe in a future commit.

- - - - -
94ecdb4f by Daniel Gröber at 2019-09-22T15:18:10+02:00
rts: retainer: Move info.next.parent to stackElement

I don't see a point in having this live in 'info', just seems to make the
code more complicated.

- - - - -
f79ac2ef by Daniel Gröber at 2019-09-22T15:18:10+02:00
rts: retainer: Generalise per-stackElement data

This essentially ammounts to s/retainer/stackData/, s/c_child_r/data/ and
some temporary casting of c_child_r to stackData until refactoring of this
module is completed by a subsequent commit. We also introduce a new union
'stackData' which will contain the actual extra data to be stored on the
stack.

The idea is to make the heap traversal logic of the retainer profiler ready
for extraction into it's own module. So talking about "retainers" there
doesn't really make sense anymore.

Essentially the "retainers" we store in the stack are just data associated
with the push()ed closures which we return when pop()ing it.

- - - - -
f083358b by Daniel Gröber at 2019-09-22T15:18:10+02:00
rts: retainer: Fix comment typo s/keeps/keep/

- - - - -
2f2f6dd5 by Daniel Gröber at 2019-09-22T15:18:10+02:00
rts: Generalise profiling heap traversal flip bit handling

This commit starts renaming some flip bit related functions for the
generalised heap traversal code and adds provitions for sharing the
per-closure profiling header field currently used exclusively for retainer
profiling with other heap traversal profiling modes.

- - - - -
e40b3c23 by Daniel Gröber at 2019-09-22T15:18:10+02:00
rts: GC: Remove redundant #include "RetainerProfiler.h"

- - - - -
b03db9da by Daniel Gröber at 2019-09-22T15:18:10+02:00
rts: retainer: Pull retainer specific code into a callback

This essentially turns the heap traversal code into a visitor. You add a
bunch of roots to the work-stack and then the callback you give to
traverseWorkStack() will be called with every reachable closure at least
once.

- - - - -
48e816f0 by Daniel Gröber at 2019-09-22T15:18:10+02:00
rts: retainer: simplify pop() control flow

Instead of breaking out of the switch-in-while construct using `return` this
uses `goto out` which makes it possible to share a lot of the out-variable
assignment code in all the cases.

I also replaced the nasty `while(true)` business by the real loop
condition: `while(*c == NULL)`. All `break` calls inside the switch aready
have either a check for NULL or an assignment of `c` to NULL so this should
not change any behaviour.

Using `goto out` also allowed me to remove another minor wart: In the
MVAR_*/WEAK cases the popOff() call used to happen before reading the
stackElement. This looked like a use-after-free hazard to me as the stack
is allocated in blocks and depletion of a block could mean it getting freed
and possibly overwritten by zero or garbage, depending on the block
allocator's behaviour.

- - - - -
b92ed68a by Daniel Gröber at 2019-09-22T15:18:10+02:00
rts: Add note reference to SET_PROF_HDR for profiling 'flip' bit

- - - - -
f3bb7397 by Daniel Gröber at 2019-09-22T15:18:10+02:00
rts: RetainerSet: Remove obsolete fist/second-approach choice

In the old code when DEBUG_RETAINER was set, FIRST_APPROACH is
implied. However ProfHeap.c now depends on printRetainerSetShort which is
only available with SECOND_APPROACH. This is because with FIRST_APPROACH
retainerProfile() will free all retainer sets before returning so by the
time ProfHeap calls dumpCensus the retainer set pointers are segfaulty.

Since all of this debugging code obviously hasn't been compiled in ages
anyways I'm taking the liberty of just removing it.

Remember guys: Dead code is a liability not an asset :)

- - - - -
ec1d76e2 by Daniel Gröber at 2019-09-22T15:18:10+02:00
rts: retainer: Remove obsolete debug code

Commit dbef766ce7 ("Profiling cleanup.") made this debug code obsolete by
removing the 'cost' function without a replacement. As best I can tell the
retainer profiler used to do some heap census too and this debug code was
mainly concerned with that.

- - - - -
b7e15d17 by Daniel Gröber at 2019-09-22T15:18:10+02:00
rts: retainer: Rename heap traversal functions for extraction

This gets all remaining functions in-line with the new 'traverse' prefix
and module name.

- - - - -
64ec45a7 by Daniel Gröber at 2019-09-22T15:18:10+02:00
rts: retainer: Reduce DEBUG_RETAINER ifdef noise

Keeping track of the maximum stack seems like a good idea in all
configurations. The associated ASSERTs only materialize in debug mode but
having the statistic is nice.

To make the debug code less prone to bitrotting I introduce a function
'debug()' which doesn't actually print by default and is #define'd away
only when the standard DEBUG define is off.

- - - - -
bd78b696 by Daniel Gröber at 2019-09-22T15:18:10+02:00
rts: retainer: Cleanup comments and strings for traversal extraction

A lot of comments and strings are still talking about old names, fix
that.

- - - - -
cb7220b3 by Daniel Gröber at 2019-09-22T15:18:10+02:00
rts: retainer: Remove outdated invariants on traversePushStack

These invariants don't seem to make any sense in the current code.  The
text talks about c_child_r as if it were an StgClosure, for which RSET()
would make sense, but it's a retainer aka 'CostCentreStack*'.

- - - - -
bb92660c by Daniel Gröber at 2019-09-22T15:18:10+02:00
rts: retainer: Use global STATIC_INLINE macro

STATIC_INLINE already does what the code wanted here, no need to duplicate
the functionality here.

- - - - -
2b76cf9e by Daniel Gröber at 2019-09-22T15:18:10+02:00
rts: retainer: Move heap traversal declarations to new header

- - - - -
44d5cc0d by Daniel Gröber at 2019-09-22T15:18:10+02:00
rts: retainer: Abstract maxStackSize for generic traversal

- - - - -
fd213d17 by Daniel Gröber at 2019-09-22T15:18:10+02:00
rts: retainer: Update obsolete docs for traverseMaybeInitClosureData

- - - - -
39f2878c by Daniel Gröber at 2019-09-22T15:18:10+02:00
rts: retainer: Move actual 'flip' bit flip to generic traversal code

- - - - -
f9b4c4f2 by Daniel Gröber at 2019-09-22T15:18:10+02:00
rts: retainer: Remove traverse-stack chunk support

There's simply no need anymore for this whole business. Instead of
individually traversing roots in retainRoot() we just push them all onto
the stack and traverse everything in one go.

This feature was not really used anyways. There is an
`ASSERT(isEmptyWorkStack(ts))` at the top of retainRoot() which means there
really can't ever have been any chunks at the toplevel.

The only place where this was probably used is in traversePushStack but
only way back when we were still using explicit recursion on the
C callstack.

Since the code was changed to use an explicit traversal-stack these
stack-chunks can never escape one call to traversePushStack anymore.  See
commit 5f1d949ab9 ("Remove explicit recursion in retainer profiling")

- - - - -
c7def600 by Daniel Gröber at 2019-09-22T15:18:10+02:00
rts: retainer: Move mut_list reset to generic traversal code

- - - - -
9bf27060 by Daniel Gröber at 2019-09-22T15:18:10+02:00
rts: retainer: Make visit callback easier to implement

Currently it is necessary for user code to expend at least one extra bit in
the closure header just to know whether visit() should return true or
false, to indicate if children should be traversed.

The generic traversal code already has this information in the visited bit
so simply pass it to the visit callback.

- - - - -
96adf179 by Daniel Gröber at 2019-09-22T15:18:10+02:00
rts: retainer: Improve Note [Profiling heap traversal visited bit]

- - - - -
187192a6 by Daniel Gröber at 2019-09-22T15:18:10+02:00
rts: RetainerProfile.c: Re-enable and fix warnings

Turns out some genius disabled warnings for RetainerProfile.c in the build
system. That would have been good to know about five silent type mismatch
crashes ago.. :)

- - - - -
eb29735e by Daniel Gröber at 2019-09-22T15:18:10+02:00
rts: RetainerProfile.c: Minimize #includes

A lot of these includes are presumably leftovers from when the retainer
profiler still did it's own heap profiling.

- - - - -
383f9089 by Daniel Gröber at 2019-09-22T15:18:10+02:00
rts: Split heap traversal from retainer profiler

This finally moves the newly generalised heap traversal code from the
retainer profiler into it's own file.

- - - - -
52c5ea71 by Daniel Gröber at 2019-09-22T15:18:10+02:00
rts: TraverseHeap: Make comment style consistent

- - - - -
75355228 by Daniel Gröber at 2019-09-22T15:18:10+02:00
rts: TraverseHeap: Make pushStackElement argument const

- - - - -
a8137780 by Daniel Gröber at 2019-09-22T15:18:10+02:00
rts: TraverseHeap: Move stackElement.cp back into nextPos union

The 'cp' field really is only used when type==posTypeFresh so it's more
space efficient to have it in the nextPos union.

- - - - -
7f10cc2d by Daniel Gröber at 2019-09-22T15:18:10+02:00
rts: RetainerProfile: Explain retainVisitClosure return values

[ci skip]

- - - - -
111f2761 by Daniel Gröber at 2019-09-22T15:33:41+02:00
rts: TraverseHeap: Add doc comment for getTraverseStackMaxSize

- - - - -
68ddb43c by Ben Gamari at 2019-09-23T00:34:00-04:00
gitlab-ci: Fix URL of Windows cabal-install tarball

- - - - -
0e478407 by Takenobu Tani at 2019-09-23T17:51:37-04:00
users-guide: Fix links and formats for GHC 8.10

This commit only fixes links and markdown syntax.

[skip ci]

- - - - -
74631bbc by Adam Sandberg Eriksson at 2019-09-23T17:52:32-04:00
base: add newtypes for socklen_t and ndfs_t to System.Posix.Types #16568

Metric Increase:
    haddock.base
    T4029

- - - - -
4470a144 by Björn Gohla at 2019-09-23T17:53:23-04:00
add Hadrian rule to build user guide as Info book

- - - - -
dbbea5a8 by Björn Gohla at 2019-09-23T17:53:23-04:00
use the Make builder instead of raw cmd_

- - - - -
b0e3b173 by Björn Gohla at 2019-09-23T17:53:23-04:00
detect makeinfo in configure(.ac)

- - - - -
9fe4d2df by Björn Gohla at 2019-09-23T17:53:23-04:00
explicit dependence on makeinfo

- - - - -
b650c2b6 by Björn Gohla at 2019-09-23T17:53:23-04:00
alphabetical ordering

- - - - -
27789294 by Björn Gohla at 2019-09-23T17:53:23-04:00
sort-paragraphs in runBuilderWith

- - - - -
d0c2f3a2 by Artem Pyanykh at 2019-09-23T17:54:04-04:00
[hadrian] Rebuild programs on dynamicGhcPrograms/ghcProfiled change

Currently, if you change these ^ flavour parameters, rebuilding is not
triggered, since `programContext` doesn't set up a dependency on
those values.

Exposing these values via an oracle does set the dependency and
properly triggers a rebuild of binaries.

Several attempts to factor out these actions ended up in cyclic
dependency here or there. I'm not absolutely happy with this variant
either, but at least it works.

====

Issue repro:

In UserSettings.hs:
```
dbgDynamic = defaultFlavour { name = "dbg-dynamic"
                            , dynamicGhcPrograms = pure True,
                            ... }

dbgStatic = defaultFlavour { name = "dbg-static"
                           , dynamicGhcPrograms = pure False
                           ... }
```

Then in console:

```
$ hadrian/build.sh -j --flavour=dbg-dynamic
... does the build
$ hadrian/build.sh -j --flavour=dbg-static
... does nothing, considers binaries up to date
```

- - - - -
238b58e4 by Kari Pahula at 2019-09-23T17:54:42-04:00
Add -fkeep-going to make compiler continue despite errors (#15424)

Add a new optional failure handling for upsweep which continues
the compilation on other modules if any of them has errors.

- - - - -
146f26cc by Sebastian Graf at 2019-09-24T01:06:40-04:00
Some leftovers from !1732. Comments only [skip ci]

- - - - -
b5f24fb4 by Takenobu Tani at 2019-09-24T01:07:19-04:00
Hadrian: Add -haddock option for GHCi's :doc command

This commit adds -haddock option to Hadrian-based build system.

To enable :doc command on GHCi, core libraries must be compiled
with -haddock option.
Especially, the `-haddock` option is essential for a release build.

Assuming current GitLab CI condition (.gitlab-ci.yml),
I add -haddock option to the default flavour only.

This has already been done for Make-based build system.
Please see #16415.

- - - - -
f97a7aac by Sebastian Graf at 2019-09-24T01:07:57-04:00
Fix some duplication in the parser

D3673 experienced reduce/reduce conflicts when trying to use
opt_instance for associated data families.

That was probably because the author tried to use it for
Haskell98-syntax without also applying it to GADT-syntax, which actually
leads to a reduce/reduce conflict. Consider the following state:

```
data . T = T
data . T where T :: T
```

The parser must decide at this point whether or not to reduce an empty
`opt_instance`. But doing so would also commit to either
Haskell98 or GADT syntax! Good thing we also accept an optional
"instance" for GADT syntax, so the `opt_instance` is there in both
productions and there's no reduce/reduce conflict anymore.

Also no need to inline `opt_instance`, how it used to be.

- - - - -
b23f01fd by Ben Gamari at 2019-09-24T08:49:43-04:00
base: Add link to "A reflection on types"

Fixes #17181.

- - - - -
4bbe0dba by Ben Gamari at 2019-09-24T08:50:20-04:00
gitlab-ci: Bump ci-images

This bumps the CI Docker images to
ghc/ci-images at 990c5217d1d0e03aea415f951afbc3b1a89240c6.

- - - - -
6bca867c by Ben Gamari at 2019-09-24T08:50:59-04:00
hadrian: Update source-repository
- - - - -
b2d47536 by Ben Gamari at 2019-09-24T08:51:45-04:00
testsuite: Mark threadstatus-9333 as fragile in profthreaded

Due to #16555.

- - - - -
ed520678 by Andreas Klebinger at 2019-09-24T21:08:42-04:00
Fix bounds check in ocResolve_PEi386 for relocation values.

The old test was wrong at least for gcc and the value -2287728808L.

It also relied on implementation defined behaviour (right shift
on a negative value), which might or might not be ok.
Either way it's now a simple comparison which will always work.

- - - - -
218c5dbf by Matthew Pickering at 2019-09-24T21:09:23-04:00
Add ghcide configuration files

This commit adds three new files

1. A hie.yaml file to the project root which specifies to IDEs how to
set up the correct environment for loading GHC. This currently
specifies to call the `./hadrian/hie-bios` script.
2. A `hie.yaml` file for the hadrian subcomponent, which uses the
`cabal` cradle type.
2. The `./hadrian/hie-bios` script which supplies the correct arguments
for an IDE to start a session.

With these two files it is possible to run

```
ghcide compiler/
```

and successfully load all the modules for use in the IDE.

or

```
ghcide --cwd hadrian/ src/
```

to test loading all of Hadrian's modules.

Closes #17194

- - - - -
2970dc7a by Kari Pahula at 2019-09-25T13:52:48-04:00
Add -Wderiving-defaults (#15839)

Enabling both DeriveAnyClass and GeneralizedNewtypeDeriving can cause
a warning when no explicit deriving strategy is in use. This change adds
an enable/suppress flag for it.

- - - - -
4540bbe2 by John Ericson at 2019-09-25T13:53:42-04:00
includes/CodeGen.Platform.hs don't include ghcautoconf.h

It doesn't need it, and it shouldn't need it or else multi-target will
break.

- - - - -
ebc65025 by Sebastian Graf at 2019-09-25T13:54:22-04:00
PmCheck: Only ever check constantly many models against a single pattern

Introduces a new flag `-fmax-pmcheck-deltas` to achieve that. Deprecates
the old `-fmax-pmcheck-iter` mechanism in favor of this new flag.

>From the user's guide:

Pattern match checking can be exponential in some cases. This limit makes sure
we scale polynomially in the number of patterns, by forgetting refined
information gained from a partially successful match. For example, when
matching `x` against `Just 4`, we split each incoming matching model into two
sub-models: One where `x` is not `Nothing` and one where `x` is `Just y` but
`y` is not `4`. When the number of incoming models exceeds the limit, we
continue checking the next clause with the original, unrefined model.

This also retires the incredibly hard to understand "maximum number of
refinements" mechanism, because the current mechanism is more general
and should catch the same exponential cases like PrelRules at the same
time.

-------------------------
Metric Decrease:
    T11822
-------------------------

- - - - -
d90d0bad by Ben Gamari at 2019-09-25T13:55:09-04:00
base: Move Ix typeclass to GHC.Ix

The `Ix` class seems rather orthogonal to its original home in
`GHC.Arr`.

- - - - -
795986aa by Ryan Scott at 2019-09-25T13:56:07-04:00
Remove unneeded CPP now that GHC 8.6 is the minimum

The minimum required GHC version for bootstrapping is 8.6, so we can
get rid of some unneeded `#if `__GLASGOW_HASKELL__` CPP guards, as
well as one `MIN_VERSION_ghc_prim(0,5,3)` guard (since GHC 8.6 bundles
`ghc-prim-0.5.3`).

- - - - -
0b5eede9 by Vladislav Zavialov at 2019-09-25T21:06:04+03:00
Standalone kind signatures (#16794)

Implements GHC Proposal #54: .../ghc-proposals/blob/master/proposals/0054-kind-signatures.rst

With this patch, a type constructor can now be given an explicit
standalone kind signature:

  {-# LANGUAGE StandaloneKindSignatures #-}
  type Functor :: (Type -> Type) -> Constraint
  class Functor f where
    fmap :: (a -> b) -> f a -> f b

This is a replacement for CUSKs (complete user-specified
kind signatures), which are now scheduled for deprecation.

User-facing changes
-------------------

* A new extension flag has been added, -XStandaloneKindSignatures, which
  implies -XNoCUSKs.

* There is a new syntactic construct, a standalone kind signature:

    type <name> :: <kind>

  Declarations of data types, classes, data families, type families, and
  type synonyms may be accompanied by a standalone kind signature.

* A standalone kind signature enables polymorphic recursion in types,
  just like a function type signature enables polymorphic recursion in
  terms. This obviates the need for CUSKs.

* TemplateHaskell AST has been extended with 'KiSigD' to represent
  standalone kind signatures.

* GHCi :info command now prints the kind signature of type constructors:

    ghci> :info Functor
    type Functor :: (Type -> Type) -> Constraint
    ...

Limitations
-----------

* 'forall'-bound type variables of a standalone kind signature do not
  scope over the declaration body, even if the -XScopedTypeVariables is
  enabled. See #16635 and #16734.

* Wildcards are not allowed in standalone kind signatures, as partial
  signatures do not allow for polymorphic recursion.

* Associated types may not be given an explicit standalone kind
  signature. Instead, they are assumed to have a CUSK if the parent class
  has a standalone kind signature and regardless of the -XCUSKs flag.

* Standalone kind signatures do not support multiple names at the moment:

    type T1, T2 :: Type -> Type   -- rejected
    type T1 = Maybe
    type T2 = Either String

  See #16754.

* Creative use of equality constraints in standalone kind signatures may
  lead to GHC panics:

    type C :: forall (a :: Type) -> a ~ Int => Constraint
    class C a where
      f :: C a => a -> Int

  See #16758.

Implementation notes
--------------------

* The heart of this patch is the 'kcDeclHeader' function, which is used to
  kind-check a declaration header against its standalone kind signature.
  It does so in two rounds:

    1. check user-written binders
    2. instantiate invisible binders a la 'checkExpectedKind'

* 'kcTyClGroup' now partitions declarations into declarations with a
  standalone kind signature or a CUSK (kinded_decls) and declarations
  without either (kindless_decls):

    * 'kinded_decls' are kind-checked with 'checkInitialKinds'
    * 'kindless_decls' are kind-checked with 'getInitialKinds'

* DerivInfo has been extended with a new field:

    di_scoped_tvs :: ![(Name,TyVar)]

  These variables must be added to the context in case the deriving clause
  references tcTyConScopedTyVars. See #16731.

- - - - -
4f81fab0 by Ryan Scott at 2019-09-26T14:04:38-04:00
Make -fbyte-code prevent unboxed tuples/sums from implying object code (#16876)

This resolves #16876 by making the explicit use of `-fbyte-code`
prevent code that enables `UnboxedTuples` or `UnboxedSums` from
automatically compiling to object code. This allows for a nice
middle ground where most code that enables `UnboxedTuples`/-`Sums`
will still benefit from automatically enabling `-fobject-code`, but
allows power users who wish to avoid this behavior in certain corner
cases (such as `lens`, whose use case is documented in #16876) to do
so.

Along the way, I did a little cleanup of the relevant code and
documentation:

* `enableCodeGenForUnboxedTuples` was only checking for the presence
  of `UnboxedTuples`, but `UnboxedSums` has the same complications.
  I fixed this and renamed the function to
  `enableCodeGenForUnboxedTuplesOrSums`.
* I amended the users' guide with a discussion of these issues.

- - - - -
289fc8da by Sebastian Graf at 2019-09-27T22:10:17-04:00
PmCheck: Elaborate what 'model' means in the user guide [skip ci]

- - - - -
9c02a793 by Ron Mordechai at 2019-09-27T22:11:06-04:00
Allow users to disable Unicode with an env var

Unicode renders funny on my terminal and I like to avoid it where
possible. Most applications which print out non-ascii characters allow
users to disable such prints with an environment variable (e.g.
Homebrew).

This diff disables Unicode usage when the environment variable
`GHC_NO_UNICODE` is set. To test, set the env var and compile a bad
program. Note that GHC does not print Unicode bullets but instead prints
out asterisks:

```
$ GHC_NO_UNICODE= _build/stage1/bin/ghc ../Temp.hs
[1 of 1] Compiling Temp             ( ../Temp.hs, ../Temp.o )

../Temp.hs:4:23: error:
    * Couldn't match type `Bool' with `a -> Bool'
      Expected type: Bool -> a -> Bool
        Actual type: Bool -> Bool
    * In the first argument of `foldl', namely `(&& (flip $ elem u))'
      In the expression: foldl (&& (flip $ elem u)) True v
      In an equation for `isPermut':
          isPermut u v = foldl (&& (flip $ elem u)) True v
    * Relevant bindings include
        v :: [a] (bound at ../Temp.hs:4:12)
        u :: [a] (bound at ../Temp.hs:4:10)
        isPermut :: [a] -> [a] -> Bool (bound at ../Temp.hs:4:1)
  |
4 | isPermut u v = foldl (&& (flip $ elem u)) True v
  |                       ^^^^^^^^^^^^^^^^^^
```

(Broken code taken from Stack Overflow)

- - - - -
144abba3 by Ben Gamari at 2019-09-27T22:11:53-04:00
configure: Don't depend upon alex in source dist build

This fixes #16860 by verifying that the generated sources don't already
exist before asserting that the `alex` executable was found. This
replicates the logic already used for `happy` in the case of `alex`.

- - - - -
c6fb913c by John Ericson at 2019-09-27T22:12:35-04:00
Just get RTS libs from its package conf

`rts.conf` already contains this exact information in its
`extra-libraries` stanza.

- - - - -
f07862b4 by Ben Gamari at 2019-09-27T22:13:16-04:00
ghc-prim: Fix documentation of Type

As pointed out in #17243, `Type` is not the only kind
having values.
- - - - -
0201d0bf by chris-martin at 2019-09-27T22:14:00-04:00
Clarify the purpose and status of the GHC.TypeLits module
- - - - -
444e554f by chris-martin at 2019-09-27T22:14:00-04:00
Expand description of DataKinds to mention data constructors, and include mention of TypeError
- - - - -
1582dafa by Sebastian Graf at 2019-09-27T22:14:44-04:00
PmCheck: Look at precendence to give type signatures to some wildcards

Basically do what we currently only do for -XEmptyCase in other cases
where adding the type signature won't distract from pattern
matches in other positions.

We use the precedence to guide us, equating "need to parenthesise" with
"too much noise".

- - - - -
ad0c4390 by Shayne Fletcher at 2019-09-27T22:15:27-04:00
Add test for expected dependencies of 'Parser'

- - - - -
0b1fa64d by Ben Gamari at 2019-09-27T22:16:04-04:00
testsuite: Mark cgrun071 as broken on i386

As described in #17247.

- - - - -
24620182 by Daniel Gröber at 2019-09-27T22:17:04-04:00
Raise minimum GHC version to 8.6

commit 795986aaf33e ("Remove unneeded CPP now that GHC 8.6 is the minimum")
broke the 8.4 build.

- - - - -
e0bbb961 by Ben Gamari at 2019-09-27T22:17:44-04:00
testsuite: Mark compact_gc as fragile in the ghci way

As noted in #17253.

- - - - -
bb984ac6 by Ben Gamari at 2019-09-27T22:18:42-04:00
testsuite: Mark hs_try_putmvar003 as fragile in threaded1

Due to #16361. Note that I'm leaving out threaded2 since it's not clear
whether the single crash in that way was due to other causes.

- - - - -
ad2a1f99 by Ben Gamari at 2019-09-27T22:19:26-04:00
testsuite: Mark T3389 as broken in profiled ways on i386

As noted in #17256.

- - - - -
6f9fa0be by Ben Gamari at 2019-09-27T22:20:04-04:00
testsuite: Mark TH tests as fragile in LLVM built external-interpreter

Due to #16087. This drops the previous explicit list of broken tests and rather
encompasses the entire set of tests since they all appear to be broken.

- - - - -
c5d888d4 by Sebastian Graf at 2019-09-28T17:11:41-04:00
PmCheck: No ConLike instantiation in pmcheck

`pmcheck` used to call `refineToAltCon` which would refine the knowledge
we had about a variable by equating it to a `ConLike` application.
Since we weren't particularly smart about this in the Check module, we
simply freshened the constructors existential and term binders utimately
through a call to `mkOneConFull`.

But that instantiation is unnecessary for when we match against a
concrete pattern! The pattern will already have fresh binders and field
types. So we don't call `refineToAltCon` from `Check` anymore.

Subsequently, we can simplify a couple of call sites and functions in
`PmOracle`. Also implementing `computeCovered` becomes viable and we
don't have to live with the hack that was `addVarPatVecCt` anymore.

A side-effect of not indirectly calling `mkOneConFull` anymore is that
we don't generate the proper strict argument field constraints anymore.
Instead we now desugar ConPatOuts as if they had bangs on their strict
fields. This implies that `PmVar` now carries a `HsImplBang` that we
need to respect by a (somewhat ephemeral) non-void check. We fix #17234
in doing so.

- - - - -
ce64b397 by Sebastian Graf at 2019-09-28T17:12:26-04:00
`exprOkForSpeculation` for Note [IO hack in the demand analyser]

In #14998 I realised that the notion of speculative execution
*exactly matches* eager evaluation of expressions in a case alternative
where the scrutinee is an IO action.

Normally we have to `deferIO` any result from that single case
alternative to prevent this speculative execution, so we had a special
case in place in the demand analyser that would check if the scrutinee
was a prim-op, in which case we assumed that it would be ok to do the
eager evaluation.

Now we just check if the scrutinee is `exprOkForSpeculation`,
corresponding to the notion that we want to push evaluation of the
scrutinee *after* eagerly evaluating stuff from the case alternative.

This fixes #14988, because it resolves the last open Item 4 there.

- - - - -
f3cb8c7c by Ömer Sinan Ağacan at 2019-09-30T22:39:53-04:00
Refactor iface file generation:

This commit refactors interface file generation to allow information
from the later passed (NCG, STG) to be stored in interface files.

We achieve this by splitting interface file generation into two parts:
* Partial interfaces, built based on the result of the core pipeline
* A fully instantiated interface, which also contains the final
fingerprints and can optionally contain information produced by the backend.

This change is required by !1304 and !1530.

-dynamic-too handling is refactored too: previously when generating code
we'd branch on -dynamic-too *before* code generation, but now we do it
after.

(Original code written by @AndreasK in !1530)

Performance
~~~~~~~~~~~

Before this patch interface files where created and immediately flushed
to disk which made space leaks impossible.
With this change we instead use NFData to force all iface related data
structures to avoid space leaks.

In the process of refactoring it was discovered that the code in the
ToIface Module allocated a lot of thunks which were immediately forced
when writing/forcing the interface file. So we made this module more
strict to avoid creating many of those thunks.

Bottom line is that allocations go down by about ~0.1% compared to
master.
Residency is not meaningfully different after this patch.
Runtime was not benchmarked.

Co-Authored-By: Andreas Klebinger <klebinger.andreas at gmx.at>
Co-Authored-By: Ömer Sinan Ağacan <omer at well-typed.com>

- - - - -
6a1700aa by Simon Peyton Jones at 2019-09-30T22:40:30-04:00
Fix arguments for unbound binders in RULE application

We were failing to correctly implement Note [Unbound RULE binders]
in Rules.hs.  In particular, when cooking up a fake Refl,
were were failing to apply the substitition.

This patch fixes that problem, and simultaneously tidies
up the impedence mis-match between RuleSubst and TCvSubst.

Thanks to Sebastian!

- - - - -
97811ef5 by Takenobu Tani at 2019-09-30T22:41:35-04:00
Add help message for GHCi :instances command

This commit updates GHCi's help message for GHC 8.10.

- - - - -
6f8550a3 by Sebastian Graf at 2019-09-30T22:42:14-04:00
Move pattern match checker modules to GHC.HsToCore.PmCheck

- - - - -
b36dd49b by Takenobu Tani at 2019-09-30T22:42:53-04:00
testsuite: Add minimal test for :doc command

Currently, there are no testcases for GHCi `:doc` command.
Perhaps because it was experimental. And it could be changed in the future.

But `:doc` command is already useful, so I add a minimal regression test
to keep current behavior.

See also 85309a3cda for implementation of `:doc` command.

- - - - -
bdba6ac2 by Vladislav Zavialov at 2019-09-30T22:43:31-04:00
Do not rely on CUSKs in 'base'

Use standalone kind signatures instead of complete user-specified kinds
in Data.Type.Equality and Data.Typeable

- - - - -
dbdf6a3d by Ben Gamari at 2019-09-30T22:44:07-04:00
testsuite: Mark T3389 as broken in hpc way on i386

See #17256.

- - - - -
822481d5 by Ben Gamari at 2019-09-30T22:44:44-04:00
Bump process submodule

Marks process003 as fragile, as noted in #17245.

- - - - -
6548b7b0 by Sebastian Graf at 2019-10-01T09:22:10+00:00
Add a bunch of testcases for the pattern match checker

Adds regression tests for tickets #17207, #17208, #17215, #17216,
 #17218, #17219, #17248

- - - - -
58013220 by Sebastian Graf at 2019-10-01T09:22:18+00:00
Add testcases inspired by Luke Maranget's pattern match series

In his paper "Warnings for Pattern Matching", Luke Maranget describes
three series in his appendix for which GHC's pattern match checker
scaled very badly. We mostly avoid this now with !1752. This commit adds
regression tests for each of the series.

Fixes #17264.

- - - - -
9c002177 by Ryan Scott at 2019-10-01T16:24:12-04:00
Refactor some cruft in TcDeriv

* `mk_eqn_stock`, `mk_eqn_anyclass`, and `mk_eqn_no_mechanism` all
  took a continuation of type
  `DerivSpecMechanism -> DerivM EarlyDerivSpec` to represent its
  primary control flow. However, in practice this continuation was
  always instantiated with the `mk_originative_eqn` function, so
  there's not much point in making this be a continuation in the
  first place.

  This patch removes these continuations in favor of invoking
  `mk_originative_eqn` directly, which is simpler.
* There were several parts of `TcDeriv` that took different code
  paths if compiling an `.hs-boot` file. But this is silly, because
  ever since 101a8c770b9d3abd57ff289bffea3d838cf25c80 we simply error
  eagerly whenever attempting to derive any instances in an
  `.hs-boot` file.

  This patch removes all of the unnecessary `.hs-boot` code paths,
  leaving only one (which errors out).
* Remove various error continuation arguments from `mk_eqn_stock`
  and related functions.

- - - - -
9a27a063 by David Eichmann at 2019-10-01T16:55:33-04:00
Hadrian: Libffi rule now `produces` dynamic library files.

- - - - -
0956c194 by David Eichmann at 2019-10-01T16:55:33-04:00
Hadrian: do not cache GHC configure rule

- - - - -
8924224e by Ömer Sinan Ağacan at 2019-10-01T16:55:37-04:00
Make small INLINE functions behave properly

Simon writes:

Currently we check for a type arg rather than isTyCoArg.   This in turn
makes INLINE things look bigger than they should be, and stops them
being inlined into boring contexts when they perfectly well could be.
E.g.

    f x = g <refl> x
    {-# INLINE g #-}

    ... (map (f x) xs) ...

The context is boring, so don't inline unconditionally.  But f's RHS is
no bigger than its call, provided you realise that the coercion argument
is ultimately cost-free.

This happens in practice for $WHRefl. It's not a big deal: at most it
means we have an extra function call overhead.  But it's untidy, and
actually worse than what happens without an INLINE pragma.

Fixes #17182

This makes 0.0% change in nofib binary sizes.

- - - - -
53b0c6e0 by Gabor Greif at 2019-10-03T08:15:50-04:00
Typo in comment [ci skip]
- - - - -
60229e9e by Ryan Scott at 2019-10-03T12:17:10-04:00
Merge TcTypeableValidity into TcTypeable, document treatment of casts

This patch:

* Implements a refactoring (suggested in
  https://gitlab.haskell.org/ghc/ghc/merge_requests/1199#note_207345)
  that moves all functions from `TcTypeableValidity` back to
  `TcTypeable`, as the former module doesn't really need to live on its
  own.
* Adds `Note [Typeable instances for casted types]` to `TcTypeable`
  explaining why the `Typeable` solver currently does not support
  types containing casts.

Resolves #16835.

- - - - -
3b9d4907 by Richard Eisenberg at 2019-10-03T12:17:13-04:00
Note [Don't flatten tuples from HsSyn] in MkCore

Previously, we would sometimes flatten 1-tuples and sometimes
not. This didn't cause damage because there is no way to
generate HsSyn with 1-tuples. But, with the upcoming fix to #16881,
there will be. Without this patch, obscure lint errors would
have resulted.

No test case, as there is not yet a way to tickle this.

- - - - -
8a254d6b by Ömer Sinan Ağacan at 2019-10-03T12:17:19-04:00
Fix new compact block allocation in allocateForCompact

allocateForCompact() is called when nursery of a compact region is
full, to add new blocks to the compact. New blocks added to an existing
region needs a StgCompactNFDataBlock header, not a StgCompactNFData.

This fixes allocateForCompact() so that it now correctly allocates space
for StgCompactNFDataBlock instead of StgCompactNFData as before.

Fixes #17044.

A regression test T17044 added.

- - - - -
3c7b172b by James Brock at 2019-10-03T12:17:24-04:00
docs String, hyperlink to Data.List

Add a reference to the documentation for Data.List in the description
for String.

On the generated Haddock for Data.String,

http://hackage.haskell.org/package/base-4.12.0.0/docs/Data-String.html

there is curently no hyperlink to Data.List, which is where a reader will find most of the useful functions which can operate on Strings. I imagine this has confused beginners who came to this page looking for String operations.

- - - - -
67bf734c by John Ericson at 2019-10-03T12:17:28-04:00
Add `module {-# SOURCE #-} Foo` syntax for hs-boot in bkp

This is a good convenience for testing.

- - - - -
6655ec73 by Richard Eisenberg at 2019-10-03T12:17:30-04:00
Improve documentation around empty tuples/lists

This patch also changes the way we handle empty lists, simplifying
them somewhat. See Note [Empty lists]. Previously, we had to
special-case empty lists in the type-checker. Now no more!

Finally, this patch improves some documentation around the ir_inst
field used in the type-checker.

This breaks a test case, but I really think the problem is #17251,
not really related to this patch.

Test case: typecheck/should_compile/T13680

- - - - -
9a4ff210 by John Ericson at 2019-10-03T12:17:31-04:00
Make Haddock submodule remote point to gitlab mirror

This makes it match the others

- - - - -
cb364bc2 by Ben Gamari at 2019-10-03T12:17:32-04:00
testsuite:  Mark print037 as fragile, not broken

See #16205.

- - - - -
259f4dff by Ben Gamari at 2019-10-03T12:17:32-04:00
Exclude rts.cabal from source distributions

This modifies both the Hadrian and make build systems to avoid included
the rts.cabal generated by autoconf in the source distribution.

Fixes #17265.

- - - - -
e4c93896 by Ben Gamari at 2019-10-03T12:17:32-04:00
DynFlags: Only warn when split-sections is ignored

Previously we would throw an error which seems a bit harsh. As reported
in #17283.

- - - - -
ee6324ad by Tobias Guggenmos at 2019-10-03T12:17:33-04:00
Improve documentation for runtime debugging flags

- - - - -
47386fe8 by Tobias Guggenmos at 2019-10-03T12:17:33-04:00
Add new debug flag -DZ

Zeros heap memory after gc freed it.

- - - - -
d0924b15 by Stefan Schulze Frielinghaus at 2019-10-03T12:17:34-04:00
Extend argument of createIOThread to word size

Function createIOThread expects its second argument to be of size word.
The natural size of the second parameter is 32bits. Thus for some 64bit
architectures, where a write of the lower half of a register does not
clear the upper half, the value must be zero extended.

- - - - -
1357d023 by Ben Gamari at 2019-10-03T12:17:34-04:00
rules/haddock: Ensure that RTS stats directory exists

It may not exist if the source tarball was extracted yet not the
testsuite tarball.

- - - - -
ec93d2a9 by Fumiaki Kinoshita at 2019-10-04T21:43:49-04:00
Add Monad instances to `(,,) a b` and `(,,,) a b c`

- - - - -
05419e55 by John Ericson at 2019-10-04T21:44:29-04:00
Per stage headers, ghc_boot_platform.h -> stage 0 ghcplatform.h

The generated headers are now generated per stage, which means we can
skip hacks like `ghc_boot_platform.h` and just have that be the stage 0
header as proper. In general, stages are to be embraced: freely generate
everything in each stage but then just build what you depend on, and
everything is symmetrical and efficient. Trying to avoid stages because
bootstrapping is a mind bender just creates tons of bespoke
mini-mind-benders that add up to something far crazier.

Hadrian was pretty close to this "stage-major" approach already, and so
was fairly easy to fix. Make needed more work, however: it did know
about stages so at least there was a scaffold, but few packages except
for the compiler cared, and the compiler used its own counting system.
That said, make and Hadrian now work more similarly, which is good for
the transition to Hadrian. The merits of embracing stage aside, the
change may be worthy for easing that transition alone.

- - - - -
75a5dd8e by John Ericson at 2019-10-04T21:44:29-04:00
Remove {Build,Host}Platform_NAME from header

They are only used in a file we construct directly, so just skip CPP.

- - - - -
b538476b by Daroc Alden at 2019-10-04T21:45:09-04:00
Deprecate -fwarn-hi-shadowing, because it was never implemented and is
not used.

This fixes #10913.

- - - - -
dd8f76b2 by John Ericson at 2019-10-04T21:45:48-04:00
Factor out a smaller part of Platform for host fallback

- - - - -
d15b44d6 by John Ericson at 2019-10-04T21:45:49-04:00
Pull out the settings file parsing code into it's own module.

This has two benefits:

1. One less hunk of code dependent on DynFlags

2. Add a little bit of error granularity to distrinugish between missing
   data and bad data. This could someday be shared with ghc-pkg which
   aims to work even with a missing file. I also am about to to make
   --supported-extensions use this too.

- - - - -
eb892b28 by John Ericson at 2019-10-04T21:45:49-04:00
Add tryFindTopDir to look for the top dir without blowing up if it is
not found.

- - - - -
0dded5ec by John Ericson at 2019-10-04T21:45:49-04:00
Always enable the external interpreter

You can always just not use or even build `iserv`. I don't think the
maintenance cost of the CPP is worth...I can't even tell what the
benefit is.

- - - - -
0d31ccdd by Artem Pyanykh at 2019-10-04T21:46:28-04:00
[linker, macho] Don't map/allocate zero size sections and segments

Zero size sections are common even during regular build on MacOS. For
instance:

```
$ ar -xv libHSghc-prim-0.6.1.a longlong.o
$ otool -l longlong.o
longlong.o:
Mach header
      magic cputype cpusubtype  caps    filetype ncmds sizeofcmds      flags
 0xfeedfacf 16777223          3  0x00           1     2        176 0x00002000
Load command 0
      cmd LC_SEGMENT_64
  cmdsize 152
  segname
   vmaddr 0x0000000000000000
   vmsize 0x0000000000000000 <-- segment size = 0
  fileoff 208
 filesize 0
  maxprot 0x00000007
 initprot 0x00000007
   nsects 1
    flags 0x0
Section
  sectname __text
   segname __TEXT
      addr 0x0000000000000000
      size 0x0000000000000000 <-- section size = 0
    offset 208
     align 2^0 (1)
    reloff 0
    nreloc 0
     flags 0x80000000
 reserved1 0
 reserved2 0
       cmd LC_BUILD_VERSION
   cmdsize 24
  platform macos
       sdk 10.14
     minos 10.14
    ntools 0
```

The issue of `mmap`ing 0 bytes was resolved in !1050, but the problem
remained. These 0 size segments and sections were still allocated in
object code, which lead to failed `ASSERT(size > 0)` in
`addProddableBlock` further down the road.

With this change zero size segments **and** sections are not
mapped/allocated at all.

Test plan:

1. Build statically linked GHC.

2. Run `ghc --interactive`. Observe that REPL loads
successfully (which was not the case before).

3. Load several more compiled hs files into repl. No failures.

- - - - -
93f02b62 by Roland Senn at 2019-10-04T21:47:07-04:00
New fix for #11647. Avoid side effects like #17171

If a main module doesn't contain a header, we omit the check whether the main module is exported.
With this patch GHC, GHCi and runghc use the same code.

- - - - -
8039b625 by Matthew Bauer at 2019-10-04T21:47:47-04:00
Add musl systems to llvm-targets

This was done in Nixpkgs, but never upstreamed. Musl is pretty much
the same as gnu, but with a different libc. I’ve used the same values
for everything.

- - - - -
ee8118ca by John Ericson at 2019-10-05T00:11:58-04:00
Clean up `#include`s in the compiler

 - Remove unneeded ones

 - Use <..> for inter-package.
   Besides general clean up, helps distinguish between the RTS we link
   against vs the RTS we compile for.

- - - - -
241921a0 by Ben Gamari at 2019-10-05T19:18:40-04:00
rts: Fix CNF dirtying logic

Previously due to a silly implementation bug CNFs would never have their
dirty flag set, resulting in their being added again and again to the
`mut_list`. Fix this.

Fixes #17297.

- - - - -
825c108b by Ryan Scott at 2019-10-07T12:00:59-04:00
Only flatten up to type family arity in coreFlattenTyFamApp (#16995)

Among other uses, `coreFlattenTyFamApp` is used by Core Lint as a
part of its check to ensure that each type family axiom reduces
according to the way it is defined in the source code. Unfortunately,
the logic that `coreFlattenTyFamApp` uses to flatten type family
applications disagreed with the logic in `TcFlatten`, which caused
it to spuriously complain this program:

```hs
type family Param :: Type -> Type

type family LookupParam (a :: Type) :: Type where
  LookupParam (f Char) = Bool
  LookupParam x        = Int

foo :: LookupParam (Param ())
foo = 42
```

This is because `coreFlattenTyFamApp` tries to flatten the `Param ()`
in `LookupParam (Param ())` to `alpha` (where `alpha` is a flattening
skolem), and GHC is unable to conclude that `alpha` is apart from
`f Char`. This patch spruces up `coreFlattenTyFamApp` so that it
instead flattens `Param ()` to `alpha ()`, which GHC _can_ know for
sure is apart from `f Char`. See
`Note [Flatten], wrinkle 3` in `FamInstEnv`.

- - - - -
b2577081 by Ben Gamari at 2019-10-07T12:01:46-04:00
Refactor, document, and optimize LLVM configuration loading

As described in the new Note [LLVM Configuration] in SysTools, we now
load llvm-targets and llvm-passes lazily to avoid the overhead of doing
so when -fllvm isn't used (also known as "the common case").

Noticed in #17003.

Metric Decrease:
    T12234
    T12150

- - - - -
93c71ae6 by Ben Gamari at 2019-10-07T12:02:23-04:00
configure: Determine library versions of template-haskell, et al.

These are needed by the user guide documentation. Fixes #17260.

- - - - -
b7890611 by Andrey Mokhov at 2019-10-07T12:03:13-04:00
Hadrian: Stop using in-tree Cabal

- - - - -
0ceb98f6 by Andrey Mokhov at 2019-10-07T12:03:13-04:00
Switch to cabal-version=3.0 in ghc-heap.cabal

- - - - -
e3418e96 by Andrey Mokhov at 2019-10-07T12:03:13-04:00
Switch to cabal-version=3.0 in base.cabal and rts.cabal

- - - - -
805653f6 by John Ericson at 2019-10-07T12:04:19-04:00
Get rid of wildcard patterns in prim Cmm emitting code

This way, we can be sure we don't miss a case.

- - - - -
ab945819 by Ryan Scott at 2019-10-07T12:05:09-04:00
Refactor some cruft in TcGenGenerics

* `foldBal` contains needless partiality that can easily be avoided.
* `mkProd_E` and `mkProd_P` both contain unique supply arguments that
  are completely unused, which can be removed.

- - - - -
d0edba3a by John Ericson at 2019-10-07T12:05:47-04:00
Remove CONFIGURE_ARGS from configure.ac

It looks like it's been unused since at least
34cc75e1a62638f2833815746ebce0a9114dc26b.

- - - - -
9a6bfb0a by John Ericson at 2019-10-07T12:06:26-04:00
Keep OSTYPE local to configure.ac

Unused outside it since b6be81b841e34ca45b3549c4c79e886a8761e59a.

- - - - -
4df39fd0 by John Ericson at 2019-10-07T12:07:08-04:00
Get rid of GHC_PACKAGE_DB_FLAG

We no longer support booting from older GHC since
527bcc41630918977c73584d99125ff164400695.

- - - - -
31a29a7a by John Ericson at 2019-10-07T12:07:46-04:00
Remove GhcLibsWithUnix

d679ca43e7477284d733b94ff542be5363be3353 meant to remove it but did not
finish the job.

- - - - -
77ca39e3 by Ben Gamari at 2019-10-08T05:11:03-04:00
gitlab-ci: Add missing TEST_ENV variables

This should fix #16985.

- - - - -
9a2798e1 by Ben Gamari at 2019-10-08T05:11:03-04:00
hadrian: Add `validate` and `slow validate` flavours

- - - - -
ab311696 by Ben Gamari at 2019-10-08T05:11:03-04:00
validate: Use Hadrian's validate flavour

- - - - -
98179a77 by Ben Gamari at 2019-10-08T05:11:03-04:00
gitlab-ci: Use validate flavour in hadrian builds

- - - - -
8af9eba8 by Ben Gamari at 2019-10-08T05:11:40-04:00
base: Document the fact that Typeable is automatically "derived"

This fixes #17060.

- - - - -
397c6ed5 by Sebastian Graf at 2019-10-08T05:12:15-04:00
PmCheck: Identify some semantically equivalent expressions

By introducing a `CoreMap Id` to the term oracle, we can represent
syntactically equivalent expressions by the same `Id`. Combine that with
`CoreOpt.simpleCoreExpr` and it might even catch non-trivial semantic
equalities.

Unfortunately due to scoping issues, this will not solve #17208 for
view patterns yet.

- - - - -
8a2e8408 by Ben Gamari at 2019-10-08T05:12:58-04:00
users-guide: Refer to language extension flags via :extension:

Previously several were referred to via :ghc-flag:`-X...`.

- - - - -
7cd54538 by Ben Gamari at 2019-10-08T05:12:58-04:00
users-guide: Make reverse flags addressable via :ghc-flag:

Previously one could not easily link to the :reverse: flag of a
ghc-flag.

- - - - -
e9813afc by Ben Gamari at 2019-10-08T05:12:58-04:00
users-guide: Document -XHaskell98 and -XHaskell2010

- - - - -
eaeb28a1 by Ben Gamari at 2019-10-08T05:12:58-04:00
users-guide: Fix various warnings

- - - - -
180cf177 by Ben Gamari at 2019-10-08T05:12:58-04:00
users-guide: Document NondecreasingIndentation

- - - - -
0a26f9e8 by Ben Gamari at 2019-10-08T05:12:58-04:00
users-guide: Document -fworker-wrapper

- - - - -
ca4791db by Ben Gamari at 2019-10-08T05:12:58-04:00
users-guide: Rework pragma key generation

Previously we had a hack to handle the case of multi-token SPECIALISE
pragmas. Now we use a slightly more general rule of using a prefix of
tokens containing only alphabetical characters.

- - - - -
98c09422 by Ben Gamari at 2019-10-08T05:12:58-04:00
users-guide: Run sphinx in nit-picky mode

This ensure that it blurts an error on missing references.

- - - - -
a95f7185 by Ben Gamari at 2019-10-08T05:12:58-04:00
doc: Write out documented flag list

- - - - -
9402608e by Ben Gamari at 2019-10-08T05:12:58-04:00
gitlab-ci: Check coverage of GHC flags in users guide

This ensures that all GHC flags are documented during the documentation
build.

Fixes #17315.

- - - - -
9ac3bcbb by Andrew Martin at 2019-10-08T13:24:52-04:00
Document the UnliftedFFITypes extension.

- - - - -
77f3ba23 by Andrew Martin at 2019-10-08T13:24:52-04:00
Rephrase a bunch of things in the unlifted ffi types documentation. Add a section on pinned byte arrays.

- - - - -
a70db7bf by Andrew Martin at 2019-10-08T13:24:52-04:00
[skip ci] link to foreign cmm call

- - - - -
0d413259 by Andrew Martin at 2019-10-08T13:24:52-04:00
[skip ci] make the table better

- - - - -
0c7a5bcd by Andrew Martin at 2019-10-08T13:24:52-04:00
[skip ci] can not -> may not

- - - - -
6a5c249d by Andrew Martin at 2019-10-08T13:24:52-04:00
[skip ci] clarify what unsound means

- - - - -
bf02c264 by Ryan Scott at 2019-10-08T13:25:37-04:00
Mark newtype constructors as used in the Coercible solver (#10347)

Currently, newtype constructors are not marked as used when they are
accessed under the hood by uses of `coerce`, as described in #10347.
This fixes #10347 by co-opting the `tcg_keep` field of `TcGblEnv`
to track uses of newtype constructors in the `Coercible` solver.
See `Note [Tracking unused binding and imports]` in `TcRnTypes`.

Since #10347 is fixed, I was able to simplify the code in `TcDeriv`
slightly, as the hack described in
`Note [Newtype deriving and unused constructors]`
is no longer necessary.

- - - - -
9612e91c by Richard Eisenberg at 2019-10-08T13:26:20-04:00
Solve constraints from top-level groups sooner

Previously, all constraints from all top-level groups (as
separated by top-level splices) were lumped together and solved
at the end. This could leak metavariables to TH, though, and
that's bad. This patch solves each group's constraints before
running the next group's splice.

Naturally, we now report fewer errors in some cases.

One nice benefit is that this also fixes #11680, but in a much
simpler way than the original fix for that ticket. Admittedly,
the error messages degrade just a bit from the fix from #11680
(previously, we informed users about variables that will be
brought into scope below a top-level splice, and now we just
report an out-of-scope error), but the amount of complexity
required throughout GHC to get that error was just not worth it.

This patch thus reverts much of
f93c9517a2c6e158e4a5c5bc7a3d3f88cb4ed119.

Fixes #16980

Test cases: th/T16980{,a}

- - - - -
c2d4011c by Vladislav Zavialov at 2019-10-08T13:27:12-04:00
Bump array and haddock submodules

- - - - -
f691f0c2 by Sebastian Graf at 2019-10-08T13:27:49-04:00
PmCheck: Look up parent data family TyCon when populating `PossibleMatches`

The vanilla COMPLETE set is attached to the representation TyCon of a
data family instance, whereas the user-defined COMPLETE sets are
attached to the parent data family TyCon itself.

Previously, we weren't trying particularly hard to get back to the
representation TyCon to the parent data family TyCon, resulting in bugs
like #17207. Now we should do much better.

Fixes the original issue in #17207, but I found another related bug that
isn't so easy to fix.

- - - - -
0c0a15a8 by Ben Gamari at 2019-10-09T16:21:14-04:00
Rename STAGE macro to GHC_STAGE

To avoid polluting the macro namespace

- - - - -
63a5371d by Ben Gamari at 2019-10-09T16:21:14-04:00
Relayout generated header body

- - - - -
817c1a94 by Ben Gamari at 2019-10-09T16:21:14-04:00
Define GHC_STAGE in headers instead of command-line

- - - - -
5f2c49d8 by Ben Gamari at 2019-10-09T16:21:14-04:00
Remove GHC_STAGE guards from MachDeps

This allows the stage1 compiler (which needs to run on the build
platform and produce code for the host) to depend upon properties of the
target. This is wrong. However, it's no more wrong than it was
previously and @Erichson2314 is working on fixing this so I'm going to
remove the guard so we can finally bootstrap HEAD with ghc-8.8 (see
issue #17146).

- - - - -
35cc5eff by Ben Gamari at 2019-10-09T16:21:15-04:00
Test

- - - - -
d584e3f0 by Ryan Scott at 2019-10-09T16:21:50-04:00
Use addUsedDataCons more judiciously in TcDeriv (#17324)

If you derive an instance like this:

```hs
deriving <...> instance Foo C
```

And the data constructors for `C` aren't in scope, then
`doDerivInstErrorChecks1` throws an error. Moreover, it will
_only_ throw an error if `<...>` is either `stock` or `newtype`.
This is because the code that the `anyclass` or `via` strategies
would generate would not require the use of the data constructors
for `C`.

However, `doDerivInstErrorChecks1` has another purpose. If you
write this:

```hs
import M (C(MkC1, ..., MkCn))

deriving <...> instance Foo C
```

Then `doDerivInstErrorChecks1` will call `addUsedDataCons` on
`MkC1` through `MkCn` to ensure that `-Wunused-imports` does not
complain about them. However, `doDerivInstErrorChecks1` was doing
this for _every_ deriving strategy, which mean that if `<...>` were
`anyclass` or `via`, then the warning about `MkC1` through `MkCn`
being unused would be suppressed!

The fix is simple enough: only call `addUsedDataCons` when the
strategy is `stock` or `newtype`, just like the other code paths
in `doDerivInstErrorChecks1`.

Fixes #17324.

- - - - -
30f5ac07 by Sebastian Graf at 2019-10-11T22:10:12-04:00
Much simpler language for PmCheck

Simon realised that the simple language composed of let bindings, bang
patterns and flat constructor patterns is enough to capture the
semantics of the source pattern language that are important for
pattern-match checking. Well, given that the Oracle is smart enough to
connect the dots in this less informationally dense form, which it is
now.

So we transform `translatePat` to return a list of `PmGrd`s relative to
an incoming match variable. `pmCheck` then trivially translates each of
the `PmGrd`s into constraints that the oracle understands.

Since we pass in the match variable, we incidentally fix #15884
(coverage checks for view patterns) through an interaction with !1746.

- - - - -
166e1c2a by Stefan Schulze Frielinghaus at 2019-10-11T22:10:51-04:00
Hadrian: Take care of assembler source files

Fixes #17286.

- - - - -
c2290596 by John Ericson at 2019-10-12T06:32:18-04:00
Simplify Configure in a few ways

 - No need to distinguish between gcc-llvm and clang. First of all,
   gcc-llvm is quite old and surely unmaintained by now. Second of all,
   none of the code actually care about that distinction!

   Now, it does make sense to consider C multiple frontends for LLVMs in
   the form of clang vs clang-cl (same clang, yes, but tweaked
   interface). But this is better handled in terms of "gccish vs
   mvscish" and "is LLVM", yielding 4 combinations. Therefore, I don't
   think it is useful saving the existing code for that.

 - Get the remaining CC_LLVM_BACKEND, and also TABLES_NEXT_TO_CODE in
   mk/config.h the normal way, rather than hacking it post-hoc. No point
   keeping these special cases around for now reason.

 - Get rid of hand-rolled `die` function and just use `AC_MSG_ERROR`.

 - Abstract check + flag override for unregisterised and tables next to
   code.

Oh, and as part of the above I also renamed/combined some variables
where it felt appropriate.

 - GccIsClang -> CcLlvmBackend. This is for `AC_SUBST`, like the other
 Camal case ones. It was never about gcc-llvm, or Apple's renamed clang,
 to be clear.

 - llvm_CC_FLAVOR -> CC_LLVM_BACKEND. This is for `AC_DEFINE`, like the
 other all-caps snake case ones. llvm_CC_FLAVOR was just silly
 indirection *and* an odd name to boot.

- - - - -
f1ce3535 by Vladislav Zavialov at 2019-10-12T06:33:05-04:00
Escape stats file command (#13676)

- - - - -
cd1a8808 by Vladislav Zavialov at 2019-10-12T06:33:05-04:00
Skip T13767 on Darwin

The CI job fails with:

	+++ rts/T13676.run/T13676.run.stderr.normalised	2019-10-09 12:27:56.000000000 -0700
	@@ -0,0 +1,4 @@
	+dyld: Library not loaded: @rpath/libHShaskeline-0.7.5.0-ghc8.9.0.20191009.dylib
	+  Referenced from: /Users/builder/builds/ewzE5N2p/0/ghc/ghc/inplace/lib/bin/ghc
	+  Reason: image not found
	+*** Exception: readCreateProcess: '/Users/builder/builds/ewzE5N2p/0/ghc/ghc/inplace/lib/bin/ghc' '-B/Users/builder/builds/ewzE5N2p/0/ghc/ghc/inplace/lib' '-e' ''/''$'/'' == '/''/x0024'/''' +RTS '-tT13676.t'  (exit -6): failed

Unable to reproduce locally.

- - - - -
0a338264 by Ryan Scott at 2019-10-12T06:33:42-04:00
Use newDFunName for both manual and derived instances (#17339)

Issue #17339 was caused by using a slightly different version of
`newDFunName` for derived instances that, confusingly enough, did not
take all arguments to the class into account when generating the
`DFun` name. I cannot think of any good reason for doing this, so
this patch uses `newDFunName` uniformly for both derived instances
and manually written instances alike.

Fixes #17339.

- - - - -
c50e4c92 by Simon Peyton Jones at 2019-10-12T13:35:24-04:00
Fix validity checking for inferred types

GHC is suposed to uphold the principle that an /inferred/ type
for a let-binding should obey the rules for that module.  E.g.
we should only accept an inferred higher rank type if we have
RankNTypes on.

But we were failing to check this: TcValidity.checkValidType
allowed arbitrary rank for inferred types.

This patch fixes the bug.  It might in principle cause some breakage,
but if so that's good: the user should add RankNTypes and/or a
manual signature.  (And almost every package has explicit user
signatures for all top-level things anyway.)  Let's see.

Fixes #17213.

Metric Decrease:
    T10370

- - - - -
226d86d2 by Simon Peyton Jones at 2019-10-12T13:36:02-04:00
Do not add a 'solved dict' for quantified constraints

GHC has a wonderful-but-delicate mechanism for building recursive
dictionaries by adding a goal to the "solved dictionaries" before
solving the sub-goals.  See Note [Solved dictionaries] in TcSMonad

Ticket #17267 showed that if you use this mechanism for local
/quantified/ constraints you can get a loop -- or even unsafe
coerce.   This patch fixes the bug.

Specifically

* Make TcSMonad.addSolvedDict be conditional on using a
  /top level/ instance, not a quantified one.

* Moreover, we /also/ don't want to add a solved dict
  for equalities (a~b).

* Add lots more comments to Note [Solved dictionaries]
  to explain the above cryptic stuff.

* Extend InstanceWhat to identify those strange built-in
  equality instances.

A couple of other things along the way

* Delete the unused Type.isIPPred_maybe.

* Stop making addSolvedDict conditional on not being an
  impolicit parameter.  This comes from way back. But
  it's irrelevant now because IP dicts are never solved
  via an instance.

- - - - -
5ab1a28d by nineonine at 2019-10-13T06:31:40-04:00
Template Haskell: make unary tuples legal (#16881)

- - - - -
c1bd07cd by Andreas Klebinger at 2019-10-13T06:32:19-04:00
Fix #17334 where NCG did not properly update the CFG.

Statements can change the basic block in which instructions
are placed during instruction selection.

We have to keep track of this switch of the current basic block
as we need this information in order to properly update the CFG.

This commit implements this change and fixes #17334.

We do so by having stmtToInstr return the new block id
if a statement changed the basic block.

- - - - -
1eda9f28 by Takenobu Tani at 2019-10-13T19:06:02-04:00
users-guide: Add GHCi's ::<builtin-command> form

This commit explicitly adds description about double colon command
of GHCi.

[skip ci]

- - - - -
27145351 by Takenobu Tani at 2019-10-13T19:06:40-04:00
Add GHCi help message for :def! and :: commands

- - - - -
78463fc5 by Ryan Scott at 2019-10-14T08:38:36-04:00
Add docs/users_guide/.log to .gitignore

When the users guide fails to build (as in #17346), a
`docs/users_guide/.log` file will be generated with contents that
look something like this:

```
WARNING: unknown config value 'latex_paper_size' in override, ignoring
/home/rgscott/Software/ghc5/docs/users_guide/ghci.rst:3410: WARNING: u'ghc-flag' reference target not found: -pgmo ?option?
/home/rgscott/Software/ghc5/docs/users_guide/ghci.rst:3410: WARNING: u'ghc-flag' reference target not found: -pgmo ?port?

Encoding error:
'ascii' codec can't encode character u'\u27e8' in position 132: ordinal not in range(128)
The full traceback has been saved in /tmp/sphinx-err-rDF2LX.log, if you want to report the issue to the developers.
```

This definitely should not be checked in to version control, so let's
add this to `.gitignore`.

- - - - -
4aba72d6 by Ryan Scott at 2019-10-14T08:39:12-04:00
Mention changes from #16980, #17213 in 8.10.1 release notes

The fixes for these issues both have user-facing consequences, so it
would be good to mention them in the release notes for GHC 8.10.1.

While I'm in town, also mention `UnboxedSums` in the release notes
entry related to `-fobject-code`.

- - - - -
0ca044fd by Ben Gamari at 2019-10-14T08:39:48-04:00
gitlab-ci: Move hadrian-ghc-in-ghci job first

This is a very cheap job and can catch a number of "easy" failure modes
(e.g. missing imports in the compiler). Let's run it first.

- - - - -
a2d3594c by Ryan Scott at 2019-10-15T01:35:34-04:00
Refactor some cruft in TcDerivInfer.inferConstraints

The latest installment in my quest to clean up the code in
`TcDeriv*`. This time, my sights are set on
`TcDerivInfer.inferConstraints`, which infers the context for derived
instances. This function is a wee bit awkward at the moment:

* It's not terribly obvious from a quick glance, but
  `inferConstraints` is only ever invoked when using the `stock` or
  `anyclass` deriving strategies, as the code for inferring the
  context for `newtype`- or `via`-derived instances is located
  separately in `mk_coerce_based_eqn`. But there's no good reason
  for things to be this way, so I moved this code from
  `mk_coerce_based_eqn` to `inferConstraints` so that everything
  related to inferring instance contexts is located in one place.
* In this process, I discovered that the Haddocks for the auxiliary
  function `inferConstraintsDataConArgs` are completely wrong. It
  claims that it handles both `stock` and `newtype` deriving, but
  this is completely wrong, as discussed above—it only handles
  `stock`. To rectify this, I renamed this function to
  `inferConstraintsStock` to reflect its actual purpose and created
  a new `inferConstraintsCoerceBased` function to specifically
  handle `newtype` (and `via`) deriving.

Doing this revealed some opportunities for further simplification:

* Removing the context-inference–related code from
  `mk_coerce_based_eqn` made me realize that the overall structure
  of the function is basically identical to `mk_originative_eqn`.
  In fact, I was easily able to combine the two functions into a
  single `mk_eqn_from_mechanism` function.

  As part of this merger, I now invoke
  `atf_coerce_based_error_checks` from `doDerivInstErrorChecks1`.
* I discovered that GHC defined this function:

  ```hs
  typeToTypeKind = liftedTypeKind `mkVisFunTy` liftedTypeKind
  ```

  No fewer than four times in different modules. I consolidated all
  of these definitions in a single location in `TysWiredIn`.

- - - - -
426b0ddc by Ryan Scott at 2019-10-15T01:36:14-04:00
Don't skip validity checks for built-in classes (#17355)

Issue #17355 occurred because the control flow for
`TcValidity.check_valid_inst_head` was structured in such a way that
whenever it checked a special, built-in class (like `Generic` or
`HasField`), it would skip the most important check of all:
`checkValidTypePats`, which rejects nonsense like this:

```hs
instance Generic (forall a. a)
```

This fixes the issue by carving out `checkValidTypePats` from
`check_valid_inst_head` so that `checkValidTypePats` is always
invoked. `check_valid_inst_head` has also been renamed to
`check_special_inst_head` to reflect its new purpose of _only_
checking for instances headed by special classes.

Fixes #17355.

- - - - -
a55b8a65 by Alp Mestanogullari at 2019-10-15T18:41:18-04:00
iface: export a few more functions from BinIface

- - - - -
9c11f817 by Ben Gamari at 2019-10-15T18:41:54-04:00
hadrian: Add support for bindist compressors other than Xz

Fixes #17351.

- - - - -
535a88e1 by klebinger.andreas at gmx.at at 2019-10-16T07:04:21-04:00
Add loop level analysis to the NCG backend.

For backends maintaining the CFG during codegen
we can now find loops and their nesting level.

This is based on the Cmm CFG and dominator analysis.

As a result we can estimate edge frequencies a lot better
for methods, resulting in far better code layout.

Speedup on nofib: ~1.5%
Increase in compile times: ~1.9%

To make this feasible this commit adds:
* Dominator analysis based on the Lengauer-Tarjan Algorithm.
* An algorithm estimating global edge frequences from branch
probabilities - In CFG.hs

A few static branch prediction heuristics:

* Expect to take the backedge in loops.
* Expect to take the branch NOT exiting a loop.
* Expect integer vs constant comparisons to be false.

We also treat heap/stack checks special for branch prediction
to avoid them being treated as loops.

- - - - -
cc2bda50 by adithyaov at 2019-10-16T07:05:01-04:00
Compiling with -S and -fno-code no longer panics (fixes #17143)

- - - - -
19641957 by Takenobu Tani at 2019-10-16T07:05:41-04:00
testsuite: Add test for #8305

This is a test for the current algorithm of GHCi command name resolution.

I add this test in preparation for updating GHCi command name resolution.

For the current algorithm, see https://downloads.haskell.org/ghc/latest/docs/html/users_guide/ghci.html#the-ghci-files

- - - - -
6ede3554 by Sebastian Graf at 2019-10-16T07:06:20-04:00
Infer rho-types instead of sigma-types in guard BindStmts and TransStmts

In #17343 we saw that we didn't handle the pattern guard `!_ <-
undefined` correctly: The `undefined` was never evaluated. Indeed,
elaboration failed to insert the invisible type aruments to `undefined`.
So `undefined` was trivially a normal-form and in turn never entered.

The problem is that we used to infer a sigma-type for the RHS of the
guard, the leading qualifiers of which will never be useful in a pattern
match situation. Hence we infer a rho-type now.

Fixes #17343.

- - - - -
798037a1 by John Ericson at 2019-10-16T07:06:58-04:00
Delete ghctags cabal file

It came back to life in 381c3ae31b68019177f1cd20cb4da2f9d3b7d6c6 by
mistake.

- - - - -
51fad9e6 by Richard Eisenberg at 2019-10-16T15:58:58-04:00
Break up TcRnTypes, among other modules.

This introduces three new modules:

 - basicTypes/Predicate.hs describes predicates, moving
   this logic out of Type. Predicates don't really exist
   in Core, and so don't belong in Type.

 - typecheck/TcOrigin.hs describes the origin of constraints
   and types. It was easy to remove from other modules and
   can often be imported instead of other, scarier modules.

 - typecheck/Constraint.hs describes constraints as used in
   the solver. It is taken from TcRnTypes.

No work other than module splitting is in this patch.

This is the first step toward homogeneous equality, which will
rely more strongly on predicates. And homogeneous equality is the
next step toward a dependently typed core language.

- - - - -
11d4fc50 by Ben Gamari at 2019-10-16T15:59:52-04:00
hadrian: Introduce enableDebugInfo flavour transformer

Also refactor things a bit to eliminate repetition.

- - - - -
deb96399 by Ryan Scott at 2019-10-16T16:00:29-04:00
Make Coverage.TM a newtype

- - - - -
42ebc3f6 by Brian Wignall at 2019-10-16T16:01:06-04:00
Add hyperlinks to PDF/HTML documentation; closes #17342

- - - - -
b15a7fb8 by Ben Gamari at 2019-10-17T01:03:11-04:00
testsuite: Ensure that makefile tests get run

Previously `makefile_test` and `run_command` tests could easily end up
in a situation where they wouldn't be run if the user used the
`only_ways` modifier. The reason is to build the set of a ways to run
the test in we first start with a candidate set determined by the test
type (e.g. `makefile_test`, `compile_run`, etc.) and then filter that
set with the constraints given by the test's modifiers.

`makefile_test` and `run_command` tests' candidate sets were simply
`{normal}`, and consequently most uses of `only_ways` would result in
the test being never run.

To avoid this we rather use all ways as the candidate sets for these
test types. This may result in a few more testcases than we would like
(given that some `run_command` tests are insensitive to way) but this
can be fixed by adding modifiers and we would much rather run too many
tests than too few.

This fixes #16042 and a number of other tests afflicted by the same issue.
However, there were a few cases that required special attention:

 * `T14028` is currently failing and is therefore marked as broken due
   to #17300

 * `T-signals-child` is fragile in the `threaded1` and `threaded2` ways
   (tracked in #17307)

- - - - -
4efdda90 by Richard Eisenberg at 2019-10-17T01:03:51-04:00
Tiny fixes to comments around flattening.

- - - - -
c4c9904b by Ben Gamari at 2019-10-17T01:04:26-04:00
testsuite: Assert that testsuite ways are known

This ensures that all testsuite way names given to `omit_ways`,
`only_ways`, etc. are known ways.

- - - - -
697be2b6 by Ömer Sinan Ağacan at 2019-10-18T15:26:53-04:00
rts/GC: Add an obvious assertion during block initialization

Namely ensure that block descriptors are initialized with valid
generation numbers.

Co-Authored-By: Ben Gamari <ben at well-typed.com>

- - - - -
61d2ed42 by Ben Gamari at 2019-10-18T15:26:53-04:00
rts: Add Note explaining applicability of selector optimisation depth limit

This was slightly non-obvious so a note seems deserved.

- - - - -
11395037 by Ben Gamari at 2019-10-18T15:26:53-04:00
rts/Capability: A few documentation comments

- - - - -
206f782a by Ben Gamari at 2019-10-18T15:26:53-04:00
rts: Give stack flags proper macros

This were previously quite unclear and will change a bit under the
non-moving collector so let's clear this up now.

- - - - -
81d4675e by Ben Gamari at 2019-10-18T15:26:53-04:00
rts/GC: Refactor gcCAFs

- - - - -
4d674c4e by Ben Gamari at 2019-10-18T15:26:53-04:00
rts: Fix macro parenthesisation

- - - - -
bfcafd39 by Ben Gamari at 2019-10-18T15:27:42-04:00
rts/Schedule: Allow synchronization without holding a capability

The concurrent mark-and-sweep will be performed by a GHC task which will
not hold a capability. This is necessary to avoid a concurrent mark from
interfering with minor generation collections.

However, the major collector must synchronize with the mutators at the
end of marking to flush their update remembered sets. This patch extends
the `requestSync` mechanism used to synchronize garbage collectors to
allow synchronization without holding a capability.

This change is fairly straightforward as the capability was previously
only required for two reasons:

 1. to ensure that we don't try to re-acquire a capability that we
    the sync requestor already holds.

 2. to provide a way to suspend and later resume the sync request if
    there is already a sync pending.

When synchronizing without holding a capability we needn't worry about
consideration (1) at all.

(2) is slightly trickier and may happen, for instance, when a capability
requests a minor collection and shortly thereafter the non-moving mark
thread requests a post-mark synchronization. In this case we need to
ensure that the non-moving mark thread suspends his request until after
the minor GC has concluded to avoid dead-locking. For this we introduce
a condition variable, `sync_finished_cond`, which a
non-capability-bearing requestor will wait on and which is signalled
after a synchronization or GC has finished.

- - - - -
921e4e36 by Ömer Sinan Ağacan at 2019-10-18T15:27:56-04:00
rts/BlockAlloc: Allow aligned allocation requests

This implements support for block group allocations which are aligned to
an integral number of blocks.

This will be used by the nonmoving garbage collector, which uses the
block allocator to allocate the segments which back its heap. These
segments are a fixed number of blocks in size, with each segment being
aligned to the segment size boundary. This allows us to easily find the
segment metadata stored at the beginning of the segment.

- - - - -
4b431f33 by Tamar Christina at 2019-10-20T16:21:10+01:00
Windows: Update tarballs to GCC 9.2 and remove MAX_PATH limit.

- - - - -
8057ac96 by Ben Gamari at 2019-10-20T21:15:14-04:00
Merge branches 'wip/gc/sync-without-capability' and 'wip/gc/aligned-block-allocation' into wip/gc/preparation

- - - - -
32500f64 by Ömer Sinan Ağacan at 2019-10-20T21:15:37-04:00
rts/StableName: Expose FOR_EACH_STABLE_NAME, freeSnEntry, SNT_size

These will be needed when we implement sweeping in the nonmoving
collector.

- - - - -
4be5152a by Ben Gamari at 2019-10-20T21:15:37-04:00
rts: Disable aggregate-return warnings from gcc

This warning is a bit of a relic; there is little reason to avoid
aggregate return values in 2019.

- - - - -
04471c4f by Ömer Sinan Ağacan at 2019-10-20T21:15:37-04:00
rts/Scav: Expose scavenging functions

To keep the non-moving collector nicely separated from the moving
collector its scavenging phase will live in another file,
`NonMovingScav.c`. However, it will need to use these functions so
let's expose them.

- - - - -
6ff29c06 by Ben Gamari at 2019-10-20T21:15:37-04:00
rts: Introduce flag to enable the nonmoving old generation

This flag will enable the use of a non-moving oldest generation.

- - - - -
b3ef2d1a by Ben Gamari at 2019-10-20T21:15:37-04:00
rts: Introduce debug flag for non-moving GC

- - - - -
68e0647f by Ömer Sinan Ağacan at 2019-10-20T21:15:37-04:00
rts: Non-concurrent mark and sweep

This implements the core heap structure and a serial mark/sweep
collector which can be used to manage the oldest-generation heap.
This is the first step towards a concurrent mark-and-sweep collector
aimed at low-latency applications.

The full design of the collector implemented here is described in detail
in a technical note

    B. Gamari. "A Concurrent Garbage Collector For the Glasgow Haskell
    Compiler" (2018)

The basic heap structure used in this design is heavily inspired by

    K. Ueno & A. Ohori. "A fully concurrent garbage collector for
    functional programs on multicore processors." /ACM SIGPLAN Notices/
    Vol. 51. No. 9 (presented by ICFP 2016)

This design is intended to allow both marking and sweeping
concurrent to execution of a multi-core mutator. Unlike the Ueno design,
which requires no global synchronization pauses, the collector
introduced here requires a stop-the-world pause at the beginning and end
of the mark phase.

To avoid heap fragmentation, the allocator consists of a number of
fixed-size /sub-allocators/. Each of these sub-allocators allocators into
its own set of /segments/, themselves allocated from the block
allocator. Each segment is broken into a set of fixed-size allocation
blocks (which back allocations) in addition to a bitmap (used to track
the liveness of blocks) and some additional metadata (used also used
to track liveness).

This heap structure enables collection via mark-and-sweep, which can be
performed concurrently via a snapshot-at-the-beginning scheme (although
concurrent collection is not implemented in this patch).

The mark queue is a fairly straightforward chunked-array structure.
The representation is a bit more verbose than a typical mark queue to
accomodate a combination of two features:

 * a mark FIFO, which improves the locality of marking, reducing one of
   the major overheads seen in mark/sweep allocators (see [1] for
   details)

 * the selector optimization and indirection shortcutting, which
   requires that we track where we found each reference to an object
   in case we need to update the reference at a later point (e.g. when
   we find that it is an indirection). See Note [Origin references in
   the nonmoving collector] (in `NonMovingMark.h`) for details.

Beyond this the mark/sweep is fairly run-of-the-mill.

[1] R. Garner, S.M. Blackburn, D. Frampton. "Effective Prefetch for
    Mark-Sweep Garbage Collection." ISMM 2007.

Co-Authored-By: Ben Gamari <ben at well-typed.com>

- - - - -
c7e73d12 by Ben Gamari at 2019-10-20T21:15:37-04:00
testsuite: Add nonmoving WAY

This simply runs the compile_and_run tests with `-xn`, enabling the
nonmoving oldest generation.

- - - - -
f8f77a07 by Ben Gamari at 2019-10-20T21:15:37-04:00
rts: Mark binder as const

- - - - -
bd8e3ff4 by Ben Gamari at 2019-10-20T21:15:52-04:00
rts: Implement concurrent collection in the nonmoving collector

This extends the non-moving collector to allow concurrent collection.

The full design of the collector implemented here is described in detail
in a technical note

    B. Gamari. "A Concurrent Garbage Collector For the Glasgow Haskell
    Compiler" (2018)

This extension involves the introduction of a capability-local
remembered set, known as the /update remembered set/, which tracks
objects which may no longer be visible to the collector due to mutation.
To maintain this remembered set we introduce a write barrier on
mutations which is enabled while a concurrent mark is underway.

The update remembered set representation is similar to that of the
nonmoving mark queue, being a chunked array of `MarkEntry`s. Each
`Capability` maintains a single accumulator chunk, which it flushed
when it (a) is filled, or (b) when the nonmoving collector enters its
post-mark synchronization phase.

While the write barrier touches a significant amount of code it is
conceptually straightforward: the mutator must ensure that the referee
of any pointer it overwrites is added to the update remembered set.
However, there are a few details:

 * In the case of objects with a dirty flag (e.g. `MVar`s) we can
   exploit the fact that only the *first* mutation requires a write
   barrier.

 * Weak references, as usual, complicate things. In particular, we must
   ensure that the referee of a weak object is marked if dereferenced by
   the mutator. For this we (unfortunately) must introduce a read
   barrier, as described in Note [Concurrent read barrier on deRefWeak#]
   (in `NonMovingMark.c`).

 * Stable names are also a bit tricky as described in Note [Sweeping
   stable names in the concurrent collector] (`NonMovingSweep.c`).

We take quite some pains to ensure that the high thread count often seen
in parallel Haskell applications doesn't affect pause times. To this end
we allow thread stacks to be marked either by the thread itself (when it
is executed or stack-underflows) or the concurrent mark thread (if the
thread owning the stack is never scheduled). There is a non-trivial
handshake to ensure that this happens without racing which is described
in Note [StgStack dirtiness flags and concurrent marking].

Co-Authored-by: Ömer Sinan Ağacan <omer at well-typed.com>

- - - - -
dd1b4fdd by Ben Gamari at 2019-10-20T21:15:52-04:00
Nonmoving: Disable memory inventory with concurrent collection

- - - - -
4a44ab33 by Ben Gamari at 2019-10-20T21:15:52-04:00
rts: Shrink size of STACK's dirty and marking fields

- - - - -
10373416 by Ben Gamari at 2019-10-20T21:15:52-04:00
Don't cleanup until we've stopped the collector

This requires that we break nonmovingExit into two pieces since we need
to first stop the collector to relinquish any capabilities, then we need
to shutdown the scheduler, then we need to free the nonmoving
allocators.

- - - - -
26c3827f by Ben Gamari at 2019-10-21T11:43:54-04:00
Nonmoving: Ensure write barrier vanishes in non-threaded RTS

- - - - -
17e5a032 by Ben Gamari at 2019-10-21T11:43:54-04:00
ThreadPaused: Add barrer on updated thunk

- - - - -
8ea316da by David Eichmann at 2019-10-22T02:07:48-04:00
CI: Always dump performance metrics.

- - - - -
aa31ceaf by Matthew Bauer at 2019-10-22T02:39:01-04:00
Replace freebsd-gnueabihf with freebsd

FreeBSD does not support GNU libc, so it makes no sense to use this
triple. Most likely previous builds were just using the FreeBSD libc
instead of gnueabihf. To fix this, we should just use
armv6-unknown-freebsd and armv7-unknown-freebsd triples. Note that
both of these are actually "soft-float", not "hard-float". FreeBSD has
never officially released hard-float arm32:

https://wiki.freebsd.org/ARMTier1

- - - - -
fd8b666a by Stefan Schulze Frielinghaus at 2019-10-22T02:39:03-04:00
Implement s390x LLVM backend.

This patch adds support for the s390x architecture for the LLVM code
generator. The patch includes a register mapping of STG registers onto
s390x machine registers which enables a registerised build.

- - - - -
2d2cc76f by Tilman Blumhagen at 2019-10-22T02:39:04-04:00
Documentation for (&&) and (&&) states that they are lazy in their second argument (fixes #17354)

- - - - -
06d51c4e by Ben Gamari at 2019-10-22T12:13:36-04:00
Fix unregisterised build

This required some fiddling around with the location of forward
declarations since the C sources generated by GHC's C backend only
includes Stg.h.

- - - - -
912e440e by Ben Gamari at 2019-10-22T12:17:00-04:00
rts: Tracing support for nonmoving collection events

This introduces a few events to mark key points in the nonmoving
garbage collection cycle. These include:

 * `EVENT_CONC_MARK_BEGIN`, denoting the beginning of a round of
   marking. This may happen more than once in a single major collection
   since we the major collector iterates until it hits a fixed point.

 * `EVENT_CONC_MARK_END`, denoting the end of a round of marking.

 * `EVENT_CONC_SYNC_BEGIN`, denoting the beginning of the post-mark
   synchronization phase

 * `EVENT_CONC_UPD_REM_SET_FLUSH`, indicating that a capability has
   flushed its update remembered set.

 * `EVENT_CONC_SYNC_END`, denoting that all mutators have flushed their
   update remembered sets.

 * `EVENT_CONC_SWEEP_BEGIN`, denoting the beginning of the sweep portion
   of the major collection.

 * `EVENT_CONC_SWEEP_END`, denoting the end of the sweep portion of the
   major collection.

- - - - -
9f42cd81 by Ben Gamari at 2019-10-22T12:17:00-04:00
rts: Introduce non-moving heap census

This introduces a simple census of the non-moving heap (not to be
confused with the heap census used by the heap profiler). This
collects basic heap usage information (number of allocated and free
blocks) which is useful when characterising fragmentation of the
nonmoving heap.

- - - - -
711837cc by Ben Gamari at 2019-10-22T12:17:00-04:00
rts/Eventlog: More descriptive error message

- - - - -
0d31819e by Ben Gamari at 2019-10-22T12:17:00-04:00
Allow census without live word count

Otherwise the census is unsafe when mutators are running due to
concurrent mutation.

- - - - -
6f173181 by Ben Gamari at 2019-10-22T12:17:00-04:00
NonmovingCensus: Emit samples to eventlog

- - - - -
13dd78dd by Ben Gamari at 2019-10-22T12:18:33-04:00
Nonmoving: Allow aging and refactor static objects logic

This commit does two things:

 * Allow aging of objects during the preparatory minor GC
 * Refactor handling of static objects to avoid the use of a hashtable

- - - - -
7b79e8b4 by Ben Gamari at 2019-10-22T12:18:33-04:00
Disable aging when doing deadlock detection GC

- - - - -
8fffe12b by Ben Gamari at 2019-10-22T12:18:33-04:00
More comments for aging

- - - - -
039d2906 by Ben Gamari at 2019-10-22T12:18:39-04:00
NonMoving: Eliminate integer division in nonmovingBlockCount

Perf showed that the this single div was capturing up to 10% of samples
in nonmovingMark. However, the overwhelming majority of cases is looking
at small block sizes. These cases we can easily compute explicitly,
allowing the compiler to turn the division into a significantly more
efficient division-by-constant.

While the increase in source code looks scary, this all optimises down
to very nice looking assembler. At this point the only remaining
hotspots in nonmovingBlockCount are due to memory access.

- - - - -
d15ac82d by Ben Gamari at 2019-10-22T12:18:39-04:00
NonMoving: Allocate mark queues in larger block groups

- - - - -
26d2d331 by Ben Gamari at 2019-10-22T12:18:39-04:00
NonMovingMark: Optimize representation of mark queue

This shortens MarkQueueEntry by 30% (one word)

- - - - -
e5eda61e by Ben Gamari at 2019-10-22T12:18:39-04:00
NonMoving: Optimize bitmap search during allocation

Use memchr instead of a open-coded loop. This is nearly twice as fast in
a synthetic benchmark.

- - - - -
dacf4cae by Ben Gamari at 2019-10-22T12:18:39-04:00
rts: Add prefetch macros

- - - - -
786c52d2 by Ben Gamari at 2019-10-22T12:18:39-04:00
NonMoving: Prefetch when clearing bitmaps

Ensure that the bitmap of the segmentt that we will clear next is in
cache by the time we reach it.

- - - - -
0387df5b by Ben Gamari at 2019-10-22T12:18:39-04:00
NonMoving: Inline nonmovingClearAllBitmaps

- - - - -
e893877e by Ben Gamari at 2019-10-22T12:18:39-04:00
NonMoving: Fuse sweep preparation into mark prep

- - - - -
e6f6823f by Ben Gamari at 2019-10-22T12:18:39-04:00
NonMoving: Pre-fetch during mark

This improved overall runtime on nofib's constraints test by nearly 10%.

- - - - -
56c5ebdc by Ben Gamari at 2019-10-22T12:18:39-04:00
NonMoving: Prefetch segment header

- - - - -
19bfe460 by Ben Gamari at 2019-10-22T12:18:39-04:00
NonMoving: Optimise allocator cache behavior

Previously we would look at the segment header to determine the block
size despite the fact that we already had the block size at hand.

- - - - -
53a1a27e by Ben Gamari at 2019-10-22T12:18:39-04:00
NonMovingMark: Eliminate redundant check_in_nonmoving_heaps

- - - - -
b967e470 by Ben Gamari at 2019-10-22T12:18:39-04:00
NonMoving: Don't do major GC if one is already running

Previously we would perform a preparatory moving collection, resulting
in many things being added to the mark queue. When we finished with this
we would realize in nonmovingCollect that there was already a collection
running, in which case we would simply not run the nonmoving collector.

However, it was very easy to end up in a "treadmilling" situation: all
subsequent GC following the first failed major GC would be scheduled as
major GCs. Consequently we would continuously feed the concurrent
collector with more mark queue entries and it would never finish.

This patch aborts the major collection far earlier, meaning that we
avoid adding nonmoving objects to the mark queue and allowing the
concurrent collector to finish.

- - - - -
3bc172a4 by Ben Gamari at 2019-10-22T12:18:39-04:00
NonMoving: Clean mut_list

- - - - -
8e79e2a9 by Ben Gamari at 2019-10-22T12:18:39-04:00
Unconditionally flush update remembered set during minor GC

Flush the update remembered set. The goal here is to flush periodically to
ensure that we don't end up with a thread who marks their stack on their
local update remembered set and doesn't flush until the nonmoving sync
period as this would result in a large fraction of the heap being marked
during the sync pause.

- - - - -
b281e80b by Ben Gamari at 2019-10-22T12:18:44-04:00
testsuite: Add nonmoving_thr way

- - - - -
07987957 by Ben Gamari at 2019-10-22T12:18:44-04:00
testsuite: Add nonmoving_thr_ghc way

This uses the nonmoving collector when compiling the testcases.

- - - - -
01fd0242 by Ben Gamari at 2019-10-22T12:18:44-04:00
testsuite: Don't run T15892 in nonmoving ways

The nonmoving GC doesn't support `+RTS -G1`, which this test insists on.

- - - - -
097f4fd0 by Ben Gamari at 2019-10-22T12:18:44-04:00
testsuite: Nonmoving collector doesn't support -G1

- - - - -
4b91dd25 by Ben Gamari at 2019-10-22T12:18:44-04:00
testsuite: Ensure that threaded tests are run in nonmoving_thr

- - - - -
78ce35b9 by Ben Gamari at 2019-10-22T12:18:44-04:00
testsuite: bug1010 requires -c, which isn't supported by nonmoving

- - - - -
6e97cc47 by Ben Gamari at 2019-10-22T12:18:44-04:00
testsuite: Skip T15892 in nonmoving_thr_ghc

- - - - -
5ce853c8 by Ben Gamari at 2019-10-22T12:18:44-04:00
ghc-heap: Skip heap_all test with debugged RTS

The debugged RTS initializes the heap with 0xaa, which breaks the
(admittedly rather fragile) assumption that uninitialized fields are set
to 0x00:
```
Wrong exit code for heap_all(nonmoving)(expected 0 , actual 1 )
Stderr ( heap_all ):
heap_all: user error (assertClosuresEq: Closures do not match
Expected: FunClosure {info = StgInfoTable {entry = Nothing, ptrs = 0, nptrs = 1, tipe = FUN_0_1, srtlen = 0, code = Nothing}, ptrArgs = [], dataArgs = [0]}
Actual:   FunClosure {info = StgInfoTable {entry = Nothing, ptrs = 0, nptrs = 1, tipe = FUN_0_1, srtlen = 1032832, code = Nothing}, ptrArgs = [], dataArgs = [12297829382473034410]}

CallStack (from HasCallStack):
  assertClosuresEq, called at heap_all.hs:230:9 in main:Main
)
```

- - - - -
6abefce7 by Ben Gamari at 2019-10-22T12:18:44-04:00
Skip ghc_heap_all test in nonmoving ways

- - - - -
99baff8c by Ben Gamari at 2019-10-22T12:18:44-04:00
testsuite: Don't run T9630 in nonmoving ways

The nonmoving collector doesn't support -G1

- - - - -
25ae8f7d by Ben Gamari at 2019-10-22T12:18:44-04:00
testsuite: Don't run T7160 in nonmoving_thr ways

The nonmoving way finalizes things in a different order.

- - - - -
8cab149b by Ben Gamari at 2019-10-22T12:18:44-04:00
testsuite: Mark length001 as failing under nonmoving ways

This is consistent with the other unoptimized ways.

- - - - -
5b130b3d by Ben Gamari at 2019-10-22T12:18:46-04:00
Merge branches 'wip/gc/optimize' and 'wip/gc/test' into wip/gc/everything

- - - - -
246ce2af by Ömer Sinan Ağacan at 2019-10-22T12:20:15-04:00
NonMoving: Implement indirection shortcutting

This allows indirection chains residing in the non-moving heap to be
shorted-out.

- - - - -
875861ef by Ömer Sinan Ağacan at 2019-10-22T12:20:15-04:00
NonMoving: Implement selector optimisation

- - - - -
c72e84c6 by Ben Gamari at 2019-10-22T12:20:15-04:00
NonMovingMark: Handle INDs left by shortcutting

- - - - -
0f8fd3c6 by Ömer Sinan Ağacan at 2019-10-22T12:20:15-04:00
NonMoving: Implement -xns to disable selector optimization

- - - - -
c936a245 by Ben Gamari at 2019-10-22T12:20:37-04:00
NonMoving: Introduce nonmovingSegmentLogBlockSize acccessor

This will allow us to easily move the block size elsewhere.

- - - - -
6dcef5ee by Ben Gamari at 2019-10-22T12:20:37-04:00
NonMoving: Move block size to block descriptor

- - - - -
dd8d1b49 by Ben Gamari at 2019-10-22T12:20:37-04:00
NonMoving: Move next_free_snap to block descriptor

- - - - -
116e4646 by Ben Gamari at 2019-10-22T12:20:46-04:00
NonMoving: Add summarizing Note

- - - - -
22eee2bc by Ben Gamari at 2019-10-22T12:20:48-04:00
Merge branches 'wip/gc/segment-header-to-bdescr' and 'wip/gc/docs' into wip/gc/everything2

- - - - -
3a862703 by Ömer Sinan Ağacan at 2019-10-22T18:56:32-04:00
rts: COMPACT_NFDATA support for the nonmoving collector

This largely follows the model used for large objects, with appropriate
adjustments made to account for references in the sharing deduplication
hashtable.

- - - - -
7c35d39b by Ben Gamari at 2019-10-22T18:56:32-04:00
rts: Mark nonmoving GC paths in moving collector as unlikely

The expectation here is that the nonmoving GC is latency-centric,
whereas the moving GC emphasizes throughput. Therefore we give the
latter the benefit of better static branch prediction.

- - - - -
91109404 by Ben Gamari at 2019-10-22T18:57:27-04:00
nonmoving: Trace GC preparation steps

- - - - -
a69b28f4 by Ben Gamari at 2019-10-22T18:57:27-04:00
nonmoving: Don't do two passes over large and compact object lists

Previously we would first move the new objects to their appropriate
non-moving GC list, then do another pass over that list to clear their
mark bits. This is needlessly expensive. First clear the mark bits of
the existing objects, then add the newly evacuated objects and, at the
same time, clear their mark bits.

This cuts the preparatory GC time in half for the Pusher benchmark with
a large queue size.

- - - - -
984745b0 by Ben Gamari at 2019-10-22T18:57:27-04:00
nonmoving: Upper-bound time we hold SM_MUTEX for during sweep

- - - - -
96c5411a by David Feuer at 2019-10-23T05:58:37-04:00
Use an IORef for QSemN

Replace the outer `MVar` in `QSemN` with an `IORef`. This should
probably be lighter, and it removes the need for `uninterruptibleMask`.

Previously Differential Revision https://phabricator.haskell.org/D4896

- - - - -
faa30dcb by Andreas Klebinger at 2019-10-23T05:58:43-04:00
Warn about missing profiled libs when using the Interpreter.

When GHC itself, or it's interpreter is profiled we need to load
profiled libraries as well.

This requirement is not always obvious, especially when TH
implicilty uses the interpreter.

When the libs were not found we fall back to assuming the
are in a DLL. This is usually not the case so now we warn
users when we do so. This makes it more obvious what is
happening and gives users a way to fix the issue.

This fixes #17121.

- - - - -
1cd3fa29 by Richard Eisenberg at 2019-10-23T05:58:46-04:00
Implement a coverage checker for injectivity

This fixes #16512.

There are lots of parts of this patch:

* The main payload is in FamInst. See
Note [Coverage condition for injective type families] there
for the overview. But it doesn't fix the bug.

* We now bump the reduction depth every time we discharge
a CFunEqCan. See Note [Flatten when discharging CFunEqCan]
in TcInteract.

* Exploration of this revealed a new, easy to maintain invariant
for CTyEqCans. See Note [Almost function-free] in TcRnTypes.

* We also realized that type inference for injectivity was a
bit incomplete. This means we exchanged lookupFlattenTyVar for
rewriteTyVar. See Note [rewriteTyVar] in TcFlatten. The new
function is monadic while the previous one was pure, necessitating
some faff in TcInteract. Nothing too bad.

* zonkCt did not maintain invariants on CTyEqCan. It's not worth
the bother doing so, so we just transmute CTyEqCans to
CNonCanonicals.

* The pure unifier was finding the fixpoint of the returned
substitution, even when doing one-way matching (in tcUnifyTysWithTFs).
Fixed now.

Test cases: typecheck/should_fail/T16512{a,b}

- - - - -
900cf195 by Alp Mestanogullari at 2019-10-23T05:58:48-04:00
compiler: introduce DynFlags plugins

They have type '[CommandLineOpts] -> Maybe (DynFlags -> IO DynFlags)'.
All plugins that supply a non-Nothing 'dynflagsPlugin' will see their
updates applied to the current DynFlags right after the plugins are
loaded.

One use case for this is to superseede !1580 for registering hooks
from a plugin. Frontend/parser plugins were considered to achieve this
but they respectively conflict with how this plugin is going to be used
and don't allow overriding/modifying the DynFlags, which is how hooks have
to be registered.

This commit comes with a test, 'test-hook-plugin', that registers a "fake"
meta hook that replaces TH expressions with the 0 integer literal.

- - - - -
a19c7d17 by Ryan Scott at 2019-10-23T05:58:49-04:00
Reify oversaturated data family instances correctly (#17296)

`TcSplice` was not properly handling oversaturated data family
instances, such as the example in #17296, as it dropped arguments due
to carelessly zipping data family instance arguments with
`tyConTyVars`. For data families, the number of `tyConTyVars` can
sometimes be less than the number of arguments it can accept in a
data family instance due to the fact that data family instances can
be oversaturated.

To account for this, `TcSplice.mkIsPolyTvs` has now been renamed to
`tyConArgsPolyKinded` and now factors in `tyConResKind` in addition
to `tyConTyVars`. I've also added
`Note [Reified instances and explicit kind signatures]` which
explains the various subtleties in play here.

Fixes #17296.

- - - - -
9b2a5008 by Ben Gamari at 2019-10-23T05:58:50-04:00
testsuite: Don't run T7653 in ghci and profiled ways

Currently this routinely fails in the i386 job.
See #7653.

- - - - -
b521e8b6 by Ömer Sinan Ağacan at 2019-10-23T05:58:57-04:00
Refactor Compact.c:

- Remove forward declarations
- Introduce UNTAG_PTR and GET_PTR_TAG for dealing with pointer tags
  without having to cast arguments to StgClosure*
- Remove dead code
- Use W_ instead of StgWord
- Use P_ instead of StgPtr

- - - - -
17987a4b by Matthew Pickering at 2019-10-23T05:58:58-04:00
eventlog: Dump cost centre stack on each sample

With this change it is possible to reconstruct the timing portion of a
`.prof` file after the fact. By logging the stacks at each time point
a more precise executation trace of the program can be observed rather
than all identical cost centres being identified in the report.

There are two new events:

1. `EVENT_PROF_BEGIN` - emitted at the start of profiling to communicate
the tick interval
2. `EVENT_PROF_SAMPLE_COST_CENTRE` - emitted on each tick to communicate the
current call stack.

Fixes #17322

- - - - -
4798f3b9 by Takenobu Tani at 2019-10-23T05:59:00-04:00
Allow command name resolution for GHCi commands with option `!` #17345

This commit allows command name resolution for GHCi commands
with option `!` as follows:

    ghci> :k! Int
    Int :: *
    = Int

This commit changes implementation as follows:

Before:
  * Prefix match with full string including the option `!` (e.g. `k!`)

After (this patch):
  * Prefix match without option suffix `!` (e.g. `k`)
  * in addition, suffix match with option `!`

See also #8305 and #8113

- - - - -
aa778152 by Andreas Klebinger at 2019-10-23T05:59:01-04:00
Fix bug in the x86 backend involving the CFG.

This is part two of fixing #17334.

There are two parts to this commit:

- A bugfix for computing loop levels
- A bugfix of basic block invariants in the NCG.

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

In the first bug we ended up with a CFG of the sort: [A -> B -> C]
This was represented via maps as fromList [(A,B),(B,C)] and later
transformed into a adjacency array. However the transformation did
not include block C in the array (since we only looked at the keys of
the map).

This was still fine until we tried to look up successors for C and tried
to read outside of the array bounds when accessing C.

In order to prevent this in the future I refactored to code to include
all nodes as keys in the map representation. And make this a invariant
which is checked in a few places.

Overall I expect this to make the code more robust as now any failed
lookup will represent an error, versus failed lookups sometimes being
expected and sometimes not.

In terms of performance this makes some things cheaper (getting a list
of all nodes) and others more expensive (adding a new edge). Overall
this adds up to no noteable performance difference.

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

Part 2: When the NCG generated a new basic block, it did
not always insert a NEWBLOCK meta instruction in the stream which
caused a quite subtle bug.

    During instruction selection a statement `s`
    in a block B with control of the sort: B -> C
    will sometimes result in control
    flow of the sort:

            ┌ < ┐
            v   ^
      B ->  B1  ┴ -> C

    as is the case for some atomic operations.

    Now to keep the CFG in sync when introducing B1 we clearly
    want to insert it between B and C. However there is
    a catch when we have to deal with self loops.

    We might start with code and a CFG of these forms:

    loop:
        stmt1               ┌ < ┐
        ....                v   ^
        stmtX              loop ┘
        stmtY
        ....
        goto loop:

    Now we introduce B1:
                            ┌ ─ ─ ─ ─ ─┐
        loop:               │   ┌ <  ┐ │
        instrs              v   │    │ ^
        ....               loop ┴ B1 ┴ ┘
        instrsFromX
        stmtY
        goto loop:

    This is simple, all outgoing edges from loop now simply
    start from B1 instead and the code generator knows which
    new edges it introduced for the self loop of B1.

    Disaster strikes if the statement Y follows the same pattern.
    If we apply the same rule that all outgoing edges change then
    we end up with:

        loop ─> B1 ─> B2 ┬─┐
          │      │    └─<┤ │
          │      └───<───┘ │
          └───────<────────┘

    This is problematic. The edge B1->B1 is modified as expected.
    However the modification is wrong!

    The assembly in this case looked like this:

    _loop:
        <instrs>
    _B1:
        ...
        cmpxchgq ...
        jne _B1
        <instrs>
        <end _B1>
    _B2:
        ...
        cmpxchgq ...
        jne _B2
        <instrs>
        jmp loop

    There is no edge _B2 -> _B1 here. It's still a self loop onto _B1.

    The problem here is that really B1 should be two basic blocks.
    Otherwise we have control flow in the *middle* of a basic block.
    A contradiction!

    So to account for this we add yet another basic block marker:

    _B:
        <instrs>
    _B1:
        ...
        cmpxchgq ...
        jne _B1
        jmp _B1'
    _B1':
        <instrs>
        <end _B1>
    _B2:
        ...

    Now when inserting B2 we will only look at the outgoing edges of B1' and
    everything will work out nicely.

    You might also wonder why we don't insert jumps at the end of _B1'. There is
    no way another block ends up jumping to the labels _B1 or _B2 since they are
    essentially invisible to other blocks. View them as control flow labels local
    to the basic block if you'd like.

    Not doing this ultimately caused (part 2 of) #17334.

- - - - -
1f40e68a by Ryan Yates at 2019-10-23T05:59:03-04:00
Full abort on validate failure merging `orElse`.

Previously partial roll back of a branch of an `orElse` was attempted
if validation failure was observed.  Validation here, however, does
not account for what part of the transaction observed inconsistent
state.  This commit fixes this by fully aborting and restarting the
transaction.

- - - - -
9c1f0f7c by Ben Gamari at 2019-10-23T05:59:03-04:00
Bump stm submodule

- - - - -
6beea836 by Andreas Klebinger at 2019-10-23T05:59:04-04:00
Make dynflag argument for withTiming pure.

19 times out of 20 we already have dynflags in scope.

We could just always use `return dflags`. But this is in fact not free.
When looking at some STG code I noticed that we always allocate a
closure for this expression in the heap. Clearly a waste in these cases.

For the other cases we can either just modify the callsite to
get dynflags or use the _D variants of withTiming I added which
will use getDynFlags under the hood.

- - - - -
8dd480cc by Matthew Pickering at 2019-10-23T05:59:06-04:00
Performance tests: Reduce acceptance threshold for bytes allocated tests

The "new" performance testing infrastructure resets the baseline after
every test so it's easy to miss gradual performance regressions over
time. We should at least make these numbers smaller to catch patches
which affect performance earlier.

- - - - -
4af20bbc by Ben Gamari at 2019-10-23T05:59:06-04:00
users-guide: Fix :since: for -Wunused-packages

Fixes #17382.

- - - - -
21663693 by Ben Gamari at 2019-10-23T05:59:07-04:00
Drop duplicate -optl's from GHC invocations

Previously the make build system would pass things like
`-optl-optl-Wl,-x -optl-optl-Wl,noexecstack` to GHC. This would
naturally result in mass confusion as GHC would pass `-optl-Wl,-x` to
GCC. GCC would in turn interpret this as `-o ptl-Wl,-x`, setting the
output pass of the invocation.

The problem that `-optl` was added to the command-line in two places in
the build system. Fix this.

Fixes #17385.

- - - - -
bb0dc5a5 by Andreas Klebinger at 2019-10-23T05:59:07-04:00
Hadrian: Invoke ghc0 via bash when running tests to fix #17362.

cmd uses RawCommand which uses Windows semantics to find the executable
which sometimes seems to fail for unclear reasons.

If we invoke ghc via bash then bash will find the ghc executable and
the issue goes away.

- - - - -
266435a7 by Ömer Sinan Ağacan at 2019-10-23T05:59:09-04:00
Add new flag for unarised STG dumps

Previously -ddump-stg would dump pre and post-unarise STGs. Now we have
a new flag for post-unarise STG and -ddump-stg only dumps coreToStg
output.

STG dump flags after this commit:

- -ddump-stg: Dumps CoreToStg output
- -ddump-stg-unarised: Unarise output
- -ddump-stg-final: STG right before code gen (includes CSE and lambda
  lifting)

- - - - -
8abddac8 by Ben Gamari at 2019-10-23T05:59:10-04:00
base: Add @since on GHC.IO.Handle.Lock.hUnlock

Unfortunately this was introduced in base-4.11.0 (GHC 8.4.1)
whereas the other locking primitives were added in base-4.10.0 (GHC
8.2.1).

- - - - -
7f72b540 by Ben Gamari at 2019-10-23T14:56:46-04:00
Merge non-moving garbage collector

This introduces a concurrent mark & sweep garbage collector to manage the old
generation. The concurrent nature of this collector typically results in
significantly reduced maximum and mean pause times in applications with large
working sets.

Due to the large and intricate nature of the change I have opted to
preserve the fully-buildable history, including merge commits, which is
described in the "Branch overview" section below.

Collector design
================

The full design of the collector implemented here is described in detail
in a technical note

> B. Gamari. "A Concurrent Garbage Collector For the Glasgow Haskell
> Compiler" (2018)

This document can be requested from @bgamari.
The basic heap structure used in this design is heavily inspired by

> K. Ueno & A. Ohori. "A fully concurrent garbage collector for
> functional programs on multicore processors." /ACM SIGPLAN Notices/
> Vol. 51. No. 9 (presented at ICFP 2016)

This design is intended to allow both marking and sweeping
concurrent to execution of a multi-core mutator. Unlike the Ueno design,
which requires no global synchronization pauses, the collector
introduced here requires a stop-the-world pause at the beginning and end
of the mark phase.

To avoid heap fragmentation, the allocator consists of a number of
fixed-size /sub-allocators/. Each of these sub-allocators allocators into
its own set of /segments/, themselves allocated from the block
allocator. Each segment is broken into a set of fixed-size allocation
blocks (which back allocations) in addition to a bitmap (used to track
the liveness of blocks) and some additional metadata (used also used
to track liveness).

This heap structure enables collection via mark-and-sweep, which can be
performed concurrently via a snapshot-at-the-beginning scheme (although
concurrent collection is not implemented in this patch).

Implementation structure
========================

The majority of the collector is implemented in a handful of files:

 * `rts/Nonmoving.c` is the heart of the beast. It implements the entry-point
   to the nonmoving collector (`nonmoving_collect`), as well as the allocator
   (`nonmoving_allocate`) and a number of utilities for manipulating the heap.

 * `rts/NonmovingMark.c` implements the mark queue functionality, update
   remembered set, and mark loop.

 * `rts/NonmovingSweep.c` implements the sweep loop.

 * `rts/NonmovingScav.c` implements the logic necessary to scavenge the
   nonmoving heap.

Branch overview
===============

```
 * wip/gc/opt-pause:
 |   A variety of small optimisations to further reduce pause times.
 |
 * wip/gc/compact-nfdata:
 |   Introduce support for compact regions into the non-moving
 |\  collector
 | \
 |  \
 | | * wip/gc/segment-header-to-bdescr:
 | | |   Another optimization that we are considering, pushing
 | | |   some segment metadata into the segment descriptor for
 | | |   the sake of locality during mark
 | | |
 | * | wip/gc/shortcutting:
 | | |   Support for indirection shortcutting and the selector optimization
 | | |   in the non-moving heap.
 | | |
 * | | wip/gc/docs:
 | |/    Work on implementation documentation.
 | /
 |/
 * wip/gc/everything:
 |   A roll-up of everything below.
 |\
 | \
 | |\
 | | \
 | | * wip/gc/optimize:
 | | |   A variety of optimizations, primarily to the mark loop.
 | | |   Some of these are microoptimizations but a few are quite
 | | |   significant. In particular, the prefetch patches have
 | | |   produced a nontrivial improvement in mark performance.
 | | |
 | | * wip/gc/aging:
 | | |   Enable support for aging in major collections.
 | | |
 | * | wip/gc/test:
 | | |   Fix up the testsuite to more or less pass.
 | | |
 * | | wip/gc/instrumentation:
 | | |   A variety of runtime instrumentation including statistics
 | | /   support, the nonmoving census, and eventlog support.
 | |/
 | /
 |/
 * wip/gc/nonmoving-concurrent:
 |   The concurrent write barriers.
 |
 * wip/gc/nonmoving-nonconcurrent:
 |   The nonmoving collector without the write barriers necessary
 |   for concurrent collection.
 |
 * wip/gc/preparation:
 |   A merge of the various preparatory patches that aren't directly
 |   implementing the GC.
 |
 |
 * GHC HEAD
 .
 .
 .
```

- - - - -
83655b06 by Ben Gamari at 2019-10-24T08:45:41-04:00
hadrian: Warn user if hadrian build fails due to lack of threaded RTS

See #16873.

- - - - -
6824f29a by Ryan Scott at 2019-10-24T08:46:19-04:00
Parenthesize GADT return types in pprIfaceConDecl (#17384)

We were using `pprIfaceAppArgs` instead of `pprParendIfaceAppArgs`
in `pprIfaceConDecl`. Oops.

Fixes #17384.

- - - - -
9de3f8b1 by Ryan Scott at 2019-10-24T18:38:32-04:00
Make isTcLevPoly more conservative with newtypes (#17360)

`isTcLevPoly` gives an approximate answer for when a type constructor
is levity polymorphic when fully applied, where `True` means
"possibly levity polymorphic" and `False` means "definitely not
levity polymorphic". `isTcLevPoly` returned `False` for newtypes,
which is incorrect in the presence of `UnliftedNewtypes`, leading
to #17360. This patch tweaks `isTcLevPoly` to return `True` for
newtypes instead.

Fixes #17360.

- - - - -
243c72eb by Ryan Scott at 2019-10-24T18:39:08-04:00
Mark promoted InfixT names as IsPromoted (#17394)

We applied a similar fix for `ConT` in #15572 but forgot to apply the
fix to `InfixT` as well. This patch fixes #17394 by doing just that.

- - - - -
87175e78 by James Foster at 2019-10-25T09:01:08-04:00
Make Hadrian use -dynamic-too in the basic case

This commit makes Hadrian use the `-dynamic-too` flag when the current
Flavour's libraryWays contains both vanilla and dynamic, cutting down
the amount of repeated work caused by separate compilation of dynamic
and static files. It does this for the basic case where '.o' and
'.dyn_o' files are built with one command, but does not generalise to
cases like '.prof_o' and '.prof_dyn_o'.

- - - - -
ecd89062 by Alp Mestanogullari at 2019-10-25T09:01:47-04:00
hadrian/ci: run testsuite against a freshly produced and installed bindist

- - - - -
2a16b555 by Ben Gamari at 2019-10-25T09:02:26-04:00
testsuite: Mark T13786 as fragile in unreg build

Due to #17018.

- - - - -
08298926 by Ben Gamari at 2019-10-25T09:02:26-04:00
testsuite: Use fragile modifier in TH_foreignInterruptible

It looks like this use of `skip` snuck through my previous refactoring.

- - - - -
4c7d45d1 by Brian Wignall at 2019-10-25T09:03:04-04:00
Make documentation for byteSwap16 consistent with byteSwap32 (impl is same, with s/16/32)

- - - - -
02822d84 by Ben Gamari at 2019-10-25T09:03:40-04:00
aclocal: A bit of reformatting

- - - - -
519f5162 by Ben Gamari at 2019-10-25T09:03:40-04:00
configure: Drop GccLT46

GCC 4.6 was released 7 years ago. I think we can finally assume that
it's available. This is a simplification prompted by #15742.

- - - - -
acedfc8b by Ben Gamari at 2019-10-25T09:04:16-04:00
gitlab-ci: Run check-uniques during lint job

- - - - -
8916e64e by Andrew Martin at 2019-10-26T05:19:38-04:00
Implement shrinkSmallMutableArray# and resizeSmallMutableArray#.

This is a part of GHC Proposal #25: "Offer more array resizing primitives".
Resources related to the proposal:

  - Discussion: https://github.com/ghc-proposals/ghc-proposals/pull/121
  - Proposal: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0025-resize-boxed.rst

Only shrinkSmallMutableArray# is implemented as a primop since a
library-space implementation of resizeSmallMutableArray# (in GHC.Exts)
is no less efficient than a primop would be. This may be replaced by
a primop in the future if someone devises a strategy for growing
arrays in-place. The library-space implementation always copies the
array when growing it.

This commit also tweaks the documentation of the deprecated
sizeofMutableByteArray#, removing the mention of concurrency. That
primop is unsound even in single-threaded applications. Additionally,
the non-negativity assertion on the existing shrinkMutableByteArray#
primop has been removed since this predicate is trivially always true.

- - - - -
1be9c35c by Roland Senn at 2019-10-26T05:20:14-04:00
Fix #14690 - :steplocal panics after break-on-error

`:steplocal` enables only breakpoints in the current top-level binding.

When a normal breakpoint is hit, then the module name and the break id from the `BRK_FUN` byte code
allow us to access the corresponding entry in a ModBreak table. From this entry we then get the SrcSpan
(see compiler/main/InteractiveEval.hs:bindLocalsAtBreakpoint).
With this source-span we can then determine the current top-level binding, needed for the steplocal command.

However, if we break at an exception or at an error, we don't have an BRK_FUN byte-code, so we don't have any source information.
The function `bindLocalsAtBreakpoint` creates an `UnhelpfulSpan`, which doesn't allow us to determine the current top-level binding.
To avoid a `panic`, we have to check for `UnhelpfulSpan` in the function `ghc/GHCi/UI.hs:stepLocalCmd`.
Hence a :steplocal command after a break-on-exception or a break-on-error is not possible.

- - - - -
4820af10 by Adam Sandberg Eriksson at 2019-10-26T19:53:01-04:00
hadrian: point link to ghc gitlab

[skip ci]

- - - - -
609c7ee6 by Ben Gamari at 2019-10-26T19:53:36-04:00
gitlab-ci: Produce ARMv7 binary distributions

- - - - -
8ac49411 by Ben Gamari at 2019-10-26T19:53:36-04:00
testsuite: Skip regalloc_unit_tests unless have_ncg

This is a unit test for the native code generator's register allocator;
naturally. the NCG is required.

- - - - -
60575596 by Ben Gamari at 2019-10-26T19:53:36-04:00
Enable PDF documentation

- - - - -
417f59d4 by Ben Gamari at 2019-10-26T19:53:36-04:00
rts: Fix ARM linker includes

 * Prefer #pragma once over guard macros
 * Drop redundant #includes
 * Fix order to ensure that necessary macros are defined when we
   condition on them

- - - - -
4054f0e5 by Ömer Sinan Ağacan at 2019-10-26T19:54:16-04:00
Remove redundant -fno-cse options

These were probably added with some GLOBAL_VARs, but those GLOBAL_VARs
are now gone.

- - - - -
c62817f2 by Luke Lau at 2019-10-27T11:35:40-04:00
Fix RankNTypes :ghc-flag: in users guide

This fixes a hadrian `build docs` failure

- - - - -
fc3a5205 by Luke Lau at 2019-10-27T11:35:40-04:00
Remove unused import

- - - - -
d2520bef by Luke Lau at 2019-10-27T11:35:40-04:00
Fix path to ghc-flags in users guide Hadrian rules

It should point to the _build directory, not the source

- - - - -
896d470a by Luke Lau at 2019-10-27T11:35:40-04:00
Add back documentation for deprecated -Whi-shadowing

This was removed in b538476be3706264620c072e6e436debf9e0d3e4, but
without it the compare-flags.py script fails. This adds it back and
marks it as deprecated, with a notice that it is slated for removal.

- - - - -
7d80f8b5 by Luke Lau at 2019-10-27T11:35:40-04:00
Remove documented flags from expected-undocumented-flags.txt

- - - - -
fa0d4809 by Ryan Scott at 2019-10-27T11:36:17-04:00
Parenthesize nullary constraint tuples using sigPrec (#17403)

We were using `appPrec`, not `sigPrec`, as the precedence when
determining whether or not to parenthesize `() :: Constraint`,
which lead to the parentheses being omitted in function contexts
like `(() :: Constraint) => String`. Easily fixed.

Fixes #17403.

- - - - -
90d06fd0 by Ben Gamari at 2019-10-27T17:27:17-04:00
hadrian: Silence output from Support SMP check

Previously we would allow the output from the check of SMP support
introduced by 83655b06e6d3e93b2d15bb0fa250fbb113d7fe68 leak to
stdout. Silence this.

See #16873.
- - - - -
6635a3f6 by Josef Svenningsson at 2019-10-28T09:20:34-04:00
Fix #15344: use fail when desugaring applicative-do

Applicative-do has a bug where it fails to use the monadic fail method
when desugaring patternmatches which can fail. See #15344.

This patch fixes that problem. It required more rewiring than I had expected.
Applicative-do happens mostly in the renamer; that's where decisions about
scheduling are made. This schedule is then carried through the typechecker and
into the desugarer which performs the actual translation. Fixing this bug
required sending information about the fail method from the renamer, through
the type checker and into the desugarer. Previously, the desugarer didn't
have enough information to actually desugar pattern matches correctly.

As a side effect, we also fix #16628, where GHC wouldn't catch missing
MonadFail instances with -XApplicativeDo.

- - - - -
cd9b9459 by Ryan Scott at 2019-10-28T09:21:13-04:00
Refactor TcDeriv to validity-check less in anyclass/via deriving (#13154)

Due to the way `DerivEnv` is currently structured, there is an
invariant that every derived instance must consist of a class applied
to a non-empty list of argument types, where the last argument *must*
be an application of a type constructor to some arguments. This works
for many cases, but there are also some design patterns in standalone
`anyclass`/`via` deriving that are made impossible due to enforcing
this invariant, as documented in #13154.

This fixes #13154 by refactoring `TcDeriv` and friends to perform
fewer validity checks when using the `anyclass` or `via` strategies.
The highlights are as followed:

* Five fields of `DerivEnv` have been factored out into a new
  `DerivInstTys` data type. These fields only make sense for
  instances that satisfy the invariant mentioned above, so
  `DerivInstTys` is now only used in `stock` and `newtype` deriving,
  but not in other deriving strategies.
* There is now a `Note [DerivEnv and DerivSpecMechanism]` describing
  the bullet point above in more detail, as well as explaining the
  exact requirements that each deriving strategy imposes.
* I've refactored `mkEqnHelp`'s call graph to be slightly less
  complicated. Instead of the previous `mkDataTypeEqn`/`mkNewTypeEqn`
  dichotomy, there is now a single entrypoint `mk_eqn`.
* Various bits of code were tweaked so as not to use fields that are
  specific to `DerivInstTys` so that they may be used by all deriving
  strategies, since not all deriving strategies use `DerivInstTys`.

- - - - -
e0e04856 by Alan Zimmerman at 2019-10-28T09:21:58-04:00
Attach API Annotations for {-# SOURCE #-} import pragma

Attach the API annotations for the start and end locations of the
{-# SOURCE #-} pragma in an ImportDecl.

Closes #17388

- - - - -
e951f219 by Sebastian Graf at 2019-10-28T09:22:35-04:00
Use FlexibleInstances for `Outputable (* p)` instead of match-all instances with equality constraints

In #17304, Richard and Simon dicovered that using `-XFlexibleInstances`
for `Outputable` instances of AST data types means users can provide orphan
`Outputable` instances for passes other than `GhcPass`.

Type inference doesn't currently to suffer, and Richard gave an example
in #17304 that shows how rare a case would be where the slightly worse
type inference would matter.

So I went ahead with the refactoring, attempting to fix #17304.

- - - - -
ad1fe274 by Simon Peyton Jones at 2019-10-28T09:23:14-04:00
Better arity for join points

A join point was getting too large an arity, leading to #17294.
I've tightened up the invariant: see
  CoreSyn, Note [Invariants on join points], invariant 2b

- - - - -
fb4f245c by Takenobu Tani at 2019-10-29T03:45:02-04:00
users-guide: Fix :since: for -xn flag

[skip ci]

- - - - -
35abbfee by Takenobu Tani at 2019-10-29T03:45:41-04:00
users-guide: Add some new features and fix warnings for GHC 8.10

This updates the following:

* Add description for ImportQualifiedPost extension
* Add description for ghci command name resolution
* Fix markdown warnings

[skip ci]

- - - - -
57dc1565 by Sylvain Henry at 2019-10-29T03:46:22-04:00
Use `not#` primitive to implement Word's complement

- - - - -
28e52732 by Ben Gamari at 2019-10-29T03:46:59-04:00
linters: Add mode to lint given set of files

This makes testing much easier.

- - - - -
db43b3b3 by Ben Gamari at 2019-10-29T03:46:59-04:00
linters: Add linter to catch unquoted use of $(TEST_HC)

This is a common bug that creeps into Makefiles (e.g. see T12674).

- - - - -
ebee0d6b by Ben Gamari at 2019-10-29T03:46:59-04:00
testsuite: Fix quoting of $(TEST_HC) in T12674

I have no idea how this went unnoticed until now.

- - - - -
3bd3456f by Ömer Sinan Ağacan at 2019-10-29T03:47:44-04:00
Refactor HscRecomp constructors:

Make it evident in the constructors that the final interface is only
available when HscStatus is not HscRecomp.

(When HscStatus == HscRecomp we need to finish the compilation to get
the final interface)

`Maybe ModIface` return value of hscIncrementalCompile and the partial
`expectIface` function are removed.

- - - - -
bbdd54aa by Ömer Sinan Ağacan at 2019-10-29T03:47:44-04:00
Return ModIface in compilation pipeline, remove IORef hack for generating ModIfaces

The compilation phases now optionally return ModIface (for phases that
generate an interface, currently only HscOut when (re)compiling a file).
The value is then used by compileOne' to return the generated interface
with HomeModInfo (which is then used by the batch mode compiler when
building rest of the tree).

hscIncrementalMode also returns a DynFlags with plugin info, to be used
in the rest of the pipeline.

Unfortunately this introduces a (perhaps less bad) hack in place of the
previous IORef: we now record the DynFlags used to generate the partial
infterface in HscRecomp and use the same DynFlags when generating the
full interface. I spent almost three days trying to understand what's
changing in DynFlags that causes a backpack test to fail, but I couldn't
figure it out. There's a FIXME added next to the field so hopefully
someone who understands this better than I do will fix it leter.

- - - - -
a56433a9 by Ömer Sinan Ağacan at 2019-10-29T03:47:44-04:00
Remove unused DynFlags arg of lookupIfaceByModule

- - - - -
dcd40c71 by Ömer Sinan Ağacan at 2019-10-29T03:47:44-04:00
HscMain: Move a comment closer to the relevant site

- - - - -
593f6543 by Ömer Sinan Ağacan at 2019-10-29T03:47:44-04:00
MkIface: Remove redundant parameter and outdated comments from addFingerprints

- - - - -
f868e1fe by Ben Gamari at 2019-10-29T03:48:20-04:00
gitlab-ci: Use Hadrian for unregisterised job

- - - - -
7b2ecbc0 by Ben Gamari at 2019-10-29T03:48:20-04:00
gitlab-ci: Factor out Linux Hadrian validation logic

- - - - -
8e5de15d by Ben Gamari at 2019-10-29T03:48:20-04:00
hadrian: Define USE_LIBFFI_FOR_ADJUSTORS when necessary

- - - - -
6a090270 by Ben Gamari at 2019-10-29T03:48:20-04:00
hadrian: Define NOSMP when building rts unregisterised

It seems that NOSMP was previously only defined when compiling the
compiler, not the RTS. Fix this.

In addition do some spring-cleaning and make the logic match that of the
Make build system.

- - - - -
b741d19d by Ben Gamari at 2019-10-29T03:48:20-04:00
hadrian: Shuffle around RTS build flags

Some of these flags wanted to be passed to .cmm builds as well as C
builds.

- - - - -
d7cedd9d by Ben Gamari at 2019-10-29T03:48:20-04:00
hadrian: Drop -Werror=unused-but-set-variable from GHC flags

Previously `hadrian` would pass `-optc-Werror=unused-but-set-variable`
to all GHC invocations. This was a difference from the make build system
and cause the unregisterised build to fail as the C that GHC produces
contains many unused functions. Drop it from the GHC flags.

Note, however, that the flag is still present in
`Settings.Builders.Common.cWarnings` and therefore will still be applied
during compilation of C sources.

- - - - -
7d3a15c7 by Ben Gamari at 2019-10-29T03:48:55-04:00
base: Fix open-file locking

The OFD locking path introduced in
3b784d440d4b01b4c549df7c9a3ed2058edfc780 due to #13945 appears to have
never actually worked but we never noticed due to an oversight in the
autoconf check. Fix it.

Thanks to Oleg Grenrus for noticing this.

- - - - -
78b70e63 by Ben Gamari at 2019-10-29T03:48:55-04:00
base: Split up file locking implementation

This makes the CPP significantly easier to follow.

- - - - -
63977398 by Ben Gamari at 2019-10-29T03:49:31-04:00
Don't substitute GccVersion variable

Not only is it now unused but we generally can't assume that we are
compiling with GCC, so it really shouldn't be used.

- - - - -
72f7ac9a by Ben Gamari at 2019-10-29T03:50:06-04:00
Revert "Replace freebsd-gnueabihf with freebsd"

This reverts commit aa31ceaf7568802590f73a740ffbc8b800096342 as
suggested in #17392.

- - - - -
3c0372d6 by Ben Gamari at 2019-10-29T20:31:36-04:00
distrib: Fix binary distribution installation

This had silently regressed due to 81860281 and the variable renaming performed
in b55ee979, as noted in #17374.

- - - - -
a7f423ee by Ben Gamari at 2019-10-29T20:31:36-04:00
gitlab-ci: Use pxz to compress binary distributions

- - - - -
db602643 by Ben Gamari at 2019-10-29T20:31:36-04:00
Don't include settings file in binary distribution

The configuration in the installation environment (as determined by
`autoconf`) may differ from the build environment and therefore we
need to be sure to rebuild the settings file.

Fixes #17374.

- - - - -
260e2379 by Ben Gamari at 2019-10-29T20:31:36-04:00
gitlab-ci: Fix binary distribution testing

- - - - -
01ef3e1f by Ömer Sinan Ağacan at 2019-10-29T20:32:18-04:00
Interpreter: initialize arity fields of AP_NOUPDs

AP_NOUPD entry code doesn't use the arity field, but not initializing
this field confuses printers/debuggers, and also makes testing harder as
the field's value changes randomly.

- - - - -
93ff9197 by Ben Gamari at 2019-10-30T07:36:49-04:00
rts: More aarch64 header fixes

- - - - -
3e7569bc by Vladislav Zavialov at 2019-10-30T07:36:50-04:00
Whitespace forward compatibility for proposal #229

GHC Proposal #229 changes the lexical rules of Haskell, which may
require slight whitespace adjustments in certain cases.

This patch changes formatting in a few places in GHC and its testsuite
in a way that enables it to compile under the proposed rules.

- - - - -
4898df1c by Ben Gamari at 2019-10-30T18:15:52-04:00
gitlab-ci: Fix the ARMv7 triple

Previously we were configuring the ARMv7 builds with a host/target
triple of arm-linux-gnueabihf, which caused us to target ARMv6 and
consequently rely on the old CP15 memory barrier implementation. This
barrier has to be emulated on ARMv8 machines which is glacially slow.

Hopefully this should fix the ARMv7 builds which currently consistently
time out.

- - - - -
337e9b5a by Ömer Sinan Ağacan at 2019-10-31T19:01:54-04:00
Remove redundant 0s in ghc-heap pointer strings

Before: 0x0000004200c86888
After:  0x42000224f8

This is more concise and consistent with the RTS's printer (which uses
%p formatter, and at least on Linux gcc prints the short form) and gdb's
pointer formatter.

- - - - -
97b6f7a3 by Ben Gamari at 2019-10-31T19:02:32-04:00
base: Clamp IO operation size to 2GB on Darwin

As reported in #17414, Darwin throws EINVAL in response to large
writes.

- - - - -
a9743eb7 by Ben Gamari at 2019-10-31T19:02:32-04:00
testsuite: Add test for #17414

- - - - -
73d6e508 by Ben Gamari at 2019-10-31T19:03:10-04:00
base: Various haddock fixes

Just a few things I found while looking at #17383.

- - - - -
dc487642 by taylorfausak at 2019-11-01T04:54:47-04:00
Implement `round` for `Ratio` that doesn't explode with `Natural`s
- - - - -
3932fb97 by taylorfausak at 2019-11-01T04:54:47-04:00
Fix rounding around 0
- - - - -
baf47ff8 by taylorfausak at 2019-11-01T04:54:47-04:00
Add tests for rounding ratios
- - - - -
214d8122 by taylorfausak at 2019-11-01T04:54:47-04:00
Fix running of ratio test case
- - - - -
70b62c97 by Ben Gamari at 2019-11-01T04:55:24-04:00
mmap: Factor out protection flags

- - - - -
c6759080 by Ben Gamari at 2019-11-01T04:55:24-04:00
rts: Make m32 allocator per-ObjectCode

MacOS Catalina is finally going to force our hand in forbidden writable
exeutable mappings. Unfortunately, this is quite incompatible with the
current global m32 allocator, which mixes symbols from various objects
in a single page. The problem here is that some of these symbols may not
yet be resolved (e.g. had relocations performed) as this happens lazily
(and therefore we can't yet make the section read-only and therefore
executable).

The easiest way around this is to simply create one m32 allocator per
ObjectCode. This may slightly increase fragmentation for short-running
programs but I suspect will actually improve fragmentation for programs
doing lots of loading/unloading since we can always free all of the
pages allocated to an object when it is unloaded (although this ability
will only be implemented in a later patch).

- - - - -
35c99e72 by Simon Peyton Jones at 2019-11-01T04:56:02-04:00
Makes Lint less chatty:

I found in #17415 that Lint was printing out truly gigantic
warnings, unmanageably huge, with repeated copies of the
same thing.

This patch makes Lint less chatty, especially for warnings:

* For **warnings**, I don't print details of the location,
  unless you add `-dppr-debug`.

* For **errors**, I still print all the info. They are fatal
  and stop exection, whereas warnings appear repeatedly.

* I've made much less use of `AnExpr` in `LintLocInfo`;
  the expression can be gigantic.

- - - - -
d2471964 by Simon Peyton Jones at 2019-11-01T04:56:38-04:00
Add another test for #17267

This one came in a comment from James Payor

- - - - -
1e2e82aa by Simon Peyton Jones at 2019-11-01T04:57:15-04:00
Fix a bad error in tcMatchTy

This patch fixes #17395, a very subtle and hard-to-trigger
bug in tcMatchTy.  It's all explained in
  Note [Matching in the presence of casts (2)]

I have not added a regression test because it is very hard
to trigger it, until we have the upcoming mkAppTyM patch,
after which lacking this patch means you can't even compile
the libraries.

- - - - -
51067194 by Ben Gamari at 2019-11-01T15:48:37-04:00
base: Ensure that failIO isn't SOURCE imported

failIO has useful information in its demand signature (specifically that
it bottoms) which is hidden if it is SOURCE imported, as noted
in #16588. Rejigger things such that we don't SOURCE import it.

Metric Increase:
    T13701

- - - - -
c751082c by Ben Gamari at 2019-11-01T15:48:37-04:00
testsuite: Make ExplicitForAllRules1 more robust

Previously the test relied on `id` not inlining. Fix this.

- - - - -
dab12c87 by Ben Gamari at 2019-11-01T15:48:37-04:00
Describe optimisation of demand analysis of noinline

As described in #16588.

- - - - -
c9236384 by Adam Sandberg Eriksson at 2019-11-01T15:49:16-04:00
template-haskell: require at least 1 GADT constructor name (#17379)

- - - - -
a4ce26e0 by Ben Gamari at 2019-11-01T15:49:53-04:00
hadrian: Make runtest invocation consistency with Make

Use True/False instead of 0/1. This shouldn't be a functional change but
we should be consistent.

- - - - -
cabafe34 by Ben Gamari at 2019-11-01T15:50:29-04:00
testsuite: Add test for #17423

- - - - -
4a6d3d68 by Simon Peyton Jones at 2019-11-01T23:11:37-04:00
Make CSE delay inlining less

CSE delays inlining a little bit, to avoid losing vital
specialisations; see Note [Delay inlining after CSE] in CSE.

But it was being over-enthusiastic.  This patch makes the
delay only apply to Ids with specialisation rules, which
avoids unnecessary delay (#17409).

- - - - -
01006bc7 by Niklas Hambüchen at 2019-11-01T23:12:17-04:00
doc: Fix backticks

- - - - -
9980fb58 by Niklas Hambüchen at 2019-11-01T23:12:17-04:00
Add +RTS --disable-delayed-os-memory-return. Fixes #17411.

Sets `MiscFlags.disableDelayedOsMemoryReturn`.

See the added `Note [MADV_FREE and MADV_DONTNEED]` for details.

- - - - -
182b1199 by Sebastian Graf at 2019-11-02T20:16:33-04:00
Separate `LPat` from `Pat` on the type-level

Since the Trees That Grow effort started, we had `type LPat = Pat`.
This is so that `SrcLoc`s would only be annotated in GHC's AST, which is
the reason why all GHC passes use the extension constructor `XPat` to
attach source locations. See #15495 for the design discussion behind
that.

But now suddenly there are `XPat`s everywhere!
There are several functions which dont't cope with `XPat`s by either
crashing (`hsPatType`) or simply returning incorrect results
(`collectEvVarsPat`).

This issue was raised in #17330. I also came up with a rather clean and
type-safe solution to the problem: We define

```haskell
type family XRec p (f :: * -> *) = r | r -> p f
type instance XRec (GhcPass p) f = Located (f (GhcPass p))
type instance XRec TH          f =          f p
type LPat p = XRec p Pat
```

This is a rather modular embedding of the old "ping-pong" style, while
we only pay for the `Located` wrapper within GHC. No ping-ponging in
a potential Template Haskell AST, for example. Yet, we miss no case
where we should've handled a `SrcLoc`: `hsPatType` and
`collectEvVarsPat` are not callable at an `LPat`.

Also, this gets rid of one indirection in `Located` variants:
Previously, we'd have to go through `XPat` and `Located` to get from
`LPat` to the wrapped `Pat`. Now it's just `Located` again.

Thus we fix #17330.

- - - - -
3c916162 by Richard Eisenberg at 2019-11-02T20:17:13-04:00
Update Note references -- comments only

Follow-on from !2041.

- - - - -
3b65655c by Ben Gamari at 2019-11-04T03:40:31-05:00
SysTools: Only apply Windows-specific workaround on Windows

Issue #1110 was apparently due to a bug in Vista which prevented GCC
from finding its binaries unless we explicitly added it to PATH.
However, this workaround was incorrectly applied on non-Windows
platforms as well, resulting in ill-formed PATHs (#17266).

Fixes #17266.

- - - - -
5d4f16ee by Leif Metcalf at 2019-11-04T03:41:09-05:00
Rephrase note on full-laziness

- - - - -
120f2e53 by Ben Gamari at 2019-11-04T03:41:44-05:00
rts/linker: Ensure that code isn't writable

For many years the linker would simply map all of its memory with
PROT_READ|PROT_WRITE|PROT_EXEC. However operating systems have been
becoming increasingly reluctant to accept this practice (e.g. #17353
and #12657) and for good reason: writable code is ripe for exploitation.

Consequently mmapForLinker now maps its memory with
PROT_READ|PROT_WRITE.  After the linker has finished filling/relocating
the mapping it must then call mmapForLinkerMarkExecutable on the
sections of the mapping which contain executable code.

Moreover, to make all of this possible it was necessary to redesign the
m32 allocator. First, we gave (in an earlier commit) each ObjectCode its
own m32_allocator. This was necessary since code loading and symbol
resolution/relocation are currently interleaved, meaning that it is not
possible to enforce W^X when symbols from different objects reside in
the same page.

We then redesigned the m32 allocator to take advantage of the fact that
all of the pages allocated with the allocator die at the same time
(namely, when the owning ObjectCode is unloaded). This makes a number of
things simpler (e.g. no more page reference counting; the interface
provided by the allocator for freeing is simpler). See
Note [M32 Allocator] for details.

- - - - -
7c28087a by Takenobu Tani at 2019-11-05T02:45:31-05:00
users-guide: Improve documentaion of CPP extension

Currently, the description of CPP extension is given in the section of
command-line options.
Therefore, it is a little difficult to understand that it is a language
extension.

This commit explicitly adds a description for it.

[skip ci]

- - - - -
d57059f7 by Ben Gamari at 2019-11-05T02:46:10-05:00
rts: Add missing const in HEAP_ALLOCED_GC

This was previously unnoticed as this code-path is hit on very few
platforms (e.g. OpenBSD).

- - - - -
487ede42 by Peter Trommler at 2019-11-05T02:46:48-05:00
testsuite: skip test requiring RTS linker on PowerPC

The RTS linker is not available on 64-bit PowerPC. Instead of
marking tests that require the RTS linker as broken on PowerPC
64-bit skip the respective tests on all platforms where the
RTS linker or a statically linked external interpreter is not
available.

Fixes #11259

- - - - -
1593debf by Sebastian Graf at 2019-11-05T11:38:30-05:00
Check EmptyCase by simply adding a non-void constraint

We can handle non-void constraints since !1733, so we can now express
the strictness of `-XEmptyCase` just by adding a non-void constraint
to the initial Uncovered set.

For `case x of {}` we thus check that the Uncovered set `{ x | x /~ ⊥ }`
is non-empty. This is conceptually simpler than the plan outlined in
 #17376, because it talks to the oracle directly.

In order for this patch to pass the testsuite, I had to fix handling of
newtypes in the pattern-match checker (#17248).

Since we use a different code path (well, the main code path) for
`-XEmptyCase` now, we apparently also handle #13717 correctly.
There's also some dead code that we can get rid off now.

`provideEvidence` has been updated to provide output more in line with
the old logic, which used `inhabitationCandidates` under the hood.

A consequence of the shift away from the `UncoveredPatterns` type is
that we don't report reduced type families for empty case matches,
because the pretty printer is pure and only knows the match variable's
type.

Fixes #13717, #17248, #17386

- - - - -
e6ffe148 by Ömer Sinan Ağacan at 2019-11-05T11:39:13-05:00
TidyPgm: replace an explicit loop with mapAccumL

- - - - -
b7460492 by Ömer Sinan Ağacan at 2019-11-05T11:39:13-05:00
CoreTidy: hide tidyRule

- - - - -
f9978f53 by Stefan Schulze Frielinghaus at 2019-11-05T11:39:51-05:00
Hadrian: enable interpreter for s390x

- - - - -
3ce18700 by Ben Gamari at 2019-11-06T08:05:57-05:00
rts: Drop redundant flags for libffi

These are now handled in the cabal file's include-dirs field.

- - - - -
ce9e2a1a by Ben Gamari at 2019-11-06T08:05:57-05:00
configure: Add --with-libdw-{includes,libraries} flags

Fixing #17255.

- - - - -
97f9674b by Takenobu Tani at 2019-11-06T08:06:37-05:00
configure: Add checking python3-sphinx

This checks the configuration about python3-sphinx.
We need python3-sphinx instead of python2-sphinx to build documentation.

The approach is as follows:
* Check python3 version with custom `conf.py` invoked from
  sphinx-build` executable
* Place custom `conf.py` into new `utils/check-sphinx` directory

If sphinx is for python2 not python3, it's treated as config ERROR
instead of WARN.

See also #17346 and #17356.

- - - - -
b4fb2328 by Dan Brooks at 2019-11-06T08:07:15-05:00
Adding examples to Semigroup/monoid

- - - - -
708c60aa by Ryan Scott at 2019-11-07T08:39:36-05:00
Clean up TH's treatment of unary tuples (or, #16881 part two)

!1906 left some loose ends in regards to Template Haskell's treatment
of unary tuples. This patch ends to tie up those loose ends:

* In addition to having `TupleT 1` produce unary tuples, `TupE [exp]`
  and `TupP [pat]` also now produce unary tuples.
* I have added various special cases in GHC's pretty-printers to
  ensure that explicit 1-tuples are printed using the `Unit` type.
  See `testsuite/tests/th/T17380`.
* The GHC 8.10.1 release notes entry has been tidied up a little.

Fixes #16881. Fixes #17371. Fixes #17380.

- - - - -
a424229d by Stefan Schulze Frielinghaus at 2019-11-07T08:40:13-05:00
For s390x issue a warning if LLVM 9 or older is used

For s390x the GHC calling convention is only supported since LLVM
version 10.  Issue a warning in case an older version of LLVM is used.

- - - - -
55bc3787 by Ben Gamari at 2019-11-07T08:40:50-05:00
FlagChecker: Add ticky flags to hashed flags

These affect output and therefore should be part of the flag hash.

- - - - -
fa0b1b4b by Stefan Schulze Frielinghaus at 2019-11-07T08:41:33-05:00
Bump libffi-tarballs submodule

- - - - -
a9566632 by Takenobu Tani at 2019-11-07T08:42:15-05:00
configure: Modify ERROR to WARN for sphinx's python check

If sphinx's python version check failed, many people prefer to build
without documents instead of stopping on the error.

So this commit fixes the following:

* Modify AC_MSG_ERROR to AC_MSG_WARN
* Add clearing of SPHINXBUILD variable when check fails

See also !2016.

- - - - -
d0ef8312 by Alp Mestanogullari at 2019-11-07T21:24:59-05:00
hadrian: fix support for the recording of perf test results

Before this patch, Hadrian didn't care about the TEST_ENV and
METRICS_FILE environment variables, that the performance testing
infrastructure uses to record perf tests results from CI jobs.

It now looks them up right before running the testsuite driver,
and passes suitable --test-env/--metrics-file arguments when
these environment variables are set.

- - - - -
601e554c by Ben Gamari at 2019-11-07T21:25:36-05:00
Bump the process submodule

This should fix the #17108 and #17249 with the fix from
https://github.com/haskell/process/pull/159.

- - - - -
6b7d7e1c by Ben Gamari at 2019-11-07T21:25:36-05:00
Bump hsc2hs submodule

- - - - -
b1c158c9 by Ben Gamari at 2019-11-07T21:25:36-05:00
rts: Fix m32 allocator build on Windows

An inconsistency in the name of m32_allocator_flush caused the build to
fail with a missing prototype error.

- - - - -
ae431cf4 by Ben Gamari at 2019-11-07T21:25:36-05:00
rts: Ensure that Rts.h is always included first

In general this is the convention that we use in the RTS. On Windows
things actually fail if we break it. For instance, you see things like:

   includes\stg\Types.h:26:9: error:
     warning: #warning "Mismatch between __USE_MINGW_ANSI_STDIO
     definitions. If using Rts.h make sure it is the first header
     included." [-Wcpp]

- - - - -
0d141d28 by Ben Gamari at 2019-11-07T21:25:36-05:00
rts: Remove undesireable inline specifier

I have no idea why I marked this as inline originally but clearly it
shouldn't be inlined.

- - - - -
870376f9 by Ben Gamari at 2019-11-07T21:25:36-05:00
base: Add missing imports in Windows locking implementation

- - - - -
23994738 by Ben Gamari at 2019-11-07T21:25:36-05:00
rts/NonMoving: Fix various Windows build issues

The Windows build seems to be stricter about not providing threading
primitives in the non-threaded RTS.

- - - - -
a3ce52fd by Ben Gamari at 2019-11-07T21:25:36-05:00
users_guide: Set flags list file encoding

Otherwise this fails on Windows.

- - - - -
9db2e905 by Stefan Schulze Frielinghaus at 2019-11-08T05:36:54-05:00
Testsuite: Introduce req_rts_linker

Some tests depend on the RTS linker. Introduce a modifier to skip such
tests, in case the RTS linker is not available.

- - - - -
a4631335 by Szymon Nowicki-Korgol at 2019-11-08T05:37:34-05:00
Set correct length of DWARF .debug_aranges section (fixes #17428)

- - - - -
3db2ab30 by Ben Gamari at 2019-11-08T05:38:11-05:00
hadrian: Add enableTickyGhc helper

This took a bit of trial-and-error to get working so it seems worth
having in the tree.

- - - - -
5c87ebd7 by Ben Gamari at 2019-11-08T12:09:22-05:00
SetLevels: Don't set context level when floating cases

When floating a single-alternative case we previously would set the
context level to the level where we were floating the case. However,
this is wrong as we are only moving the case and its binders. This
resulted in #16978, where the disrepancy caused us to
unnecessarily abstract over some free variables of the case body,
resulting in shadowing and consequently Core Lint failures.

(cherry picked from commit a2a0e6f3bb2d02a9347dec4c7c4f6d4480bc2421)

- - - - -
43623b09 by Ben Gamari at 2019-11-08T12:10:01-05:00
testsuite: Run tests in nonmoving_thr in speed==slow

- - - - -
6e4656cc by Ben Gamari at 2019-11-08T12:10:01-05:00
rts/nonmoving: Catch failure of createOSThread

- - - - -
2e4fc04b by Ben Gamari at 2019-11-08T12:10:01-05:00
Bump unix submodule

Marks executeFile001 as broken in all concurrent ways.

- - - - -
8a10f9fb by Ben Gamari at 2019-11-09T18:03:01-05:00
template-haskell: Document assembler foreign file support

See #16180.

- - - - -
5ad3cb53 by Ben Gamari at 2019-11-09T18:03:01-05:00
template-haskell: Fix TBAs in changelog

- - - - -
4a75a832 by Ben Gamari at 2019-11-09T18:03:01-05:00
base: Fix TBA in changelog

- - - - -
d7de0d81 by Ryan Scott at 2019-11-09T18:03:02-05:00
template-haskell: Fix italics in changelog

[ci-skip]

- - - - -
0fb246c3 by Ben Gamari at 2019-11-09T18:03:37-05:00
testsuite: Fix Windows cleanup path

This was a regression introduced with the Path refactoring.

- - - - -
925fbdbb by Ben Gamari at 2019-11-09T18:03:37-05:00
testsuite: Skip T16916 on Windows

The event manager is not supported on Windows.

- - - - -
7c2ce0a0 by Ben Gamari at 2019-11-09T18:03:38-05:00
testsuite: Skip T14931 on Windows

This test uses -dynamic-too, which is not supported on Windows.

- - - - -
7c63edb4 by Ben Gamari at 2019-11-09T18:03:38-05:00
gitlab-ci: Don't allow Windows make job to fail

While linking is still slow (#16084) all of the correctness issues which were
preventing us from being able to enforce testsuite-green on Windows are now
resolved.

- - - - -
a50ecda6 by Ben Gamari at 2019-11-09T18:03:38-05:00
testsuite: Fix header #include order on Windows

<Rts.h> must always come first.

- - - - -
dcb23ec9 by Ben Gamari at 2019-11-09T18:03:38-05:00
testsuite: Mark T13676 as broken on Darwin and Windows

Due to #17447.

- - - - -
411ba7ba by Ben Gamari at 2019-11-09T18:03:38-05:00
testsuite: Mark T11627b as fragile

It was previously marked as broken due to #12236 however it passes for
me locally while failing on CI.

- - - - -
c1f1f3f9 by Ben Gamari at 2019-11-09T18:03:38-05:00
testsuite: Mark T16219 as unbroken

This was previously broken due to #16386 yet it passes for me locally.

- - - - -
1f871e70 by Ben Gamari at 2019-11-09T18:03:38-05:00
testsuite: Remove redundant cleaning logic from T16511

The GHCi script for T16511 had some `rm` commands to clean up output
from previous runs. This should be harmless since stderr was redirected
to /dev/null; however, it seems that this redirection doesn't work on
Windows (perhaps because GHCi uses `cmd` to execute the command-line;
I'm not sure). I tried to fix it but was unable to find a sensible
solution.

Regardless, the cleaning logic is quite redundant now that we run each
test in a hermetic environment. Let's just remove it.

- - - - -
4d523cb1 by Ben Gamari at 2019-11-09T18:03:38-05:00
testsuite: Mark T17414 as fragile on Windows

This consistently times out on Windows as described in #17453. I have tried
increasing the timeout multiplier to two yet it stills fails. Disabling
until we have time to investigate.

- - - - -
f73fbd2d by Ben Gamari at 2019-11-09T18:03:38-05:00
testsuite: Ignore stderr in PartialDownsweep

As described in #17449, PartialDownsweep is currently fragile due to its
dependence on the error messages produced by the C preprocessor. To eliminate
this dependence we simply ignore stderr output, instead relying on the fact
that the test will exit with a non-zero exit code on failure.

Fixes #17449.

- - - - -
a9b14790 by Ben Gamari at 2019-11-09T18:03:38-05:00
testsuite: Fix putStrLn in saks028

Bizarrely, `saks028` previously failed reliably, but only on Windows
(#17450). The test would exit with a zero exit code but simply didn't
emit the expected text to stderr.

I believe this was due to the fact that the test used `putStrLn`,
resulting in the output ending up on stdout. This worked on other
platforms since (apparently) we redirect stdout to stderr when
evaluating splices. However, on Windows it seems that the redirected
output wasn't flushed as it was on other platforms.

Anyways, it seems like the right thing to do here is to be explicit
about our desire for the output to end up on stderr.

Closes #17450.

- - - - -
b62ca659 by Ben Gamari at 2019-11-09T18:03:38-05:00
testsuite: Drop T7995

This test is quite sensitive to the build configuration as it requires that ghc
have unfoldings, which isn't true in the quick build flavours. I considered
various options to make the test more robust but none of them seemed
particularly appealing. Moreover, Simon PJ was a bit skeptical of the value of
the test to begin with and I strongly suspect that any regression in #7995
would be accompanied by failures in our other compiler performance tests.

Closes #17399.

- - - - -
011f3121 by Ben Gamari at 2019-11-09T18:03:38-05:00
testsuite: Mark T16219 as fragile on Windows

As noted in #17452, this test produces very long file paths which
exceed the Windows MAX_PATH limitation. Mark the test as fragile for not
until we can come up with a better solution.

- - - - -
1f98e47d by Simon Peyton Jones at 2019-11-09T18:04:14-05:00
Use the right type in :force

A missing prime meant that we were considering the wrong
type in the GHCi debugger, when doing :force on multiple
arguments (issue #17431).

The fix is trivial.

- - - - -
1f911de4 by Brian Wignall at 2019-11-09T18:04:57-05:00
Add IsList instance for ZipList (closes #17433)

- - - - -
e3672f40 by Brian Wignall at 2019-11-09T18:04:57-05:00
Incorporate MR review suggestions; add change in changelog

- - - - -
3957bdf2 by Brian Wignall at 2019-11-09T18:04:57-05:00
Fix incorrect plurals

- - - - -
6f4c1250 by Alina Banerjee at 2019-11-10T01:06:12-05:00
Improve SPECIALIZE pragma error messages (Fixes #12126)

- - - - -
fa25c8c4 by Richard Eisenberg at 2019-11-10T01:06:48-05:00
Update release notes about #16512 / #17405.

- - - - -
55ca1085 by Richard Eisenberg at 2019-11-10T01:06:48-05:00
Fix #17405 by not checking imported equations

Previously, we checked all imported type family equations
for injectivity. This is very silly. Now, we check only
for conflicts.

Before I could even imagine doing the fix, I needed to untangle
several functions that were (in my opinion) overly complicated.
It's still not quite as perfect as I'd like, but it's good enough
for now.

Test case: typecheck/should_compile/T17405

- - - - -
a9467f4f by Ben Gamari at 2019-11-10T21:06:33-05:00
testsuite: Mark tests fragile in threaded2 as fragile in all concurrent ways

- - - - -
3e07ea8d by Ben Gamari at 2019-11-10T21:10:30-05:00
testsuite: Use small allocation area when measuring residency

As suggested in #17387; this helps reduce the variance in our residency
sampling.

Metric Increase:
    T10370
    T3586
    lazy-bs-alloc

Metric Decrease 'compile_time/peak_megabytes_allocated':
    T1969

Metric Decrease 'runtime/bytes allocated':
    space_leak_001

Metric Increase 'compile_time/bytes allocated':
    T1969

Metric Increase 'runtime/peak_megabytes_allocated':
    space_leak_001

Metric Decrease:
    T3064
    T9675

- - - - -
049d9ae0 by Ben Gamari at 2019-11-10T21:10:30-05:00
testsuite: Don't check_stats at runtime if not requested

Previously we would call check_stats to check the runtime metrics even
if the test definition hadn't requested it. This would result in an
error since the .stats file doesn't exist.

- - - - -
64433428 by Alp Mestanogullari at 2019-11-11T08:49:01-05:00
hadrian: export METRICS_FILE to make it accessible to perf notes script

This addresses #17456 and also fixes the --metrics-file argument that Hadrian
passes to the testsuite driver.

- - - - -
06640394 by Ben Gamari at 2019-11-11T08:50:45-05:00
testsuite: Disable T4334 in nonmoving_thr way

- - - - -
f8ec32d7 by Alp Mestanogullari at 2019-11-11T11:36:44-05:00
ci: push perf test metrics even when the testsuite doesn't pass

The corresponding commit might introduce a regression on a perf test, in which
case we certainly want to record it. The testsuite might also fail because
of a test unrelated to performance, in which case we want to record that the
perf test results were good.

Either way, we likely want to record them under all circumstances but
we don't without this patch.

Metric Decrease:
    T3586

Metric Increase:
    lazy-bs-alloc

- - - - -
643d42fc by Alp Mestanogullari at 2019-11-12T18:40:19-05:00
testsuite: don't collect compiler stats in collect_runtime_residency

We instead want to collect the runtime stats (with collect_stats, instead of
collect_compiler_stats).

This should fix a number of perf tests failures we have been seeing, where
we suddenly started measuring metrics we didn't intend to measure, which
tend to fall outside of the acceptance window.

Metric Decrease:
    lazy-bs-alloc
    T3586

Metric Increase:
    space_leak_001
    T4801
    T5835
    T12791

- - - - -
535d0edc by Ömer Sinan Ağacan at 2019-11-13T07:06:12-05:00
Document CmmTopInfo type

[ci skip]

- - - - -
2d4f9ad8 by Ben Gamari at 2019-11-13T07:06:49-05:00
Ensure that coreView/tcView are able to inline

Previously an import cycle between Type and TyCoRep meant that several
functions in TyCoRep ended up SOURCE import coreView. This is quite
unfortunate as coreView is intended to be fused into a larger pattern
match and not incur an extra call.

Fix this with a bit of restructuring:

 * Move the functions in `TyCoRep` which depend upon things in `Type`
   into `Type`
 * Fold contents of `Kind` into `Type` and turn `Kind` into a simple
   wrapper re-exporting kind-ish things from `Type`
 * Clean up the redundant imports that popped up as a result

Closes #17441.

Metric Decrease:
    T4334

- - - - -
b795637f by Alp Mestanogullari at 2019-11-13T07:07:28-05:00
hadrian: fix Windows CI script

By only using 'export' from within bash commands.

- - - - -
6885e22c by Ben Gamari at 2019-11-13T07:08:03-05:00
testsuite: Add test for #17458

As noted in #17458, QuantifiedConstraints and UndecideableInstances
could previously be used to write programs which can loop at runtime.
This was fixed in !1870.

- - - - -
b4b19d89 by Ben Gamari at 2019-11-13T07:08:03-05:00
users guide: Fix broken link

- - - - -
9a939a6c by Ryan Scott at 2019-11-13T07:08:40-05:00
Print name prefixly in the Outputable instance for StandaloneKindSig

Issue #17461 was occurring because the `Outputable` instance for
standalone kind signatures was simply calling `ppr` on the name in
the kind signature, which does not add parentheses to infix names.
The solution is simple: use `pprPrefixOcc` instead.

Fixes #17461.

- - - - -
a06cfb59 by Ömer Sinan Ağacan at 2019-11-13T07:09:18-05:00
Only pass mod_location with HscRecomp instead of the entire ModSummary

HscRecomp users only need the ModLocation of the module being compiled,
so only pass that to users instead of the entire ModSummary

Metric Decrease:
    T4801

- - - - -
dd49b3f0 by Ben Gamari at 2019-11-13T17:01:21-05:00
Bump Haskeline and add exceptions as boot library

Haskeline now depends upon exceptions. See #16752.

- - - - -
b06b1858 by Ben Gamari at 2019-11-14T11:30:20-05:00
base: Bump version to 4.14.0.0

Metric Increase:
    T4801

- - - - -
6ab80439 by Ben Gamari at 2019-11-14T23:05:30-05:00
gitlab-ci: Allow Windows to fail again

- - - - -
46afc380 by Ben Gamari at 2019-11-15T09:45:36-05:00
gitlab-ci: Install process to global pkgdb before starting build

This is an attempt to mitigate #17480 by ensuring that a functional version of
the process library is available before attempting the build.

- - - - -
8c5cb806 by Ben Gamari at 2019-11-15T10:45:55-05:00
Bump supported LLVM version to 9.0

- - - - -
8e5851f0 by Ben Gamari at 2019-11-15T10:45:55-05:00
llvm-targets: Update with Clang 9

- - - - -
f3ffec27 by Ben Gamari at 2019-11-15T11:54:26-05:00
testsuite: Increase acceptance window of T4801

This statistic is rather unstable. Hopefully fixes #17475.

- - - - -
c2991f16 by Ben Gamari at 2019-11-15T11:56:10-05:00
users-guide: Drop 8.6.1 release notes

- - - - -
e8da1354 by Ben Gamari at 2019-11-17T06:48:16-05:00
gitlab-ci: Fix submodule linter

We ran it against the .git directory despite the fact that the linter
wants to be run against the repository.

- - - - -
13290f91 by Ben Gamari at 2019-11-17T06:48:16-05:00
Bump version to 8.10.0

Bumps haddock submodule.

- - - - -
fa98f823 by Ben Gamari at 2019-11-17T06:48:16-05:00
testsuite: Don't collect residency for T4801

I previously increased the size of the acceptance window from 2% to 5%
but this still isn't enough. Regardless, measuring bytes allocated
should be sufficient to catch any regressions.

- - - - -
002b2842 by Ivan Kasatenko at 2019-11-17T06:49:22-05:00
Make test 16916 more stable across runs

- - - - -
ca89dd3b by Ben Gamari at 2019-11-17T06:58:17-05:00
users-guide: Address #17329

Adopts the language suggested by @JakobBruenker.

- - - - -
2f5ed225 by Ben Gamari at 2019-11-17T07:16:32-05:00
exceptions: Bump submodule back to master

The previous commit hasn't made it to master yet.

- - - - -
34515e7c by nineonine at 2019-11-17T13:33:22-08:00
Fix random typos [skip ci]

- - - - -
4a37a29b by Mario Blažević at 2019-11-17T17:26:24-05:00
Fixed issue #17435, missing Data instances

- - - - -
97f1bcae by Andreas Klebinger at 2019-11-17T17:26:24-05:00
Turn some comments into GHC.Hs.Utils into haddocks

- - - - -
cf7f8e5b by Ben Gamari at 2019-11-17T17:26:26-05:00
testsuite: Skip T17414 on Linux

It is typical for $TMP to be a small tmpfson Linux. This test will fail
in such cases since we must create a file larger than the filesystem.
See #17459.

- - - - -
88013b78 by nineonine at 2019-11-19T11:53:16-05:00
Optimize MonadUnique instances based on IO (#16843)

Metric Decrease:
    T14683

- - - - -
a8adb5b4 by Ben Gamari at 2019-11-19T11:53:55-05:00
desugar: Drop stale Note [Matching seqId]

The need for this note vanished in
eae703aa60f41fd232be5478e196b661839ec3de.

- - - - -
08d595c0 by Ben Gamari at 2019-11-19T11:53:55-05:00
Give seq a more precise type and remove magic

`GHC.Prim.seq` previously had the rather plain type:

    seq :: forall a b. a -> b -> b

However, it also had a special typing rule to applications
where `b` is not of kind `Type`.

Issue #17440 noted that levity polymorphism allows us to rather give
it the more precise type:

    seq :: forall (r :: RuntimeRep) a (b :: TYPE r). a -> b -> b

This allows us to remove the special typing rule that we previously
required to allow applications on unlifted arguments. T9404 contains a
non-Type application of `seq` which should verify that this works as
expected.

Closes #17440.

- - - - -
ec8a463d by Viktor Dukhovni at 2019-11-19T11:54:45-05:00
Enable USE_PTHREAD_FOR_ITIMER also on FreeBSD

If using a pthread instead of a timer signal is more reliable, and
has no known drawbacks, then FreeBSD is also capable of supporting
this mode of operation (tested on FreeBSD 12 with GHC 8.8.1, but
no reason why it would not also work on FreeBSD 11 or GHC 8.6).

Proposed by Kevin Zhang in:

    https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=241849

- - - - -
cd40e12a by Ömer Sinan Ağacan at 2019-11-19T11:55:36-05:00
Packages.hs: use O(n*log(n)) ordNub instead of O(n*n) nub

As reported in #8173 in some environments package lists can get quite
long, so we use more efficient ordNub instead of nub on package lists.

- - - - -
2b27cc16 by Ben Gamari at 2019-11-19T11:56:21-05:00
Properly account for libdw paths in make build system

Should finally fix #17255.

- - - - -
0418c38d by Ben Gamari at 2019-11-19T11:56:58-05:00
rts: Add missing include of SymbolExtras.h

This broke the Windows build.

- - - - -
c819c0e4 by Ben Gamari at 2019-11-19T11:57:36-05:00
nonmoving: Use correct info table pointer accessor

Previously we used INFO_PTR_TO_STRUCT instead of
THUNK_INFO_PTR_TO_STRUCT when looking at a thunk. These two happen to be
equivalent on 64-bit architectures due to alignment considerations
however they are different on 32-bit platforms. This lead to #17487.

To fix this we also employ a small optimization: there is only one thunk
of type WHITEHOLE (namely stg_WHITEHOLE_info). Consequently, we can just
use a plain pointer comparison instead of testing against info->type.

- - - - -
deed8e31 by Ben Gamari at 2019-11-19T11:57:36-05:00
nonmoving: Fix incorrect masking in mark queue type test

We were using TAG_BITS instead of TAG_MASK. This happened to work on
64-bit platforms where TAG_BITS==3 since we only use tag values 0 and
3. However, this broken on 32-bit platforms where TAG_BITS==2.

- - - - -
097f8072 by Ben Gamari at 2019-11-19T11:57:36-05:00
nonmoving: Rework mark queue representation

The previous representation needlessly limited the array length to
16-bits on 32-bit platforms.

- - - - -
eb7b233a by Ben Gamari at 2019-11-19T11:57:36-05:00
nonmoving: Fix handling on large object marking on 32-bit

Previously we would reset the pointer pointing to the object to be
marked to the beginning of the block when marking a large object. This
did no harm on 64-bit but on 32-bit it broke, e.g. `arr020`, since we
align pinned ByteArray allocations such that the payload is 8
byte-aligned. This means that the object might not begin at the
beginning of the block.,

- - - - -
a7571a74 by Ben Gamari at 2019-11-19T11:57:36-05:00
testsuite: Increase width of stack003 test

Previously the returned tuple seemed to fit in registers on amd64. This
meant that non-moving collector bug would cause the test to fail on i386
yet not amd64.

- - - - -
098d5017 by Ben Gamari at 2019-11-19T11:57:36-05:00
nonmoving: Drop redundant write barrier on stack underflow

Previously we would push stack-carried return values to the new stack on
a stack overflow. While the precise reasoning for this barrier is
unfortunately lost to history, in hindsight I suspect it was prompted by
a missing barrier elsewhere (that has been since fixed).

Moreover, there the redundant barrier is actively harmful: the stack may
contain non-pointer values; blindly pushing these to the mark queue will
result in a crash. This is precisely what happened in the `stack003`
test. However, because of a (now fixed) deficiency in the test this
crash did not trigger on amd64.

- - - - -
e57b7cc6 by Roland Zumkeller at 2019-11-19T20:39:19-05:00
Changing Thread IDs from 32 bits to 64 bits.

- - - - -
d1f3c637 by Roland Zumkeller at 2019-11-19T20:39:19-05:00
Use pointer equality in Eq/Ord for ThreadId

Changes (==) to use only pointer equality. This is safe because two
threads are the same iff they have the same id.

Changes `compare` to check pointer equality first and fall back on ids
only in case of inequality.

See discussion in #16761.

- - - - -
ef8a08e0 by Alexey Kuleshevich at 2019-11-19T20:39:20-05:00
hpc: Fix encoding issues. Add test for and fix #17073

* Make sure files are being read/written in UTF-8. Set encoding while writing
  HTML output. Also set encoding while writing and reading .tix files although
  we don't yet have a ticket complaining that this poses problems.
* Set encoding in html header to utf8
* Upgrade to new version of 'hpc' library and reuse `readFileUtf8`
  and `writeFileUtf8` functions
* Update git submodule for `hpc`
* Bump up `hpc` executable version

Co-authored-by: Ben Gamari <ben at smart-cactus.org>

- - - - -
b79e46d6 by Vladislav Zavialov at 2019-11-19T20:39:20-05:00
Strip parentheses in expressions contexts in error messages

This makes error messages a tad less noisy.

- - - - -
13bbde77 by Ben Gamari at 2019-11-21T13:56:56-05:00
Bump hsc2hs submodule

Including Phyx's backport of the process changes fixing #17480.

- - - - -
d4d10501 by Ben Gamari at 2019-11-23T09:42:38-05:00
Bump hsc2hs submodule again

This fixes the Darwin build.

- - - - -
889d475b by nineonine at 2019-11-23T18:53:29-05:00
Fix typo in Note reference [skip ci]

- - - - -
8a33abfc by Ryan Scott at 2019-11-23T18:54:05-05:00
Target the IsList instance for ZipList at base-4.14.0.0 (#17489)

This moves the changelog entry about the instance from
`base-4.15.0.0` to `base-4.14.0.0`. This accomplishes part (1)
from #17489.

[ci skip]

- - - - -
e43e6ece by Ben Gamari at 2019-11-23T18:54:41-05:00
rts: Expose interface for configuring EventLogWriters

This exposes a set of interfaces from the GHC API for configuring
EventLogWriters. These can be used by consumers like
[ghc-eventlog-socket](https://github.com/bgamari/ghc-eventlog-socket).

- - - - -
de6bbdf2 by Matheus Magalhães de Alcantara at 2019-11-23T18:55:23-05:00
Take care to not eta-reduce jumps in CorePrep

CorePrep already had a check to prevent it from eta-reducing Ids that
respond true to hasNoBinding (foreign calls, constructors for unboxed
sums and products, and Ids with compulsory unfoldings). It did not,
however, consider join points as ids that 'must be saturated'.

Checking whether the Id responds True to 'isJoinId' should prevent
CorePrep from turning saturated jumps like the following (from #17429)
into undersaturated ones:

      (\ eta_XP ->
         join { mapped_s1vo _ = lvl_s1vs } in jump mapped_s1vo eta_XP)

- - - - -
4a1e7e47 by Matheus Magalhães de Alcantara at 2019-11-23T18:55:23-05:00
Make CorePrep.tryEtaReducePrep and CoreUtils.tryEtaReduce line up

Simon PJ says he prefers this fix to #17429 over banning eta-reduction
for jumps entirely. Sure enough, this also works.

Test case: simplCore/should_compile/T17429.hs

- - - - -
15f1dc33 by Ryan Scott at 2019-11-23T18:56:00-05:00
Prevent -optc arguments from being duplicated in reverse order (#17471)

This reverts a part of commit
7bc5d6c6578ab9d60a83b81c7cc14819afef32ba that causes all arguments
to `-optc` (and `-optcxx`) to be passed twice to the C/C++ compiler,
once in reverse order and then again in the correct order. While
passing duplicate arguments is usually harmless it can cause breakage
in this pattern, which is employed by Hackage libraries in the wild:

```
ghc Foo.hs foo.c -optc-D -optcFOO
```

As `FOO -D -D FOO` will cause compilers to error.

Fixes #17471.

- - - - -
e85c9b22 by Ben Gamari at 2019-11-23T18:56:36-05:00
Bump ghc version to 8.11

- - - - -
0e6c2045 by Ben Gamari at 2019-11-23T18:57:12-05:00
rts: Consolidate spinlock implementation

Previously we had two distinct implementations: one with spinlock
profiling and another without. This seems like needless duplication.

- - - - -
cb11fcb5 by Ben Gamari at 2019-11-23T18:57:49-05:00
Packages: Don't use expectJust

Throw a slightly more informative error on failure. Motivated by the
errors seen in !2160.

- - - - -
5747ebe9 by Sebastian Graf at 2019-11-23T18:58:25-05:00
Stricten functions ins GHC.Natural

This brings `Natural` on par with `Integer` and fixes #17499.
Also does some manual CSE for 0 and 1 literals.

- - - - -
c14b723f by Ömer Sinan Ağacan at 2019-11-23T18:59:06-05:00
Bump exceptions submodule

Adds a few files generated by GHC's configure script to .gitignore

- - - - -
7b4c7b75 by Brian Wignall at 2019-11-23T19:04:52-05:00
Fix typos

- - - - -
6008206a by Viktor Dukhovni at 2019-11-24T14:33:18-05:00
On FreeBSD 12 sys/sysctl.h requires sys/types.h

Else build fails with:

    In file included from ExecutablePath.hsc:42:
    /usr/include/sys/sysctl.h:1062:25: error: unknown type name 'u_int'; did you mean 'int'?
     int sysctl(const int *, u_int, void *, size_t *, const void *, size_t);
			     ^~~~~
			     int
    compiling libraries/base/dist-install/build/System/Environment/ExecutablePath_hsc_make.c failed (exit code 1)

Perhaps also also other FreeBSD releases, but additional include
will no harm even if not needed.

- - - - -
b694b566 by Ben Gamari at 2019-11-24T14:33:54-05:00
configure: Fix HAVE_C11_ATOMICS macro

Previously we were using AC_DEFINE instead of
AC_DEFINE_UNQUOTED, resulted in the variable not being
interpolated.

Fixes #17505.

- - - - -
8b8dc366 by Krzysztof Gogolewski at 2019-11-25T14:37:38+01:00
Remove prefix arrow support for GADTs (#17211)

This reverts the change in #9096.

The specialcasing done for prefix (->) is brittle and
does not support VTA, type families, type synonyms etc.

- - - - -
5a08f7d4 by Sebastian Graf at 2019-11-27T00:14:59-05:00
Make warnings for TH splices opt-in

In #17270 we have the pattern-match checker emit incorrect warnings. The
reason for that behavior is ultimately an inconsistency in whether we
treat TH splices as written by the user (`FromSource :: Origin`) or as
generated code (`Generated`). This was first reported in #14838.

The current solution is to TH splices as `Generated` by default and only
treat them as `FromSource` when the user requests so
(-fenable-th-splice-warnings). There are multiple reasons for opt-in
rather than opt-out:

  * It's not clear that the user that compiles a splice is the author of the code
    that produces the warning. Think of the situation where she just splices in
    code from a third-party library that produces incomplete pattern matches.
    In this scenario, the user isn't even able to fix that warning.
  * Gathering information for producing the warnings (pattern-match check
    warnings in particular) is costly. There's no point in doing so if the user
    is not interested in those warnings.

Fixes #17270, but not #14838, because the proper solution needs a GHC
proposal extending the TH AST syntax.

- - - - -
8168b42a by Vladislav Zavialov at 2019-11-27T11:32:18+03:00
Whitespace-sensitive bang patterns (#1087, #17162)

This patch implements a part of GHC Proposal #229 that covers five
operators:

* the bang operator (!)
* the tilde operator (~)
* the at operator (@)
* the dollar operator ($)
* the double dollar operator ($$)

Based on surrounding whitespace, these operators are disambiguated into
bang patterns, lazy patterns, strictness annotations, type
applications, splices, and typed splices.

This patch doesn't cover the (-) operator or the -Woperator-whitespace
warning, which are left as future work.

- - - - -
9e5477c4 by Ryan Scott at 2019-11-27T20:01:50-05:00
Fix @since annotations for isResourceVanishedError and friends (#17488)

- - - - -
e122ba33 by Sergei Trofimovich at 2019-11-27T20:02:29-05:00
.gitmodules: tweak 'exception' URL to avoid redirection warnings

Avoid initial close warning of form:

```
Cloning into 'exceptions'...
warning: redirecting to https://gitlab.haskell.org/ghc/packages/exceptions.git/
```

Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org>

- - - - -
5f84b52a by Philipp Krüger at 2019-11-28T02:54:05-05:00
Reduce boolean blindness in OccInfo(OneOcc) #17482

* Transformed the type aliases `InterestingCxt`, `InsideLam` and `OneBranch`
  into data types.
* Added Semigroup and Monoid instances for use in orOccInfo in OccurAnal.hs
* Simplified some usage sites by using pattern matching instead of boolean algebra.

Metric Increase:
    T12150

This increase was on a Mac-build of exactly 1%. This commit does *not* re-intruduce
the asymptotic memory usage described in T12150.

- - - - -
3748ba3a by Brian Wignall at 2019-11-28T02:54:52-05:00
Fix typos, using Wikipedia list of common typos

- - - - -
6c59cc71 by Stefan Schulze Frielinghaus at 2019-11-28T02:55:33-05:00
Fix endian handling of LLVM backend

Get rid of CPP macro WORDS_BIGENDIAN which is not defined anymore, and
replace it by DynFlag. This fixes partially #17337.

- - - - -
6985e0fc by Vladislav Zavialov at 2019-11-28T15:47:53+03:00
Factor out HsSCC/HsCoreAnn/HsTickPragma into HsPragE

This is a refactoring with no user-visible changes (except for GHC API
users). Consider the HsExpr constructors that correspond to user-written
pragmas:

  HsSCC         representing  {-# SCC ... #-}
  HsCoreAnn     representing  {-# CORE ... #-}
  HsTickPragma  representing  {-# GENERATED ... #-}

We can factor them out into a separate datatype, HsPragE. It makes the
code a bit tidier, especially in the parser.

Before this patch:

  hpc_annot :: { Located ( (([AddAnn],SourceText),(StringLiteral,(Int,Int),(Int,Int))),
                           ((SourceText,SourceText),(SourceText,SourceText))
                         ) }

After this patch:

  prag_hpc :: { Located ([AddAnn], HsPragE GhcPs) }

- - - - -
7f695a20 by Ömer Sinan Ağacan at 2019-11-29T08:25:28-05:00
Pass ModDetails with (partial) ModIface in HscStatus

(Partial) ModIface and ModDetails are generated at the same time, but
they're passed differently: ModIface is passed in HscStatus consturctors
while ModDetails is returned in a tuple. This refactors ModDetails
passing so that it's passed around with ModIface in HscStatus
constructors. This makes the code more consistent and hopefully easier
to understand: ModIface and ModDetails are really very closely related.
It makes sense to treat them the same way.

- - - - -
e921c90f by Ömer Sinan Ağacan at 2019-11-29T08:26:07-05:00
Improve few Foreign.Marshal.Utils docs

In copyBytes and moveBytes mention which argument is source and which is
destination.

Also fixes some of the crazy indentation in the module and cleans
trailing whitespace.

- - - - -
316f2431 by Sebastian Graf at 2019-11-30T02:57:58-05:00
Hadrian docs: Rename the second "validate" entry to "slow-validate" [ci skip]

That would be in line with the implementation.

- - - - -
5aba5d32 by Vladislav Zavialov at 2019-11-30T02:58:34-05:00
Remove HasSrcSpan (#17494)

Metric Decrease:
    haddock.compiler

- - - - -
d1de5c22 by Sylvain Henry at 2019-11-30T02:59:13-05:00
Use Hadrian by default in validate script (#17527)

- - - - -
3a96a0b6 by Sebastian Graf at 2019-11-30T02:59:55-05:00
Simpler Semigroup instance for InsideLam and InterestingCtxt

This mirrors the definition of `(&&)` and `(||)` now, relieving the
Simplifier of a marginal amount of pressure.

- - - - -
f8cfe81a by Roland Senn at 2019-11-30T20:33:49+01:00
Improve tests for #17171

While backporting MR !1806 to 8.8.2 (!1885) I learnt the following:

* Tests with `expect_fail` do not compare `*.stderr` output files. So a test using `expect_fail` will not detect future regressions on the `stderr` output.
* To compare the `*.stderr` output files, I have to use the `exit_code(n)` function.
* When a release is made, tests with `makefile_test` are converted to use `run_command`.
* For the test `T17171a` the return code is `1` when running `makefile_test`, however it's `2` when running `run_command`.

Therefore I decided:

* To improve my tests for #17171
* To change test T17171a from `expect_fail` to `exit_code(2)`
* To change both tests from  `makefile_test` to `run_command`

- - - - -
2b113fc9 by Vladislav Zavialov at 2019-12-01T08:17:05-05:00
Update DisambECP-related comments

- - - - -
beed7c3e by Ben Gamari at 2019-12-02T03:41:37-05:00
testsuite: Fix location of typing_stubs module

This should fix the build on Debian 8.

- - - - -
53251413 by Ben Gamari at 2019-12-02T03:42:14-05:00
testsuite: Don't override LD_LIBRARY_PATH, only prepend

NixOS development environments often require that LD_LIBRARY_PATH
be set in order to find system libraries. T1407 was overriding
LD_LIBRARY_PATH, dropping these directories. Now it merely prepends,
its directory.
- - - - -
65400314 by Krzysztof Gogolewski at 2019-12-02T03:42:57-05:00
Convert warnings into assertions

Since the invariants always hold in the testsuite, we can convert
them to asserts.

- - - - -
18baed64 by Alan Zimmerman at 2019-12-02T03:43:37-05:00
API Annotations: Unicode '->' on HsForallTy

The code fragment

  type family Proxy2' ∷ ∀ k → k → Type where
    Proxy2' = Proxy'

Generates AnnRarrow instead of AnnRarrowU for the first →.

Fixes #17519

- - - - -
717f3236 by Brian Wignall at 2019-12-02T03:44:16-05:00
Fix more typos

- - - - -
bde48f8e by Ben Gamari at 2019-12-02T11:55:34-05:00
More Haddock syntax in GHC.Hs.Utils

As suggested by RyanGlScott in !2163.

- - - - -
038bedbc by Ben Gamari at 2019-12-02T11:56:18-05:00
Simplify: Fix pretty-printing of strictness

A colleague recently hit the panic in Simplify.addEvals and I noticed
that the message is quite unreadable due to incorrect pretty-printing.
Fix this.

- - - - -
c500f652 by Ben Gamari at 2019-12-02T11:56:54-05:00
gitlab-ci: Fix changelog linting logic

- - - - -
8ead967d by Ben Gamari at 2019-12-02T11:56:54-05:00
win32-init: Drop workaround for #17480

The `process` changes have now been merged into `hsc2hs`.

(cherry picked from commit fa029f53132ad59f847ed012d3b835452cf16615)

- - - - -
d402209a by Ben Gamari at 2019-12-02T11:56:54-05:00
gitlab-ci: Disable Sphinx build on Debian 8

The docutils version available appears to be too old to support the
`table` directive's `:widths:` options.

(cherry picked from commit 75764487a96a7a026948b5af5022781872d12baa)

- - - - -
f1f68824 by Ben Gamari at 2019-12-02T11:56:54-05:00
base: Fix <unistd.h> #include

Previously we were including <sys/unistd.h> which is available on glibc
but not musl.

(cherry picked from commit e44b695ca7cb5f3f99eecfba05c9672c6a22205e)

- - - - -
37eb94b3 by Ben Gamari at 2019-12-02T11:56:54-05:00
gitlab-ci: Bump Docker images

Installs pxz on Centos7

(cherry picked from commit 86960e691f7a600be247c32a7cf795bf9abf7cc4)

- - - - -
aec98a79 by Ben Gamari at 2019-12-02T11:56:54-05:00
gitlab-ci: pxz is unavailable on CentOS 7

Fall back to xz

- - - - -
6708b8e5 by Ben Gamari at 2019-12-02T11:56:54-05:00
gitlab-ci: Set LANG on CentOS 7

It otherwise seems to default to ascii

- - - - -
470ef0e7 by Ben Gamari at 2019-12-02T11:56:54-05:00
gitlab-ci: Consolidate release build configuration

- - - - -
38338757 by Ben Gamari at 2019-12-02T11:56:54-05:00
gitlab-ci: Add Debian 10 builds

- - - - -
012f13b5 by Ben Gamari at 2019-12-02T11:56:54-05:00
gitlab-ci: Fix Windows bindist collection

Apparently variable interpolation in the `artifacts.paths` key of
`gitlab-ci.yml` doesn't work on Windows as it does on WIndows.

(cherry picked from commit 100cc756faa4468ed6950116bae30609c1c3468b)

- - - - -
a0f09e23 by Ben Gamari at 2019-12-02T11:56:54-05:00
testsuite: Simplify Python <3.5 fallback for TextIO

(cherry picked from commit d092d8598694c23bc07cdcc504dff52fa5f33be1)

- - - - -
2b2370ec by Ben Gamari at 2019-12-02T11:56:54-05:00
gitlab-ci: Add release-x86_64-linux-deb9 job

(cherry picked from commit cbedb3c4a90649f474cb716842ba53afc5a642ca)

- - - - -
b1c206fd by Ben Gamari at 2019-12-02T11:56:54-05:00
gitlab-ci: Always build source tarball

(cherry picked from commit 67b5de88ef923971f1980335137e3c7193213abd)

- - - - -
4cbd5b47 by Sergei Trofimovich at 2019-12-02T11:57:33-05:00
configure.ac: make cross-compiler detection stricter

Be more precise at detecting cross-compilation case.

Before the change configuration
  $ ./configure --host=x86_64-pc-linux-gnu --target=x86_64-gentoo-linux-musl
was not considered a cross-target. Even though libcs are different (`glibc` vs. `musl`).

Without this patch build fails as:

```
"inplace/bin/ghc-cabal" check libraries/integer-gmp
"inplace/bin/ghc-cabal" configure libraries/integer-gmp dist-install \
    --with-ghc="/home/slyfox/dev/git/ghc/inplace/bin/ghc-stage1" \
    --with-ghc-pkg="/home/slyfox/dev/git/ghc/inplace/bin/ghc-pkg" \
    --disable-library-for-ghci --enable-library-vanilla --enable-library-for-ghci \
    --enable-library-profiling --enable-shared --with-hscolour="/usr/bin/HsColour" \
    --configure-option=CFLAGS="-Wall \
    -Werror=unused-but-set-variable -Wno-error=inline \
    -iquote /home/slyfox/dev/git/ghc/libraries/integer-gmp" \
    --configure-option=LDFLAGS="  " --configure-option=CPPFLAGS="   \
    " --gcc-options="-Wall     -Werror=unused-but-set-variable -Wno-error=inline -iquote /home/slyfox/dev/git/ghc/libraries/integer-gmp   \
    " --with-gcc="x86_64-gentoo-linux-musl-gcc" --with-ld="x86_64-gentoo-linux-musl-ld.gold" --with-ar="x86_64-gentoo-linux-musl-ar" \
    --with-alex="/usr/bin/alex" --with-happy="/usr/bin/happy"
Configuring integer-gmp-1.0.2.0...
configure: WARNING: unrecognized options: --with-compiler
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
checking for gcc... /usr/lib/ccache/bin/x86_64-gentoo-linux-musl-gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... configure: error: in `/home/slyfox/dev/git/ghc/libraries/integer-gmp/dist-install/build':
configure: error: cannot run C compiled programs.
If you meant to cross compile, use `--host'.
See `config.log' for more details
make[1]: *** [libraries/integer-gmp/ghc.mk:5: libraries/integer-gmp/dist-install/package-data.mk] Error 1
make: *** [Makefile:126: all] Error 2
```

Note: here `ghc-stage1` is assumed to target `musl` target but is passed
`glibc` toolchain. It happens because initial ./configure phase did not
detect host/target as different.

Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org>

- - - - -
5f7cb423 by Sylvain Henry at 2019-12-02T23:59:29-05:00
Add `timesInt2#` primop

- - - - -
fbbe18a2 by Sylvain Henry at 2019-12-02T23:59:29-05:00
Use the new timesInt2# primop in integer-gmp (#9431)

- - - - -
5a4b8d0c by Athas at 2019-12-03T00:00:09-05:00
Document RTS behaviour upon encountering '--'.
- - - - -
705a16df by Ben Gamari at 2019-12-03T07:11:33-05:00
Make BCO# lifted

In #17424 Simon PJ noted that there is a potentially unsafe occurrence
of unsafeCoerce#, coercing from an unlifted to lifted type. However,
nowhere in the compiler do we assume that a BCO# is not a thunk.
Moreover, in the case of a CAF the result returned by `createBCO` *will*
be a thunk (as noted in [Updatable CAF BCOs]).  Consequently it seems
better to rather make BCO# a lifted type and rename it to BCO.

- - - - -
35afe4f3 by Sylvain Henry at 2019-12-03T07:12:13-05:00
Use Int# primops in `Bits Int{8,16,32,64}` instances

- - - - -
7a51b587 by Sylvain Henry at 2019-12-03T07:12:13-05:00
Add constant folding rule (#16402)

    narrowN (x .&. m)
    m .&. (2^N-1) = 2^N-1
    ==> narrowN x

e.g.  narrow16 (x .&. 0x12FFFF) ==> narrow16 x

- - - - -
10caee7f by Ben Gamari at 2019-12-03T21:04:50-05:00
users-guide: Add 8.12.1 release notes

- - - - -
25019d18 by Ben Gamari at 2019-12-03T21:04:50-05:00
Drop Uniquable constraint for AnnTarget

This relied on deriveUnique, which was far too subtle to be safely
applied. Thankfully the instance doesn't appear to be used so let's just
drop it.

- - - - -
78b67ad0 by Ben Gamari at 2019-12-03T21:04:50-05:00
Simplify uniqAway

This does two things:

 * Eliminate all uses of Unique.deriveUnique, which was quite easy to
   mis-use and extremely subtle.

 * Rename the previous "derived unique" notion to "local unique". This
   is possible because the only places where `uniqAway` can be safely
   used are those where local uniqueness (with respect to some
   InScopeSet) is sufficient.

 * Rework the implementation of VarEnv.uniqAway, as discussed in #17462.
   This should make the operation significantly more efficient than its
   previous iterative implementation..

Metric Decrease:
    T9872c
    T12227
    T9233
    T14683
    T5030
    T12545
    hie002

Metric Increase:
    T9961

- - - - -
f03a41d4 by Ben Gamari at 2019-12-03T21:05:27-05:00
Elf: Fix link info note generation

Previously we would use the `.int` assembler directive to generate
32-bit words in the note section. However, `.int` is note guaranteed to
produce 4-bytes; in fact, on some platforms (e.g. AArch64) it produces
8-bytes. Use the `.4bytes` directive to avoid this.

Moreover, we used the `.align` directive, which is quite platform
dependent. On AArch64 it appears to not even be idempotent (despite what
the documentation claims). `.balign` is consequentially preferred as it
offers consistent behavior across platforms.

- - - - -
84585e5e by Vladislav Zavialov at 2019-12-05T16:07:44-05:00
Meaning-preserving SCC annotations (#15730)

This patch implements GHC Proposal #176:
  https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0176-scc-parsing.rst

Before the change:

  1 /                    2 / 2 = 0.25
  1 / {-# SCC "name" #-} 2 / 2 = 1.0

After the change:

  1 /                    2 / 2 = 0.25
  1 / {-# SCC "name" #-} 2 / 2 = parse error

- - - - -
e49e5470 by Vladislav Zavialov at 2019-12-05T16:07:44-05:00
Improve error messages for SCC pragmas

- - - - -
a2b535d9 by Ben Gamari at 2019-12-05T16:07:45-05:00
users guide: Try to silence underfull \hbox warnings

We use two tricks, as suggested here [1]:

 * Use microtype to try to reduce the incidence of underfull boxes
 * Bump up \hbadness to eliminate the warnings

- - - - -
4e47217f by Bodigrim at 2019-12-05T16:07:47-05:00
Make sameNat and sameSymbol proxy-polymorphic

- - - - -
8324f0b7 by Bodigrim at 2019-12-05T16:07:47-05:00
Test proxy-polymorphic sameNat and sameSymbol

- - - - -
69001f54 by Ben Gamari at 2019-12-05T16:07:48-05:00
nonmoving: Clear segment bitmaps during sweep

Previously we would clear the bitmaps of segments which we are going to
sweep during the preparatory pause. However, this is unnecessary: the
existence of the mark epoch ensures that the sweep will correctly
identify non-reachable objects, even if we do not clear the bitmap.

We now defer clearing the bitmap to sweep, which happens concurrently
with mutation.

- - - - -
58a9c429 by Ben Gamari at 2019-12-05T16:07:48-05:00
testsuite: Disable divByZero on non-NCG targets

The LLVM backend does not guarantee any particular semantics for
division by zero, making this test unreliable across platforms.

- - - - -
8280bd8a by Ben Gamari at 2019-12-05T16:07:49-05:00
testsuite: Factor out terminal coloring

- - - - -
92a52aaa by Ben Gamari at 2019-12-05T16:07:49-05:00
testsuite: Make performance metric summary more readable

Along with some refactoring.

- - - - -
c4ca29c7 by Ben Gamari at 2019-12-05T16:07:49-05:00
testsuite: Use colors more consistently

- - - - -
3354c68e by Vladislav Zavialov at 2019-12-05T16:07:49-05:00
Pretty-printing of the * kind

Before this patch, GHC always printed the * kind unparenthesized.

This led to two issues:

1. Sometimes GHC printed invalid or incorrect code.
   For example, GHC would print:  type F @*   x = x
         when it meant to print:  type F @(*) x = x
   In the former case, instead of a kind application we were getting a
   type operator (@*).

2. Sometimes GHC printed kinds that were correct but hard to read.
   Should  Either * Int  be read as  Either (*) Int
                              or as  (*) Either Int  ?
   This depends on whether -XStarIsType is enabled, but it would be
   easier if we didn't have to check for the flag when reading the code.

We can solve both problems by assigning (*) a different precedence. Note
that Haskell98 kinds are not affected:

  ((* -> *) -> *) -> *  does NOT become  (((*) -> (*)) -> (*)) -> (*)

The parentheses are added when (*) is used in a function argument
position:

   F * * *   becomes  F (*) (*) (*)
   F A * B   becomes  F A (*) B
   Proxy *   becomes  Proxy (*)
   a * -> *  becomes  a (*) -> *

- - - - -
70dd0e4b by Vladislav Zavialov at 2019-12-05T16:07:49-05:00
Parenthesize the * kind in TH.Ppr

- - - - -
a7a4efbf by Ben Gamari at 2019-12-05T16:07:49-05:00
rts/NonMovingSweep: Fix locking of new mutable list allocation

Previously we used allocBlockOnNode_sync in nonmovingSweepMutLists
despite the fact that we aren't in the GC and therefore the allocation
spinlock isn't in use. This meant that sweep would end up spinning until
the next minor GC, when the SM lock was moved away from the SM_MUTEX to
the spinlock. This isn't a correctness issue but it sure isn't good for
performance.

Found thanks for Ward.

Fixes #17539.

- - - - -
f171b358 by Matthias Braun at 2019-12-05T16:07:51-05:00
Fix typo in documentation of Base.hs.
- - - - -
9897e8c8 by Gabor Greif at 2019-12-06T21:20:38-05:00
Implement pointer tagging for big families (#14373)

Formerly we punted on these and evaluated constructors always got a tag
of 1.

We now cascade switches because we have to check the tag first and when
it is MAX_PTR_TAG then get the precise tag from the info table and
switch on that. The only technically tricky part is that the default
case needs (logical) duplication. To do this we emit an extra label for
it and branch to that from the second switch. This avoids duplicated
codegen.

Here's a simple example of the new code gen:

    data D = D1 | D2 | D3 | D4 | D5 | D6 | D7 | D8

On a 64-bit system previously all constructors would be tagged 1. With
the new code gen D7 and D8 are tagged 7:

    [Lib.D7_con_entry() {
         ...
         {offset
           c1eu: // global
               R1 = R1 + 7;
               call (P64[Sp])(R1) args: 8, res: 0, upd: 8;
         }
     }]

    [Lib.D8_con_entry() {
         ...
         {offset
           c1ez: // global
               R1 = R1 + 7;
               call (P64[Sp])(R1) args: 8, res: 0, upd: 8;
         }
     }]

When switching we now look at the info table only when the tag is 7. For
example, if we derive Enum for the type above, the Cmm looks like this:

    c2Le:
        _s2Js::P64 = R1;
        _c2Lq::P64 = _s2Js::P64 & 7;
        switch [1 .. 7] _c2Lq::P64 {
            case 1 : goto c2Lk;
            case 2 : goto c2Ll;
            case 3 : goto c2Lm;
            case 4 : goto c2Ln;
            case 5 : goto c2Lo;
            case 6 : goto c2Lp;
            case 7 : goto c2Lj;
        }

    // Read info table for tag
    c2Lj:
        _c2Lv::I64 = %MO_UU_Conv_W32_W64(I32[I64[_s2Js::P64 & (-8)] - 4]);
        if (_c2Lv::I64 != 6) goto c2Lu; else goto c2Lt;

Generated Cmm sizes do not change too much, but binaries are very
slightly larger, due to the fact that the new instructions are longer in
encoded form. E.g. previously entry code for D8 above would be

    00000000000001c0 <Lib_D8_con_info>:
     1c0:	48 ff c3             	inc    %rbx
     1c3:	ff 65 00             	jmpq   *0x0(%rbp)

With this patch

    00000000000001d0 <Lib_D8_con_info>:
     1d0:	48 83 c3 07          	add    $0x7,%rbx
     1d4:	ff 65 00             	jmpq   *0x0(%rbp)

This is one byte longer.

Secondly, reading info table directly and then switching is shorter

    _c1co:
            movq -1(%rbx),%rax
            movl -4(%rax),%eax
            // Switch on info table tag
            jmp *_n1d5(,%rax,8)

than doing the same switch, and then for the tag 7 doing another switch:

    // When tag is 7
    _c1ct:
            andq $-8,%rbx
            movq (%rbx),%rax
            movl -4(%rax),%eax
            // Switch on info table tag
            ...

Some changes of binary sizes in actual programs:

- In NoFib the worst case is 0.1% increase in benchmark "parser" (see
  NoFib results below). All programs get slightly larger.

- Stage 2 compiler size does not change.

- In "containers" (the library) size of all object files increases
  0.0005%. Size of the test program "bitqueue-properties" increases
  0.03%.

nofib benchmarks kindly provided by Ömer (@osa1):

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.0%
            VSM          +0.0%      0.0%      0.0%      0.0%      0.0%
           anna          +0.0%      0.0%     +0.1%     -0.9%     -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.1%     -0.8%      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.1%     -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.0%      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.0%      0.0%     +0.0%     -0.1%     -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%     +1.2%     -6.1%     -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.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.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.4%     -1.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.0%     -0.0%     -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.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.0%     +0.0%     +0.0%
          sched          +0.0%      0.0%     +0.0%     +0.0%     +0.0%
            scs          +0.0%      0.0%     +0.0%     +0.0%      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.0%     -0.0%      0.0%
  spectral-norm          +0.0%      0.0%     -0.0%     -0.0%     -0.0%
         sphere          +0.0%      0.0%     +0.0%     -1.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.4%     -1.3%     +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.1%     +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%     -0.0%     -6.1%     -0.0%
            Max          +0.1%      0.0%     +1.2%     +0.0%     +0.0%
 Geometric Mean          +0.0%     -0.0%     +0.0%     -0.1%     -0.0%

NoFib GC Results
================

--------------------------------------------------------------------------------
        Program           Size    Allocs    Instrs     Reads    Writes
--------------------------------------------------------------------------------
        circsim          +0.0%      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%
         fulsom          +0.0%      0.0%      0.0%     -0.6%     -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%
      mutstore1          +0.0%      0.0%      0.0%     -0.0%     -0.0%
      mutstore2          +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.0%      0.0%     -0.0%     -0.6%     -0.0%
            Max          +0.0%      0.0%     +0.0%      0.0%      0.0%
 Geometric Mean          +0.0%     +0.0%     +0.0%     -0.1%     +0.0%

Fixes #14373

These performance regressions appear to be a fluke in CI. See the
discussion in !1742 for details.

Metric Increase:
    T6048
    T12234
    T12425
    Naperian
    T12150
    T5837
    T13035

- - - - -
ee07421f by Simon Peyton Jones at 2019-12-06T21:21:14-05:00
Work in progress on coercionLKind, coercionRKind

This is a preliminary patch for #17515

- - - - -
0a4ca9eb by Simon Peyton Jones at 2019-12-06T21:21:14-05:00
Split up coercionKind

This patch implements the idea in #17515, splitting `coercionKind` into:

 * `coercion{Left,Right}Kind`, which computes the left/right side of the
    pair
 * `coercionKind`, which computes the pair of coercible types

This is reduces allocation since we frequently only need only one side
of the pair. Specifically, we see the following improvements on x86-64
Debian 9:

| test     | new        | old           | relative chg. |
| :------- | ---------: | ------------: | ------------: |
| T5030	   | 695537752  | 747641152.0   | -6.97%        |
| T5321Fun | 449315744  | 474009040.0   | -5.21%        |
| T9872a   | 2611071400 | 2645040952.0  | -1.28%        |
| T9872c   | 2957097904 | 2994260264.0  | -1.24%        |
| T12227   | 773435072  | 812367768.0   | -4.79%        |
| T12545   | 3142687224 | 3215714752.0  | -2.27%        |
| T14683   | 9392407664 | 9824775000.0  | -4.40%        |

Metric Decrease:
    T12545
    T9872a
    T14683
    T5030
    T12227
    T9872c
    T5321Fun
    T9872b

- - - - -
d46a72e1 by Gabor Greif at 2019-12-09T12:05:15-05:00
Fix comment typos

The below is only necessary to fix the CI perf fluke that
happened in 9897e8c8ef0b19a9571ef97a1d9bb050c1ee9121:
-------------------------
Metric Decrease:
    T5837
    T6048
    T9020
    T12425
    T12234
    T13035
    T12150
    Naperian
-------------------------

- - - - -
e3bba7e4 by Micha Wiedenmann at 2019-12-10T19:52:44-05:00
users guide: Motivation of DefaultSignatures

- - - - -
843ceb38 by Ben Gamari at 2019-12-10T19:53:54-05:00
rts: Add a long form flag to enable the non-moving GC

The old flag, `-xn`, was quite cryptic. Here we add `--nonmoving-gc` in
addition.

- - - - -
921d3238 by Ryan Scott at 2019-12-10T19:54:34-05:00
Ignore unary constraint tuples during typechecking (#17511)

We deliberately avoid defining a magical `Unit%` class, for reasons
that I have expounded upon in the newly added
`Note [Ignore unary constraint tuples]` in `TcHsType`. However, a
sneaky user could try to insert `Unit%` into their program by way of
Template Haskell, leading to the interface-file error observed
in #17511. To avoid this, any time we encounter a unary constraint
tuple during typechecking, we drop the surrounding constraint tuple
application. This is safe to do since `Unit% a` and `a` would be
semantically equivalent (unlike other forms of unary tuples).

Fixes #17511.

- - - - -
436ec9f3 by Ben Gamari at 2019-12-10T19:55:37-05:00
gitlab-ci: Move changelog linting logic to shell script

Allowing it to be easily used locally.

- - - - -
2f6b434f by Ben Gamari at 2019-12-10T19:55:37-05:00
gitlab-ci: Move changelog linting logic to shell script

Allowing it to be easily used locally.

- - - - -
7a5a6e07 by Ben Gamari at 2019-12-10T19:56:25-05:00
base: Fix incorrect @since in GHC.Natural

Fixes #17547.

- - - - -
2bbfaf8a by Ben Gamari at 2019-12-10T19:57:01-05:00
hadrian: AArch64 supports the GHCi interpreter and SMP

I'm not sure how this was omitted from the list of supported
architectures.

- - - - -
8f1ceb67 by John Ericson at 2019-12-10T19:57:39-05:00
Move Int# section of primops.txt.pp

This matches the organization of the fixed-sized ones, and keeps each
Int* next to its corresponding Word*.

- - - - -
7a823b0f by John Ericson at 2019-12-10T19:57:39-05:00
Move Int64# and Word64# sections of primops.txt.pp

This way it is next to the other fixed-sized ones.

- - - - -
8dd9929a by Ben Gamari at 2019-12-10T19:58:19-05:00
testsuite: Add (broken) test for #17510

- - - - -
6e47a76a by Ben Gamari at 2019-12-10T19:58:59-05:00
Re-layout validate script

This script was previously a whitespace nightmare.

- - - - -
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)

- - - - -
c4f820a8 by Ben Gamari at 2020-03-26T11:22:59-04:00
typecheck: Check for non-sensical mkCoherence*Co applications

The mkCoherenceLeftCo and mkCoherenceRightCo helpers expect a
precondition on their arguments. Namely, in the case of

    mkCoherenceLeftCo r ty1 co co2

it holds that

    co2 :: ty1 ~r ty2

Check this.

- - - - -
2ec74231 by Ben Gamari at 2020-03-26T11:22:59-04:00
Assert that Vars are of expected type in toIface{Ty,Co}Var

- - - - -
227bec20 by Ben Gamari at 2020-03-26T11:28:23-04:00
Coercion zapping

- - - - -
e19bcc51 by Ben Gamari at 2020-03-26T16:36:37-04:00
Fix it

- - - - -


26 changed files:

- .ghcid
- .gitignore
- .gitlab-ci.yml
- + .gitlab/ci.sh
- − .gitlab/darwin-init.sh
- − .gitlab/fix-submodules.py
- .gitlab/issue_templates/bug.md
- + .gitlab/issue_templates/documentation_issue.md
- .gitlab/issue_templates/feature_request.md
- + .gitlab/linters/check-changelogs.sh
- .gitlab/linters/check-cpp.py
- .gitlab/linters/check-makefiles.py
- .gitlab/linters/linter.py
- .gitlab/merge_request_templates/merge-request.md
- − .gitlab/prepare-system.sh
- − .gitlab/push-test-metrics.sh
- .gitlab/start-head.hackage.sh
- + .gitlab/test-metrics.sh
- − .gitlab/win32-init.sh
- .gitmodules
- .mailmap
- CODEOWNERS
- HACKING.md
- aclocal.m4
- boot
- − build.nix.sh


The diff was not included because it is too large.


View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/75cb667c434a2b59a237c6d95877cc0eeb81b258...e19bcc513d66ac1e246a0b47bf5aea2cf6f20723

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/75cb667c434a2b59a237c6d95877cc0eeb81b258...e19bcc513d66ac1e246a0b47bf5aea2cf6f20723
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/20200327/bed239ac/attachment-0001.html>


More information about the ghc-commits mailing list