[Git][ghc/ghc][wip/T18319] 313 commits: testsuite: Fix comment for a language extension

Ben Gamari gitlab at gitlab.haskell.org
Wed Jun 10 17:30:29 UTC 2020



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


Commits:
0889f5ee by Takenobu Tani at 2020-04-12T11:44:52+09:00
testsuite: Fix comment for a language extension

[skip ci]

- - - - -
cd4f92b5 by Simon Peyton Jones at 2020-04-12T11:20:58-04:00
Significant refactor of Lint

This refactoring of Lint was triggered by #17923, which is
fixed by this patch.

The main change is this.  Instead of
   lintType :: Type -> LintM LintedKind
we now have
   lintType :: Type -> LintM LintedType

Previously, all of typeKind was effectively duplicate in lintType.
Moreover, since we have an ambient substitution, we still had to
apply the substition here and there, sometimes more than once. It
was all very tricky, in the end, and made my head hurt.

Now, lintType returns a fully linted type, with all substitutions
performed on it.  This is much simpler.

The same thing is needed for Coercions.  Instead of
  lintCoercion :: OutCoercion
               -> LintM (LintedKind, LintedKind,
                         LintedType, LintedType, Role)
we now have
  lintCoercion :: Coercion -> LintM LintedCoercion

Much simpler!  The code is shorter and less bug-prone.

There are a lot of knock on effects.  But life is now better.

Metric Decrease:
    T1969

- - - - -
0efaf301 by Josh Meredith at 2020-04-12T11:21:34-04:00
Implement extensible interface files

- - - - -
54ca66a7 by Ryan Scott at 2020-04-12T11:22:10-04:00
Use conLikeUserTyVarBinders to quantify field selector types

This patch:

1. Writes up a specification for how the types of top-level field
   selectors should be determined in a new section of the GHC User's
   Guide, and
2. Makes GHC actually implement that specification by using
   `conLikeUserTyVarBinders` in `mkOneRecordSelector` to preserve the
   order and specificity of type variables written by the user.

Fixes #18023.

- - - - -
35799dda by Ben Gamari at 2020-04-12T11:22:50-04:00
hadrian: Don't --export-dynamic on Darwin

When fixing #17962 I neglected to consider that --export-dynamic is only
supported on ELF platforms.

- - - - -
e8029816 by Alexis King at 2020-04-12T11:23:27-04:00
Add an INLINE pragma to Control.Category.>>>

This fixes #18013 by adding INLINE pragmas to both Control.Category.>>>
and GHC.Desugar.>>>. The functional change in this patch is tiny (just
two lines of pragmas!), but an accompanying Note explains in gory
detail what’s going on.

- - - - -
0da186c1 by Krzysztof Gogolewski at 2020-04-14T07:55:20-04:00
Change zipWith to zipWithEqual in a few places

- - - - -
074c1ccd by Andreas Klebinger at 2020-04-14T07:55:55-04:00
Small change to the windows ticker.

We already have a function to go from time to ms so use it.
Also expand on the state of timer resolution.

- - - - -
b69cc884 by Alp Mestanogullari at 2020-04-14T07:56:38-04:00
hadrian: get rid of unnecessary levels of nesting in source-dist

- - - - -
d0c3b069 by Julien Debon at 2020-04-14T07:57:16-04:00
doc (Foldable): Add examples to Data.Foldable

See #17929

- - - - -
5b08e0c0 by Ben Gamari at 2020-04-14T23:28:20-04:00
StgCRun: Enable unwinding only on Linux

It's broken on macOS due and SmartOS due to assembler differences
(#15207) so let's be conservative in enabling it. Also, refactor things
to make the intent clearer.

- - - - -
27cc2e7b by Ben Gamari at 2020-04-14T23:28:57-04:00
rts: Don't mark evacuate_large as inline

This function has two callsites and is quite large. GCC consequently
decides not to inline and warns instead. Given the situation, I can't
blame it. Let's just remove the inline specifier.

- - - - -
9853fc5e by Ben Gamari at 2020-04-14T23:29:48-04:00
base: Enable large file support for OFD locking impl.

Not only is this a good idea in general but this should also avoid
issue #17950 by ensuring that off_t is 64-bits.

- - - - -
7b41f21b by Matthew Pickering at 2020-04-14T23:30:24-04:00
Hadrian: Make -i paths absolute

The primary reason for this change is that ghcide does not work with
relative paths. It also matches what cabal and stack do, they always
pass absolute paths.

- - - - -
41230e26 by Daniel Gröber at 2020-04-14T23:31:01-04:00
Zero out pinned block alignment slop when profiling

The heap profiler currently cannot traverse pinned blocks because of
alignment slop. This used to just be a minor annoyance as the whole block
is accounted into a special cost center rather than the respective object's
CCS, cf. #7275. However for the new root profiler we would like to be able
to visit _every_ closure on the heap. We need to do this so we can get rid
of the current 'flip' bit hack in the heap traversal code.

Since info pointers are always non-zero we can in principle skip all the
slop in the profiler if we can rely on it being zeroed. This assumption
caused problems in the past though, commit a586b33f8e ("rts: Correct
handling of LARGE ARR_WORDS in LDV profiler"), part of !1118, tried to use
the same trick for BF_LARGE objects but neglected to take into account that
shrink*Array# functions don't ensure that slop is zeroed when not
compiling with profiling.

Later, commit 0c114c6599 ("Handle large ARR_WORDS in heap census (fix
as we will only be assuming slop is zeroed when profiling is on.

This commit also reduces the ammount of slop we introduce in the first
place by calculating the needed alignment before doing the allocation for
small objects where we know the next available address. For large objects
we don't know how much alignment we'll have to do yet since those details
are hidden behind the allocateMightFail function so there we continue to
allocate the maximum additional words we'll need to do the alignment.

So we don't have to duplicate all this logic in the cmm code we pull it
into the RTS allocatePinned function instead.

Metric Decrease:
    T7257
    haddock.Cabal
    haddock.base

- - - - -
15fa9bd6 by Daniel Gröber at 2020-04-14T23:31:01-04:00
rts: Expand and add more notes regarding slop

- - - - -
caf3f444 by Daniel Gröber at 2020-04-14T23:31:01-04:00
rts: allocatePinned: Fix confusion about word/byte units

- - - - -
c3c0f662 by Daniel Gröber at 2020-04-14T23:31:01-04:00
rts: Underline some Notes as is conventional

- - - - -
e149dea9 by Daniel Gröber at 2020-04-14T23:31:38-04:00
rts: Fix nomenclature in OVERWRITING_CLOSURE macros

The additional commentary introduced by commit 8916e64e5437 ("Implement
shrinkSmallMutableArray# and resizeSmallMutableArray#.") unfortunately got
this wrong. We set 'prim' to true in overwritingClosureOfs because we
_don't_ want to call LDV_recordDead().

The reason is because of this "inherently used" distinction made in the LDV
profiler so I rename the variable to be more appropriate.

- - - - -
1dd3d18c by Daniel Gröber at 2020-04-14T23:31:38-04:00
Remove call to LDV_RECORD_CREATE for array resizing

- - - - -
19de2fb0 by Daniel Gröber at 2020-04-14T23:31:38-04:00
rts: Assert LDV_recordDead is not called for inherently used closures

The comments make it clear LDV_recordDead should not be called for
inhererently used closures, so add an assertion to codify this fact.

- - - - -
0b934e30 by Ryan Scott at 2020-04-14T23:32:14-04:00
Bump template-haskell version to 2.17.0.0

This requires bumping the `exceptions` and `text` submodules to bring
in commits that bump their respective upper version bounds on
`template-haskell`.

Fixes #17645. Fixes #17696.

Note that the new `text` commit includes a fair number of additions
to the Haddocks in that library. As a result, Haddock has to do more
work during the `haddock.Cabal` test case, increasing the number of
allocations it requires. Therefore,

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

- - - - -
22cc8e51 by Ryan Scott at 2020-04-15T17:48:47-04:00
Fix #18052 by using pprPrefixOcc in more places

This fixes several small oversights in the choice of pretty-printing
function to use. Fixes #18052.

- - - - -
ec77b2f1 by Daniel Gröber at 2020-04-15T17:49:24-04:00
rts: ProfHeap: Fix wrong time in last heap profile sample

We've had this longstanding issue in the heap profiler, where the time of
the last sample in the profile is sometimes way off causing the rendered
graph to be quite useless for long runs.

It seems to me the problem is that we use mut_user_time() for the last
sample as opposed to getRTSStats(), which we use when calling heapProfile()
in GC.c.

The former is equivalent to getProcessCPUTime() but the latter does
some additional stuff:

    getProcessCPUTime() - end_init_cpu - stats.gc_cpu_ns -
    stats.nonmoving_gc_cpu_ns

So to fix this just use getRTSStats() in both places.

- - - - -
85fc32f0 by Sylvain Henry at 2020-04-17T12:45:25-04:00
Hadrian: fix dyn_o/dyn_hi rule (#17534)

- - - - -
bfde3b76 by Ryan Scott at 2020-04-17T12:46:02-04:00
Fix #18065 by fixing an InstCo oversight in Core Lint

There was a small thinko in Core Lint's treatment of `InstCo`
coercions that ultimately led to #18065. The fix: add an apostrophe.
That's it!

Fixes #18065.

Co-authored-by: Simon Peyton Jones <simonpj at microsoft.com>

- - - - -
a05348eb by Cale Gibbard at 2020-04-17T13:08:47-04:00
Change the fail operator argument of BindStmt to be a Maybe

Don't use noSyntaxExpr for it. There is no good way to defensively case
on that, nor is it clear one ought to do so.

- - - - -
79e27144 by John Ericson at 2020-04-17T13:08:47-04:00
Use trees that grow for rebindable operators for `<-` binds

Also add more documentation.

- - - - -
18bc16ed by Cale Gibbard at 2020-04-17T13:08:47-04:00
Use FailOperator in more places, define a couple datatypes (XBindStmtRn and XBindStmtTc) to help clarify the meaning of XBindStmt in the renamer and typechecker

- - - - -
84cc8394 by Simon Peyton Jones at 2020-04-18T13:20:29-04:00
Add a missing zonk in tcHsPartialType

I omitted a vital zonk when refactoring tcHsPartialType in
   commit 48fb3482f8cbc8a4b37161021e846105f980eed4
   Author: Simon Peyton Jones <simonpj at microsoft.com>
   Date:   Wed Jun 5 08:55:17 2019 +0100

   Fix typechecking of partial type signatures

This patch fixes it and adds commentary to explain why.

Fixes #18008

- - - - -
2ee96ac1 by Ben Gamari at 2020-04-18T13:21:05-04:00
gitlab-ci: Bump FreeBSD bootstrap compiler to 8.10.1

- - - - -
434312e5 by Ben Gamari at 2020-04-18T13:21:05-04:00
gitlab-ci: Enable FreeBSD job for so-labelled MRs

- - - - -
ddffb227 by Ben Gamari at 2020-04-18T13:21:05-04:00
gitlab-ci: Use rules syntax for conditional jobs

- - - - -
e2586828 by Ben Gamari at 2020-04-18T13:21:05-04:00
Bump hsc2hs submodule

- - - - -
15ab6cd5 by Ömer Sinan Ağacan at 2020-04-18T13:21:44-04:00
Improve prepForeignCall error reporting

Show parameters and description of the error code when ffi_prep_cif
fails.

This may be helpful for debugging #17018.

- - - - -
3ca52151 by Sylvain Henry at 2020-04-18T20:04:14+02:00
GHC.Core.Opt renaming

* GHC.Core.Op                  => GHC.Core.Opt
* GHC.Core.Opt.Simplify.Driver => GHC.Core.Opt.Driver
* GHC.Core.Opt.Tidy            => GHC.Core.Tidy
* GHC.Core.Opt.WorkWrap.Lib    => GHC.Core.Opt.WorkWrap.Utils

As discussed in:
 * https://mail.haskell.org/pipermail/ghc-devs/2020-April/018758.html
 * https://gitlab.haskell.org/ghc/ghc/issues/13009#note_264650

- - - - -
15312bbb by Sylvain Henry at 2020-04-18T20:04:46+02:00
Modules (#13009)

* SysTools
* Parser
* GHC.Builtin
* GHC.Iface.Recomp
* Settings

Update Haddock submodule

Metric Decrease:
    Naperian
    parsing001

- - - - -
eaed0a32 by Alexis King at 2020-04-19T03:16:44-04:00
Add missing addInScope call for letrec binders in OccurAnal

This fixes #18044, where a shadowed variable was incorrectly substituted
by the binder swap on the RHS of a floated-in letrec. This can only
happen when the uniques line up *just* right, so writing a regression
test would be very difficult, but at least the fix is small and
straightforward.

- - - - -
36882493 by Shayne Fletcher at 2020-04-20T04:36:43-04:00
Derive Ord instance for Extension

Metric Increase:
   T12150
   T12234

- - - - -
b43365ad by Simon Peyton Jones at 2020-04-20T04:37:20-04:00
Fix a buglet in redundant-constraint warnings

Ticket #18036 pointed out that we were reporting a redundant
constraint when it really really wasn't.

Turned out to be a buglet in the SkolemInfo for the
relevant implication constraint.  Easily fixed!

- - - - -
d5fae7da by Ömer Sinan Ağacan at 2020-04-20T14:39:28-04:00
Mark T12010 fragile on 32-bit

- - - - -
bca02fca by Adam Sandberg Ericsson at 2020-04-21T06:38:45-04:00
docs: drop note about not supporting shared libraries on unix systems

[skip ci]

- - - - -
6655f933 by Sylvain Henry at 2020-04-21T06:39:32-04:00
Use ParserFlags in GHC.Runtime.Eval (#17957)

Instead of passing `DynFlags` to functions such as `isStmt` and
`hasImport` in `GHC.Runtime.Eval` we pass `ParserFlags`. It's a much
simpler structure that can be created purely with `mkParserFlags'`.

- - - - -
70be0fbc by Sylvain Henry at 2020-04-21T06:39:32-04:00
GHC.Runtime: avoid DynFlags (#17957)

* add `getPlatform :: TcM Platform` helper
* remove unused `DynFlags` parameter from `emptyPLS`

- - - - -
35e43d48 by Sylvain Henry at 2020-04-21T06:39:32-04:00
Avoid DynFlags in Ppr code (#17957)

* replace `DynFlags` parameters with `SDocContext` parameters for a few
  Ppr related functions: `bufLeftRenderSDoc`, `printSDoc`,
  `printSDocLn`, `showSDocOneLine`.

* remove the use of `pprCols :: DynFlags -> Int` in Outputable. We
  already have the information via `sdocLineLength :: SDocContext ->
  Int`

- - - - -
ce5c2999 by Sylvain Henry at 2020-04-21T06:39:32-04:00
Avoid using sdocWithDynFlags (#17957)

Remove one use of `sdocWithDynFlags` from `GHC.CmmToLlvm.llvmCodeGen'`
and from `GHC.Driver.CodeOutput.profilingInitCode`

- - - - -
f2a98996 by Sylvain Henry at 2020-04-21T06:39:32-04:00
Avoid `sdocWithDynFlags` in `pprCLbl` (#17957)

* add a `DynFlags` parameter to `pprCLbl`
* put `maybe_underscore` and `pprAsmCLbl` in a `where` clause to avoid
  `DynFlags` parameters

- - - - -
747093b7 by Sylvain Henry at 2020-04-21T06:39:32-04:00
CmmToAsm DynFlags refactoring (#17957)

* Remove `DynFlags` parameter from `isDynLinkName`: `isDynLinkName` used
  to test the global `ExternalDynamicRefs` flag. Now we test it outside of
  `isDynLinkName`

* Add new fields into `NCGConfig`: current unit id, sse/bmi versions,
  externalDynamicRefs, etc.

* Replace many uses of `DynFlags` by `NCGConfig`

* Moved `BMI/SSE` datatypes into `GHC.Platform`

- - - - -
ffd7eef2 by Takenobu Tani at 2020-04-22T23:09:50-04:00
stg-spec: Modify file paths according to new module hierarchy

This patch updates file paths according to new module hierarchy [1]:

  * GHC/Stg/Syntax.hs       <= stgSyn/StgSyn.hs
  * GHC/Types/Literal.hs    <= basicTypes/Literal.hs
  * GHC/Types/CostCentre.hs <= profiling/CostCentre.hs

This patch also updates old file path [2]:

  * utils/genapply/Main.hs  <= utils/genapply/GenApply.hs

[1]: https://gitlab.haskell.org/ghc/ghc/-/wikis/Make-GHC-codebase-more-modular
[2]: commit 0cc4aad36f

[skip ci]

- - - - -
e8a5d81b by Jonathan DK Gibbons at 2020-04-22T23:10:28-04:00
Refactor the `MatchResult` type in the desugarer

This way, it does a better job of proving whether or not the fail operator is used.

- - - - -
dcb7fe5a by John Ericson at 2020-04-22T23:10:28-04:00
Remove panic in dsHandleMonadicFailure

Rework dsHandleMonadicFailure to be correct by construction instead of
using an unreachable panic.

- - - - -
cde23cd4 by John Ericson at 2020-04-22T23:10:28-04:00
Inline `adjustMatchResult`

It is just `fmap`

- - - - -
72cb6bcc by John Ericson at 2020-04-22T23:10:28-04:00
Generalize type of `matchCanFail`

- - - - -
401f7bb3 by John Ericson at 2020-04-22T23:10:28-04:00
`MatchResult'` -> `MatchResult`

Inline `MatchResult` alias accordingly.

- - - - -
6c9fae23 by Alexis King at 2020-04-22T23:11:12-04:00
Mark DataCon wrappers CONLIKE

Now that DataCon wrappers don’t inline until phase 0 (see commit
b78cc64e923716ac0512c299f42d4d0012306c05), it’s important that
case-of-known-constructor and RULE matching be able to see saturated
applications of DataCon wrappers in unfoldings. Making them conlike is a
natural way to do it, since they are, in fact, precisely the sort of
thing the CONLIKE pragma exists to solve.

Fixes #18012.

This also bumps the version of the parsec submodule to incorporate a
patch that avoids a metric increase on the haddock perf tests. The
increase was not really a flaw in this patch, as parsec was implicitly
relying on inlining heuristics. The patch to parsec just adds some
INLINABLE pragmas, and we get a nice performance bump out of it (well
beyond the performance we lost from this patch).

Metric Decrease:
    T12234
    WWRec
    haddock.Cabal
    haddock.base
    haddock.compiler

- - - - -
48b8951e by Roland Senn at 2020-04-22T23:11:51-04:00
Fix tab-completion for :break (#17989)

In tab-completion for the `:break` command, only those
identifiers should be shown, that are accepted in the
`:break` command. Hence these identifiers must be

- defined in an interpreted module
- top-level
- currently in scope
- listed in a `ModBreaks` value as a possible breakpoint.

The identifiers my be qualified or unqualified.

To get all possible top-level breakpoints for tab-completeion
with the correct qualification do:

1. Build the  list called `pifsBreaks` of all pairs of
(Identifier, module-filename) from the `ModBreaks` values.
Here all identifiers are unqualified.

2. Build the list called `pifInscope` of all pairs of
(Identifiers, module-filename) with identifiers from
the `GlobalRdrEnv`. Take only those identifiers that are
in scope and have the  correct prefix.
Here the identifiers may be qualified.

3. From the `pifInscope` list seclect all pairs that can be
found in the `pifsBreaks` list, by comparing only the
unqualified part of the identifier.
The remaining identifiers can be used for tab-completion.

This ensures, that we show only identifiers, that can be used
in a `:break` command.

- - - - -
34a45ee6 by Peter Trommler at 2020-04-22T23:12:27-04:00
PPC NCG: Add DWARF constants and debug labels

Fixes #11261

- - - - -
ffde2348 by Simon Peyton Jones at 2020-04-22T23:13:06-04:00
Do eager instantation in terms

This patch implements eager instantiation, a small but critical change
to the type inference engine, #17173.  The main change is this:

  When inferring types, always return an instantiated type
  (for now, deeply instantiated; in future shallowly instantiated)

There is more discussion in
https://www.tweag.io/posts/2020-04-02-lazy-eager-instantiation.html

There is quite a bit of refactoring in this patch:

* The ir_inst field of GHC.Tc.Utils.TcType.InferResultk
  has entirely gone.  So tcInferInst and tcInferNoInst have collapsed
  into tcInfer.

* Type inference of applications, via tcInferApp and
  tcInferAppHead, are substantially refactored, preparing
  the way for Quick Look impredicativity.

* New pure function GHC.Tc.Gen.Expr.collectHsArgs and applyHsArgs
  are beatifully dual.  We can see the zipper!

* GHC.Tc.Gen.Expr.tcArgs is now much nicer; no longer needs to return
  a wrapper

* In HsExpr, HsTypeApp now contains the the actual type argument,
  and is used in desugaring, rather than putting it in a mysterious
  wrapper.

* I struggled a bit with good error reporting in
  Unify.matchActualFunTysPart. It's a little bit simpler than before,
  but still not great.

Some smaller things

* Rename tcPolyExpr --> tcCheckExpr
         tcMonoExpr --> tcLExpr
* tcPatSig moves from GHC.Tc.Gen.HsType to GHC.Tc.Gen.Pat

Metric Decrease:
    T9961

Reduction of 1.6% in comiler allocation on T9961, I think.

- - - - -
6f84aca3 by Ben Gamari at 2020-04-22T23:13:43-04:00
rts: Ensure that sigaction structs are initialized

I noticed these may have uninitialized fields when looking into #18037.
The reporter says that zeroing them doesn't fix the MSAN failures they
observe but zeroing them is the right thing to do regardless.

- - - - -
c29f0fa6 by Andreas Klebinger at 2020-04-22T23:14:21-04:00
Add "ddump-cmm-opt" as alias for "ddump-opt-cmm".

- - - - -
4b4a8b60 by Ben Gamari at 2020-04-22T23:14:57-04:00
llvmGen: Remove -fast-llvm flag

Issue #18076 drew my attention to the undocumented `-fast-llvm` flag for
the LLVM code generator introduced in
22733532171330136d87533d523f565f2a4f102f. Speaking to Moritz about this,
the motivation for this flag was to avoid potential incompatibilities
between LLVM and the assembler/linker toolchain by making LLVM
responsible for machine-code generation.

Unfortunately, this cannot possibly work: the LLVM backend's mangler
performs a number of transforms on the assembler generated by LLVM that
are necessary for correctness. These are currently:

 * mangling Haskell functions' symbol types to be `object` instead of
   `function` on ELF platforms (necessary for tables-next-to-code)
 * mangling AVX instructions to ensure that we don't assume alignment
   (which LLVM otherwise does)
 * mangling Darwin's  subsections-via-symbols directives

Given that these are all necessary I don't believe that we can support
`-fast-llvm`. Let's rather remove it.

- - - - -
831b6642 by Moritz Angermann at 2020-04-22T23:15:33-04:00
Fix build warning; add more informative information to the linker; fix linker for empty sections

- - - - -
c409961a by Ryan Scott at 2020-04-22T23:16:12-04:00
Update commentary and slightly refactor GHC.Tc.Deriv.Infer

There was some out-of-date commentary in `GHC.Tc.Deriv.Infer` that
has been modernized. Along the way, I removed the `bad` constraints
in `simplifyDeriv`, which did not serve any useful purpose (besides
being printed in debugging output).

Fixes #18073.

- - - - -
125aa2b8 by Ömer Sinan Ağacan at 2020-04-22T23:16:51-04:00
Remove leftover comment in tcRnModule', redundant bind

The code for the comment was moved in dc8c03b2a5c but the comment was
forgotten.

- - - - -
8ea37b01 by Sylvain Henry at 2020-04-22T23:17:34-04:00
RTS: workaround a Linux kernel bug in timerfd

Reading a timerfd may return 0: https://lkml.org/lkml/2019/8/16/335.

This is currently undocumented behavior and documentation "won't happen
anytime soon" (https://lkml.org/lkml/2020/2/13/295).

With this patch, we just ignore the result instead of crashing. It may
fix #18033 but we can't be sure because we don't have enough
information.

See also this discussion about the kernel bug:
https://github.com/Azure/sonic-swss-common/pull/302/files/1f070e7920c2e5d63316c0105bf4481e73d72dc9

- - - - -
cd8409c2 by Ryan Scott at 2020-04-23T11:39:24-04:00
Create di_scoped_tvs for associated data family instances properly

See `Note [Associated data family instances and di_scoped_tvs]` in
`GHC.Tc.TyCl.Instance`, which explains all of the moving parts.

Fixes #18055.

- - - - -
339e8ece by Ben Gamari at 2020-04-23T11:40:02-04:00
hadrian/ghci: Allow arguments to be passed to GHCi

Previously the arguments passed to hadrian/ghci were passed both to
`hadrian` and GHCi. This is rather odd given that there are essentially
not arguments in the intersection of the two. Let's just pass them to
GHCi; this allows `hadrian/ghci -Werror`.

- - - - -
5946c85a by Ben Gamari at 2020-04-23T11:40:38-04:00
testsuite: Don't attempt to read .std{err,out} files if they don't exist

Simon reports that he was previously seeing framework failures due to
an attempt to read the non-existing T13456.stderr. While I don't know
exactly what this is due to, it does seem like a non-existing
.std{out,err} file should be equivalent to an empty file. Teach the
testsuite driver to treat it as such.

- - - - -
c42754d5 by John Ericson at 2020-04-23T18:32:43-04:00
Trees That Grow refactor for `ConPat` and `CoPat`

- `ConPat{In,Out}` -> `ConPat`

- `CoPat` -> `XPat (CoPat ..)`

Note that `GHC.HS.*` still uses `HsWrap`, but only when `p ~ GhcTc`.
After this change, moving the type family instances out of `GHC.HS.*` is
sufficient to break the cycle.

Add XCollectPat class to decide how binders are collected from XXPat based on the pass.

Previously we did this with IsPass, but that doesn't work for Haddock's
DocNameI, and the constraint doesn't express what actual distinction is being
made. Perhaps a class for collecting binders more generally is in order, but we
haven't attempted this yet.

Pure refactor of code around ConPat

 - InPat/OutPat synonyms removed

 - rename several identifiers

 - redundant constraints removed

 - move extension field in ConPat to be first

 - make ConPat use record syntax more consistently

Fix T6145 (ConPatIn became ConPat)

Add comments from SPJ.

Add comment about haddock's use of CollectPass.

Updates haddock submodule.

- - - - -
72da0c29 by mniip at 2020-04-23T18:33:21-04:00
Add :doc to GHC.Prim

- - - - -
2c23e2e3 by mniip at 2020-04-23T18:33:21-04:00
Include docs for non-primop entries in primops.txt as well

- - - - -
0ac29c88 by mniip at 2020-04-23T18:33:21-04:00
GHC.Prim docs: note and test

- - - - -
b0fbfc75 by John Ericson at 2020-04-24T12:07:14-04:00
Switch order on `GhcMake.IsBoot`

In !1798 we were requested to replace many `Bool`s with this data type.
But those bools had `False` meaning `NotBoot`, so the `Ord` instance
would be flipped if we use this data-type as-is.

Since the planned formally-`Bool` occurrences vastly outnumber the
current occurrences, we figured it would be better to conform the `Ord`
instance to how the `Bool` is used now, fixing any issues, rather than
fix them currently with the bigger refactor later in !1798. That way,
!1798 can be a "pure" refactor with no behavioral changes.

- - - - -
af332442 by Sylvain Henry at 2020-04-26T13:55:14-04:00
Modules: Utils and Data (#13009)

Update Haddock submodule

Metric Increase:
   haddock.compiler

- - - - -
cd4434c8 by Sylvain Henry at 2020-04-26T13:55:16-04:00
Fix misleading Ptr phantom type in SerializedCompact (#15653)

- - - - -
22bf5c73 by Ömer Sinan Ağacan at 2020-04-26T13:55:22-04:00
Tweak includes in non-moving GC headers

We don't use hash tables in non-moving GC so remove the includes.

This breaks Compact.c as existing includes no longer include Hash.h, so
include Hash.h explicitly in Compact.c.

- - - - -
99823ed2 by Sylvain Henry at 2020-04-27T20:24:46-04:00
TH: fix Show/Eq/Ord instances for Bytes (#16457)

We shouldn't compare pointer values but the actual bytes.

- - - - -
c62271a2 by Alp Mestanogullari at 2020-04-27T20:25:33-04:00
hadrian: always capture both stdout and stderr when running a builder fails

The idea being that when a builder('s command) fails, we quite likely want to
have all the information available to figure out why. Depending on the builder
_and_ the particular problem, the useful bits of information can be printed
on stdout or stderr.

We accomplish this by defining a simple wrapper for Shake's `cmd` function,
that just _always_ captures both streams in case the command returns a non-zero
exit code, and by using this wrapper everywhere in `hadrian/src/Builder.hs`.

Fixes #18089.

- - - - -
4b9764db by Ryan Scott at 2020-04-28T15:40:04-04:00
Define a Quote IO instance

Fixes #18103.

- - - - -
518a63d4 by Ryan Scott at 2020-04-28T15:40:42-04:00
Make boxed 1-tuples have known keys

Unlike other tuples, which use special syntax and are "known" by way
of a special `isBuiltInOcc_maybe` code path, boxed 1-tuples do not
use special syntax. Therefore, in order to make sure that the
internals of GHC are aware of the `data Unit a = Unit a` definition
in `GHC.Tuple`, we give `Unit` known keys. For the full details, see
`Note [One-tuples] (Wrinkle: Make boxed one-tuple names have known keys)`
in `GHC.Builtin.Types`.

Fixes #18097.

- - - - -
2cfc4ab9 by Sylvain Henry at 2020-04-30T01:56:56-04:00
Document backpack fields in DynFlags

- - - - -
10a2ba90 by Sylvain Henry at 2020-04-30T01:56:56-04:00
Refactor UnitInfo

* Rename InstalledPackageInfo into GenericUnitInfo

The name InstalledPackageInfo is only kept for alleged backward
compatibility reason in Cabal. ghc-boot has its own stripped down copy
of this datatype but it doesn't need to keep the name. Internally we
already use type aliases (UnitInfo in GHC, PackageCacheFormat in
ghc-pkg).

* Rename UnitInfo fields: add "unit" prefix and fix misleading names

* Add comments on every UnitInfo field

* Rename SourcePackageId into PackageId

"Package" already indicates that it's a "source package". Installed
package components are called units.

Update Haddock submodule

- - - - -
69562e34 by Sylvain Henry at 2020-04-30T01:56:56-04:00
Remove unused `emptyGenericUnitInfo`

- - - - -
9e2c8e0e by Sylvain Henry at 2020-04-30T01:56:56-04:00
Refactor UnitInfo load/store from databases

Converting between UnitInfo stored in package databases and UnitInfo as
they are used in ghc-pkg and ghc was done in a very convoluted way (via
BinaryStringRep and DbUnitModuleRep type classes using fun deps, etc.).
It was difficult to understand and even more to modify (I wanted to
try to use a GADT for UnitId but fun deps got in the way).

The new code uses much more straightforward functions to convert between
the different representations. Much simpler.

- - - - -
ea717aa4 by Sylvain Henry at 2020-04-30T01:56:56-04:00
Factorize mungePackagePaths code

This patch factorizes the duplicated code used in ghc-pkg and in GHC to
munge package paths/urls.

It also fixes haddock-html munging in GHC (allowed to be either a file
or a url) to mimic ghc-pkg behavior.

- - - - -
10d15f1e by Sylvain Henry at 2020-04-30T01:56:56-04:00
Refactoring unit management code

Over the years the unit management code has been modified a lot to keep
up with changes in Cabal (e.g. support for several library components in
the same package), to integrate BackPack, etc. I found it very hard to
understand as the terminology wasn't consistent, was referring to past
concepts, etc.

The terminology is now explained as clearly as I could in the Note
"About Units" and the code is refactored to reflect it.

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

Many names were misleading: UnitId is not an Id but could be a virtual
unit (an indefinite one instantiated on the fly), IndefUnitId
constructor may contain a definite instantiated unit, etc.

   * Rename IndefUnitId into InstantiatedUnit
   * Rename IndefModule into InstantiatedModule
   * Rename UnitId type into Unit
   * Rename IndefiniteUnitId constructor into VirtUnit
   * Rename DefiniteUnitId constructor into RealUnit
   * Rename packageConfigId into mkUnit
   * Rename getPackageDetails into unsafeGetUnitInfo
   * Rename InstalledUnitId into UnitId

Remove references to misleading ComponentId: a ComponentId is just an
indefinite unit-id to be instantiated.

   * Rename ComponentId into IndefUnitId
   * Rename ComponentDetails into UnitPprInfo
   * Fix display of UnitPprInfo with empty version: this is now used for
     units dynamically generated by BackPack

Generalize several types (Module, Unit, etc.) so that they can be used
with different unit identifier types: UnitKey, UnitId, Unit, etc.

   * GenModule: Module, InstantiatedModule and InstalledModule are now
     instances of this type
   * Generalize DefUnitId, IndefUnitId, Unit, InstantiatedUnit,
     PackageDatabase

Replace BackPack fake "hole" UnitId by a proper HoleUnit constructor.

Add basic support for UnitKey. They should be used more in the future to
avoid mixing them up with UnitId as we do now.

Add many comments.

Update Haddock submodule

- - - - -
8bfb0219 by Sylvain Henry at 2020-04-30T01:56:56-04:00
Unit: split and rename modules

Introduce GHC.Unit.* hierarchy for everything concerning units, packages
and modules.

Update Haddock submodule

- - - - -
71484b09 by Alexis King at 2020-04-30T01:57:35-04:00
Allow block arguments in arrow control operators

Arrow control operators have their own entries in the grammar, so they
did not cooperate with BlockArguments. This was just a minor oversight,
so this patch adjusts the grammar to add the desired behavior.

fixes #18050

- - - - -
a48cd2a0 by Alexis King at 2020-04-30T01:57:35-04:00
Allow LambdaCase to be used as a command in proc notation

- - - - -
f4d3773c by Alexis King at 2020-04-30T01:57:35-04:00
Document BlockArguments/LambdaCase support in arrow notation

- - - - -
5bdfdd13 by Simon Peyton Jones at 2020-04-30T01:58:15-04:00
Add tests for #17873

- - - - -
19b701c2 by Simon Peyton Jones at 2020-04-30T07:30:13-04:00
Mark rule args as non-tail-called

This was just an omission...b I'd failed to call markAllNonTailCall on
rule args.  I think this bug has been here a long time, but it's quite
hard to trigger.

Fixes #18098

- - - - -
014ef4a3 by Matthew Pickering at 2020-04-30T07:30:50-04:00
Hadrian: Improve tool-args command to support more components

There is a new command to hadrian, tool:path/to/file.hs, which returns
the options needed to compile that file in GHCi.

This is now used in the ghci script with argument `ghc/Main.hs` but its
main purpose is to support the new multi-component branch of ghcide.

- - - - -
2aa67611 by Ben Gamari at 2020-04-30T21:34:44-04:00
nonmoving: Clear bitmap after initializing block size

Previously nonmovingInitSegment would clear the bitmap before
initializing the segment's block size. This is broken since
nonmovingClearBitmap looks at the segment's block size to determine how
much bitmap to clear.

- - - - -
54dad3cf by Ben Gamari at 2020-04-30T21:34:44-04:00
nonmoving: Explicitly memoize block count

A profile cast doubt on whether the compiler hoisted the bound out the
loop as I would have expected here. It turns out it did but nevertheless
it seems clearer to just do this manually.

- - - - -
99ff8145 by Ben Gamari at 2020-04-30T21:34:44-04:00
nonmoving: Eagerly flush all capabilities' update remembered sets

(cherry picked from commit 2fa79119570b358a4db61446396889b8260d7957)

- - - - -
05b0a9fd by Ömer Sinan Ağacan at 2020-04-30T21:35:24-04:00
Remove OneShotInfo field of LFReEntrant, document OneShotInfo

The field is only used in withNewTickyCounterFun and it's easier to
directly pass a parameter for one-shot info to withNewTickyCounterFun
instead of passing it via LFReEntrant. This also makes !2842 simpler.

Other changes:

- New Note (by SPJ) [OneShotInfo overview] added.
- Arity argument of thunkCode removed as it's always 0.

- - - - -
a43620c6 by Ömer Sinan Ağacan at 2020-04-30T21:35:24-04:00
GHC.StgToCmm.Ticky: remove a few unused stuff

- - - - -
780de9e1 by Sylvain Henry at 2020-05-01T10:37:39-04:00
Use platform in Iface Binary

- - - - -
f8386c7b by Sylvain Henry at 2020-05-01T10:37:39-04:00
Refactor PprDebug handling

If `-dppr-debug` is set, then PprUser and PprDump styles are silently
replaced with PprDebug style. This was done in `mkUserStyle` and
`mkDumpStyle` smart constructors. As a consequence they needed a
DynFlags parameter.

Now we keep the original PprUser and PprDump styles until they are used
to create an `SDocContext`. I.e. the substitution is only performed in
`initSDocContext`.

- - - - -
b3df9e78 by Sylvain Henry at 2020-05-01T10:37:39-04:00
Remove PprStyle param of logging actions

Use `withPprStyle` instead to apply a specific style to a SDoc.

- - - - -
de9fc995 by Sylvain Henry at 2020-05-01T10:37:39-04:00
Fully remove PprDebug

PprDebug was a pain to deal with consistently as it is implied by
`-dppr-debug` but it isn't really a PprStyle. We remove it completely
and query the appropriate SDoc flag instead (`sdocPprDebug`) via
helpers (`getPprDebug` and its friends).

- - - - -
8b51fcbd by Sebastian Graf at 2020-05-01T10:38:16-04:00
PmCheck: Only call checkSingle if we would report warnings

- - - - -
fd7ea0fe by Sebastian Graf at 2020-05-01T10:38:16-04:00
PmCheck: Pick up `EvVar`s bound in `HsWrapper`s for long-distance info

`HsWrapper`s introduce evidence bindings through `WpEvLam` which the
pattern-match coverage checker should be made aware of.

Failing to do so caused #18049, where the resulting impreciseness of
imcompleteness warnings seemingly contradicted with
`-Winaccessible-code`.

The solution is simple: Collect all the evidence binders of an
`HsWrapper` and add it to the ambient `Deltas` before desugaring
the wrapped expression.

But that means we pick up many more evidence bindings, even when they
wrap around code without a single pattern match to check! That regressed
`T3064` by over 300%, so now we are adding long-distance info lazily
through judicious use of `unsafeInterleaveIO`.

Fixes #18049.

- - - - -
7bfe9ac5 by Ben Gamari at 2020-05-03T04:41:33-04:00
rts: Enable tracing of nonmoving heap census with -ln

Previously this was not easily available to the user. Fix this.
Non-moving collection lifecycle events are now reported with -lg.

- - - - -
c560dd07 by Ben Gamari at 2020-05-03T04:41:33-04:00
users guide: Move eventlog documentation users guide

- - - - -
02543d5e by Ben Gamari at 2020-05-03T04:41:33-04:00
users guide: Add documentation for non-moving GC events

- - - - -
b465dd45 by Alexis King at 2020-05-03T04:42:12-04:00
Flatten nested casts in the simple optimizer

Normally, we aren’t supposed to generated any nested casts, since mkCast
takes care to flatten them, but the simple optimizer didn’t use mkCast,
so they could show up after inlining. This isn’t really a problem, since
the simplifier will clean them up immediately anyway, but it can clutter
the -ddump-ds output, and it’s an extremely easy fix.

closes #18112

- - - - -
8bdc03d6 by Simon Peyton Jones at 2020-05-04T01:56:59-04:00
Don't return a panic in tcNestedSplice

In GHC.Tc.Gen.Splice.tcNestedSplice we were returning a
typechecked expression of "panic". That is usually OK, because
the result is discarded.  But it happens that tcApp now looks at
the typechecked expression, trivially, to ask if it is tagToEnum.
So being bottom is bad.

Moreover a debug-trace might print it out.

So better to return a civilised expression, even though it is
usually discarded.

- - - - -
0bf640b1 by Baldur Blöndal at 2020-05-04T01:57:36-04:00
Don't require parentheses around via type (`-XDerivingVia'). Fixes #18130".

- - - - -
30272412 by Artem Pelenitsyn at 2020-05-04T13:19:59-04:00
Remove custom ExceptionMonad class (#18075) (updating haddock submodule accordingly)

- - - - -
b9f7c08f by jneira at 2020-05-04T13:20:37-04:00
Remove unused hs-boot file

- - - - -
1d8f80cd by Sylvain Henry at 2020-05-05T03:22:46-04:00
Remove references to -package-key

* remove references to `-package-key` which has been removed in 2016
  (240ddd7c39536776e955e881d709bbb039b48513)

* remove support for `-this-package-key` which has been deprecated at the
  same time

- - - - -
7bc3a65b by Sylvain Henry at 2020-05-05T03:23:31-04:00
Remove SpecConstrAnnotation (#13681)

This has been deprecated since 2013. Use GHC.Types.SPEC instead.

Make GHC.Exts "not-home" for haddock

Metric Decrease:
   haddock.base

- - - - -
3c862f63 by DenisFrezzato at 2020-05-05T03:24:15-04:00
Fix Haskell98 short description in documentation

- - - - -
2420c555 by Ryan Scott at 2020-05-05T03:24:53-04:00
Add regression tests for #16244, #16245, #16758

Commit e3c374cc5bd7eb49649b9f507f9f7740697e3f70 ended up
fixing quite a few bugs:

* This commit fixes #16244 completely. A regression test has been
  added.
* This commit fixes one program from #16245. (The program in
  https://gitlab.haskell.org/ghc/ghc/issues/16245#note_211369 still
  panics, and the program in
  https://gitlab.haskell.org/ghc/ghc/issues/16245#note_211400 still
  loops infinitely.) A regression test has been added for this
  program.
* This commit fixes #16758. Accordingly, this patch removes the
  `expect_broken` label from the `T16758` test case, moves it from
  `should_compile` to `should_fail` (as it should produce an error
  message), and checks in the expected stderr.

- - - - -
40c71c2c by Sylvain Henry at 2020-05-05T03:25:31-04:00
Fix colorized error messages (#18128)

In b3df9e780fb2f5658412c644849cd0f1e6f50331 I broke colorized messages
by using "dump" style instead of "user" style. This commits fixes it.

- - - - -
7ab6ab09 by Richard Eisenberg at 2020-05-06T04:39:32-04:00
Refactor hole constraints.

Previously, holes (both expression holes / out of scope variables and
partial-type-signature wildcards) were emitted as *constraints* via
the CHoleCan constructor. While this worked fine for error reporting,
there was a fair amount of faff in keeping these constraints in line.
In particular, and unlike other constraints, we could never change
a CHoleCan to become CNonCanonical. In addition:
 * the "predicate" of a CHoleCan constraint was really the type
   of the hole, which is not a predicate at all
 * type-level holes (partial type signature wildcards) carried
   evidence, which was never used
 * tcNormalise (used in the pattern-match checker) had to create
   a hole constraint just to extract it again; it was quite messy

The new approach is to record holes directly in WantedConstraints.
It flows much more nicely now.

Along the way, I did some cleaning up of commentary in
GHC.Tc.Errors.Hole, which I had a hard time understanding.

This was instigated by a future patch that will refactor
the way predicates are handled. The fact that CHoleCan's
"predicate" wasn't really a predicate is incompatible with
that future patch.

No test case, because this is meant to be purely internal.

It turns out that this change improves the performance of
the pattern-match checker, likely because fewer constraints
are sloshing about in tcNormalise. I have not investigated
deeply, but an improvement is not a surprise here:

-------------------------
Metric Decrease:
    PmSeriesG
-------------------------

- - - - -
420b957d by Ben Gamari at 2020-05-06T04:40:08-04:00
rts: Zero block flags with -DZ

Block flags are very useful for determining the state of a block.
However, some block allocator users don't touch them, leading to
misleading values. Ensure that we zero then when zero-on-gc is set. This
is safe and makes the flags more useful during debugging.

- - - - -
740b3b8d by Ben Gamari at 2020-05-06T04:40:08-04:00
nonmoving: Fix incorrect failed_to_evac value during deadlock gc

Previously we would incorrectly set the failed_to_evac flag if we
evacuated a value due to a deadlock GC. This would cause us to mark more
things as dirty than strictly necessary. It also turned up a nasty but
which I will fix next.

- - - - -
b2d72c75 by Ben Gamari at 2020-05-06T04:40:08-04:00
nonmoving: Fix handling of dirty objects

Previously we (incorrectly) relied on failed_to_evac to be "precise".
That is, we expected it to only be true if *all* of an object's fields
lived outside of the non-moving heap. However, does not match the
behavior of failed_to_evac, which is true if *any* of the object's
fields weren't promoted (meaning that some others *may* live in the
non-moving heap).

This is problematic as we skip the non-moving write barrier for dirty
objects (which we can only safely do if *all* fields point outside of
the non-moving heap).

Clearly this arises due to a fundamental difference in the behavior
expected of failed_to_evac in the moving and non-moving collector.
e.g., in the moving collector it is always safe to conservatively say
failed_to_evac=true whereas in the non-moving collector the safe value
is false.

This issue went unnoticed as I never wrote down the dirtiness
invariant enforced by the non-moving collector. We now define this
invariant as

    An object being marked as dirty implies that all of its fields are
    on the mark queue (or, equivalently, update remembered set).

To maintain this invariant we teach nonmovingScavengeOne to push the
fields of objects which we fail to evacuate to the update remembered
set. This is a simple and reasonably cheap solution and avoids the
complexity and fragility that other, more strict alternative invariants
would require.

All of this is described in a new Note, Note [Dirty flags in the
non-moving collector] in NonMoving.c.

- - - - -
9f3e6884 by Zubin Duggal at 2020-05-06T04:41:08-04:00
Allow atomic update of NameCache in readHieFile

The situation arises in ghcide where multiple different threads may need to
update the name cache, therefore with the older interface it could happen
that you start reading a hie file with name cache A and produce name cache
A + B, but another thread in the meantime updated the namecache to A +
C. Therefore if you write the new namecache you will lose the A' updates
from the second thread.

Updates haddock submodule

- - - - -
edec6a6c by Ryan Scott at 2020-05-06T04:41:57-04:00
Make isTauTy detect higher-rank contexts

Previously, `isTauTy` would only detect higher-rank `forall`s, not
higher-rank contexts, which led to some minor bugs observed
in #18127. Easily fixed by adding a case for
`(FunTy InvisArg _ _)`.

Fixes #18127.

- - - - -
a95e7fe0 by Ömer Sinan Ağacan at 2020-05-06T04:42:39-04:00
ELF linker: increment curSymbol after filling in fields of current entry

The bug was introduced in a8b7cef4d45 which added a field to the
`symbols` array elements and then updated this code incorrectly:

    - oc->symbols[curSymbol++] = nm;
    + oc->symbols[curSymbol++].name = nm;
    + oc->symbols[curSymbol].addr = symbol->addr;

- - - - -
cab1871a by Sylvain Henry at 2020-05-06T04:43:21-04:00
Move LeadingUnderscore into Platform (#17957)

Avoid direct use of DynFlags to know if symbols must be prefixed by an
underscore.

- - - - -
94e7c563 by Sylvain Henry at 2020-05-06T04:43:21-04:00
Don't use DynFlags in showLinkerState (#17957)

- - - - -
9afd9251 by Ryan Scott at 2020-05-06T04:43:58-04:00
Refactoring: Use bindSigTyVarsFV in rnMethodBinds

`rnMethodBinds` was explicitly using `xoptM` to determine if
`ScopedTypeVariables` is enabled before bringing type variables
bound by the class/instance header into scope. However, this `xoptM`
logic is already performed by the `bindSigTyVarsFV` function. This
patch uses `bindSigTyVarsFV` in `rnMethodBinds` to reduce the number
of places where we need to consult if `ScopedTypeVariables` is on.

This is purely refactoring, and there should be no user-visible
change in behavior.

- - - - -
6f6d72b2 by Brian Foley at 2020-05-08T15:29:25-04:00
Remove further dead code found by a simple Python script.

Avoid removing some functions that are part of an API even
though they're not used in-tree at the moment.

- - - - -
78bf8bf9 by Julien Debon at 2020-05-08T15:29:28-04:00
Add doc examples for Bifoldable

See #17929

- - - - -
66f0a847 by Julien Debon at 2020-05-08T15:29:29-04:00
doc (Bitraversable): Add examples to Bitraversable

* Add examples to Data.Bitraversable
* Fix formatting for (,) in Bitraversable and Bifoldable
* Fix mistake on bimapAccumR documentation

See #17929

- - - - -
9749fe12 by Baldur Blöndal at 2020-05-08T15:29:32-04:00
Specify kind variables for inferred kinds in base.

- - - - -
4e9aef9e by John Ericson at 2020-05-08T15:29:36-04:00
HsSigWcTypeScoping: Pull in documentation from stray location

- - - - -
f4d5c6df by John Ericson at 2020-05-08T15:29:36-04:00
Rename local `real_fvs` to `implicit_vs`

It doesn't make sense to call the "free" variables we are about to
implicitly bind the real ones.

- - - - -
20570b4b by John Ericson at 2020-05-08T15:29:36-04:00
A few tiny style nits with renaming

 - Use case rather than guards that repeatedly scrutenize same thing.

 - No need for view pattern when `L` is fine.

 - Use type synnonym to convey the intent like elsewhere.

- - - - -
09ac8de5 by John Ericson at 2020-05-08T15:29:36-04:00
Add `forAllOrNothing` function with note

- - - - -
bb35c0e5 by Joseph C. Sible at 2020-05-08T15:29:40-04:00
Document lawlessness of Ap's Num instance
- - - - -
cdd229ff by Joseph C. Sible at 2020-05-08T15:29:40-04:00
Apply suggestion to libraries/base/Data/Monoid.hs
- - - - -
926d2aab by Joseph C. Sible at 2020-05-08T15:29:40-04:00
Apply more suggestions from Simon Jakobi
- - - - -
7a763cff by Adam Gundry at 2020-05-08T15:29:41-04:00
Reject all duplicate declarations involving DuplicateRecordFields (fixes #17965)

This fixes a bug that resulted in some programs being accepted that used the same
identifier as a field label and another declaration, depending on the order they
appeared in the source code.

- - - - -
88e3c815 by Simon Peyton Jones at 2020-05-08T15:29:41-04:00
Fix specialisation for DFuns

When specialising a DFun we must take care to saturate the
unfolding.  See Note [Specialising DFuns] in Specialise.

Fixes #18120

- - - - -
86c77b36 by Greg Steuck at 2020-05-08T15:29:45-04:00
Remove unused SEGMENT_PROT_RWX

It's been unused for a year and is problematic on any OS which
requires W^X for security.

- - - - -
9d97f4b5 by nineonine at 2020-05-08T15:30:03-04:00
Add test for #16167

- - - - -
aa318338 by Ryan Scott at 2020-05-08T15:30:04-04:00
Bump exceptions submodule so that dist-boot is .gitignore'd

`exceptions` is a stage-0 boot library as of commit
30272412fa437ab8e7a8035db94a278e10513413, which means that building
`exceptions` in a GHC tree will generate a `dist-boot` directory.
However, this directory was not specified in `exceptions`'
`.gitignore` file, which causes it to dirty up the current `git`
working directory.

Accordingly, this bumps the `exceptions` submodule to commit
ghc/packages/exceptions at 23c0b8a50d7592af37ca09beeec16b93080df98f,
which adds `dist-boot` to the `.gitignore` file.

- - - - -
ea86360f by Ömer Sinan Ağacan at 2020-05-08T15:30:30-04:00
Linker.c: initialize n_symbols of ObjectCode with other fields

- - - - -
951c1fb0 by Sylvain Henry at 2020-05-09T21:46:38-04:00
Fix unboxed-sums GC ptr-slot rubbish value (#17791)

This patch allows boot libraries to use unboxed sums without implicitly
depending on `base` package because of `absentSumFieldError`.

See updated Note [aBSENT_SUM_FIELD_ERROR_ID] in GHC.Core.Make

- - - - -
b352d63c by Ben Gamari at 2020-05-09T21:47:14-04:00
rts: Make non-existent linker search path merely a warning

As noted in #18105, previously this resulted in a rather intrusive error
message. This is in contrast to the general expectation that search
paths are merely places to look, not places that must exist.

Fixes #18105.

- - - - -
cf4f1e2f by Ben Gamari at 2020-05-13T02:02:33-04:00
rts/CNF: Fix fixup comparison function

Previously we would implicitly convert the difference between two words
to an int, resulting in an integer overflow on 64-bit machines.

Fixes #16992

- - - - -
a03da9bf by Ömer Sinan Ağacan at 2020-05-13T02:03:16-04:00
Pack some of IdInfo fields into a bit field

This reduces residency of compiler quite a bit on some programs.
Example stats when building T10370:

Before:

   2,871,242,832 bytes allocated in the heap
   4,693,328,008 bytes copied during GC
      33,941,448 bytes maximum residency (276 sample(s))
         375,976 bytes maximum slop
              83 MiB total memory in use (0 MB lost due to fragmentation)

After:

   2,858,897,344 bytes allocated in the heap
   4,629,255,440 bytes copied during GC
      32,616,624 bytes maximum residency (278 sample(s))
         314,400 bytes maximum slop
              80 MiB total memory in use (0 MB lost due to fragmentation)

So -3.9% residency, -1.3% bytes copied and -0.4% allocations.

Fixes #17497

Metric Decrease:
    T9233
    T9675

- - - - -
670c3e5c by Ben Gamari at 2020-05-13T02:03:54-04:00
get-win32-tarballs: Fix base URL

Revert a change previously made for testing purposes.

- - - - -
8ad8dc41 by Ben Gamari at 2020-05-13T02:03:54-04:00
get-win32-tarballs: Improve diagnostics output

- - - - -
8c0740b7 by Simon Jakobi at 2020-05-13T02:04:33-04:00
docs: Add examples for Data.Semigroup.Arg{Min,Max}

Context: #17153

- - - - -
cb22348f by Ben Gamari at 2020-05-13T02:05:11-04:00
Add few cleanups of the CAF logic

Give the NameSet of non-CAFfy names a proper newtype to distinguish it
from all of the other NameSets floating about.

- - - - -
90e38b81 by Emeka Nkurumeh at 2020-05-13T02:05:51-04:00
fix printf warning when using with ghc with clang on mingw
- - - - -
86d8ac22 by Sebastian Graf at 2020-05-13T02:06:29-04:00
CprAnal: Don't attach CPR sigs to expandable bindings (#18154)

Instead, look through expandable unfoldings in `cprTransform`.
See the new Note [CPR for expandable unfoldings]:

```
Long static data structures (whether top-level or not) like

  xs = x1 : xs1
  xs1 = x2 : xs2
  xs2 = x3 : xs3

should not get CPR signatures, because they

  * Never get WW'd, so their CPR signature should be irrelevant after analysis
    (in fact the signature might even be harmful for that reason)
  * Would need to be inlined/expanded to see their constructed product
  * Recording CPR on them blows up interface file sizes and is redundant with
    their unfolding. In case of Nested CPR, this blow-up can be quadratic!

But we can't just stop giving DataCon application bindings the CPR property,
for example

  fac 0 = 1
  fac n = n * fac (n-1)

fac certainly has the CPR property and should be WW'd! But FloatOut will
transform the first clause to

  lvl = 1
  fac 0 = lvl

If lvl doesn't have the CPR property, fac won't either. But lvl doesn't have a
CPR signature to extrapolate into a CPR transformer ('cprTransform'). So
instead we keep on cprAnal'ing through *expandable* unfoldings for these arity
0 bindings via 'cprExpandUnfolding_maybe'.

In practice, GHC generates a lot of (nested) TyCon and KindRep bindings, one
for each data declaration. It's wasteful to attach CPR signatures to each of
them (and intractable in case of Nested CPR).
```

Fixes #18154.

- - - - -
e34bf656 by Ben Gamari at 2020-05-13T02:07:08-04:00
users-guide: Add discussion of shared object naming

Fixes #18074.

- - - - -
5d0f2445 by Ben Gamari at 2020-05-13T02:07:47-04:00
testsuite: Print sign of performance changes

Executes the minor formatting change in the tabulated performance
changes suggested in #18135.

- - - - -
9e4b981f by Ben Gamari at 2020-05-13T02:08:24-04:00
testsuite: Add testcase for #18129

- - - - -
266310c3 by Ivan-Yudin at 2020-05-13T02:09:03-04:00
doc: Reformulate the opening paragraph of Ch. 4 in User's guide

Removes mentioning of Hugs
(it is not helpful for new users anymore).

Changes the wording for the rest of the paragraph.

Fixes #18132.

- - - - -
55e35c0b by Baldur Blöndal at 2020-05-13T20:02:48-04:00
Predicate, Equivalence derive via `.. -> a -> All'

- - - - -
d7e0b57f by Alp Mestanogullari at 2020-05-13T20:03:30-04:00
hadrian: add a --freeze2 option to freeze stage 1 and 2

- - - - -
d880d6b2 by Artem Pelenitsyn at 2020-05-13T20:04:11-04:00
Don't reload environment files on every setSessionDynFlags

Makes `interpretPackageEnv` (which loads envirinment files) a part of
`parseDynamicFlags` (parsing command-line arguments, which is typically
done once) instead of `setSessionDynFlags` (which is typically called
several times). Making several (transitive) calls to `interpretPackageEnv`,
as before, caused #18125 #16318, which should be fixed now.

- - - - -
102cfd67 by Ryan Scott at 2020-05-13T20:04:46-04:00
Factor out HsPatSigType for pat sigs/RULE term sigs (#16762)

This implements chunks (2) and (3) of
https://gitlab.haskell.org/ghc/ghc/issues/16762#note_270170. Namely,
it introduces a dedicated `HsPatSigType` AST type, which represents
the types that can appear in pattern signatures and term-level `RULE`
binders. Previously, these were represented with `LHsSigWcType`.
Although `LHsSigWcType` is isomorphic to `HsPatSigType`, the intended
semantics of the two types are slightly different, as evidenced by
the fact that they have different code paths in the renamer and
typechecker.

See also the new `Note [Pattern signature binders and scoping]` in
`GHC.Hs.Types`.

- - - - -
b17574f7 by Hécate at 2020-05-13T20:05:28-04:00
fix(documentation): Fix the RST links to GHC.Prim

- - - - -
df021fb1 by Baldur Blöndal at 2020-05-13T20:06:06-04:00
Document (->) using inferred quantification for its runtime representations.

Fixes #18142.

- - - - -
1a93ea57 by Takenobu Tani at 2020-05-13T20:06:54-04:00
Tweak man page for ghc command

This commit updates the ghc command's man page as followings:

* Enable `man_show_urls` to show URL addresses in the `DESCRIPTION`
section of ghc.rst, because sphinx currently removes hyperlinks
for man pages.

* Add a `SEE ALSO` section to point to the GHC homepage

- - - - -
a951e1ba by Takenobu Tani at 2020-05-13T20:07:37-04:00
GHCi: Add link to the user's guide in help message

This commit adds a link to the user's guide in ghci's
`:help` message.

Newcomers could easily reach to details of ghci.

- - - - -
404581ea by Jeff Happily at 2020-05-13T20:08:15-04:00
Handle single unused import

- - - - -
1c999e5d by Ben Gamari at 2020-05-13T20:09:07-04:00
Ensure that printMinimalImports closes handle

Fixes #18166.

- - - - -
c9f5a8f4 by Ben Gamari at 2020-05-13T20:09:51-04:00
hadrian: Tell testsuite driver about LLVM availability

This reflects the logic present in the Make build system into Hadrian.

Fixes #18167.

- - - - -
c05c0659 by Simon Jakobi at 2020-05-14T03:31:21-04:00
Improve some folds over Uniq[D]FM

* Replace some non-deterministic lazy folds with
  strict folds.
* Replace some O(n log n) folds in deterministic order
  with O(n) non-deterministic folds.
* Replace some folds with set-operations on the underlying
  IntMaps.

This reduces max residency when compiling
`nofib/spectral/simple/Main.hs` with -O0 by about 1%.

Maximum residency when compiling Cabal also seems reduced on the
order of 3-9%.

- - - - -
477f13bb by Simon Jakobi at 2020-05-14T03:31:58-04:00
Use Data.IntMap.disjoint

Data.IntMap gained a dedicated `disjoint` function in containers-0.6.2.1.

This patch applies this function where appropriate in hopes of modest
compiler performance improvements.

Closes #16806.

- - - - -
e9c0110c by Ben Gamari at 2020-05-14T12:25:53-04:00
IdInfo: Add reference to bitfield-packing ticket

- - - - -
9bd20e83 by Sebastian Graf at 2020-05-15T10:42:09-04:00
DmdAnal: Improve handling of precise exceptions

This patch does two things: Fix possible unsoundness in what was called
the "IO hack" and implement part 2.1 of the "fixing precise exceptions"
plan in
https://gitlab.haskell.org/ghc/ghc/wikis/fixing-precise-exceptions,
which, in combination with !2956, supersedes !3014 and !2525.

**IO hack**

The "IO hack" (which is a fallback to preserve precise exceptions
semantics and thus soundness, rather than some smart thing that
increases precision) is called `exprMayThrowPreciseException` now.
I came up with two testcases exemplifying possible unsoundness (if
twisted enough) in the old approach:

- `T13380d`: Demonstrating unsoundness of the "IO hack" when resorting
             to manual state token threading and direct use of primops.
             More details below.
- `T13380e`: Demonstrating unsoundness of the "IO hack" when we have
             Nested CPR. Not currently relevant, as we don't have Nested
             CPR yet.
- `T13380f`: Demonstrating unsoundness of the "IO hack" for safe FFI
             calls.

Basically, the IO hack assumed that precise exceptions can only be
thrown from a case scrutinee of type `(# State# RealWorld, _ #)`. I
couldn't come up with a program using the `IO` abstraction that violates
this assumption. But it's easy to do so via manual state token threading
and direct use of primops, see `T13380d`. Also similar code might be
generated by Nested CPR in the (hopefully not too) distant future, see
`T13380e`. Hence, we now have a more careful test in `forcesRealWorld`
that passes `T13380{d,e}` (and will hopefully be robust to Nested CPR).

**Precise exceptions**

In #13380 and #17676 we saw that we didn't preserve precise exception
semantics in demand analysis. We fixed that with minimal changes in
!2956, but that was terribly unprincipled.

That unprincipledness resulted in a loss of precision, which is tracked
by these new test cases:

- `T13380b`: Regression in dead code elimination, because !2956 was too
             syntactic about `raiseIO#`
- `T13380c`: No need to apply the "IO hack" when the IO action may not
             throw a precise exception (and the existing IO hack doesn't
             detect that)

Fixing both issues in !3014 turned out to be too complicated and had
the potential to regress in the future. Hence we decided to only fix
`T13380b` and augment the `Divergence` lattice with a new middle-layer
element, `ExnOrDiv`, which means either `Diverges` (, throws an
imprecise exception) or throws a *precise* exception.

See the wiki page on Step 2.1 for more implementational details:
https://gitlab.haskell.org/ghc/ghc/wikis/fixing-precise-exceptions#dead-code-elimination-for-raiseio-with-isdeadenddiv-introducing-exnordiv-step-21

- - - - -
568d7279 by Ben Gamari at 2020-05-15T10:42:46-04:00
GHC.Cmm.Opt: Handle MO_XX_Conv

This MachOp was introduced by 2c959a1894311e59cd2fd469c1967491c1e488f3
but a wildcard match in cmmMachOpFoldM hid the fact that it wasn't
handled. Ideally we would eliminate the match but this appears to be a
larger task.

Fixes #18141.

- - - - -
5bcf8606 by Ryan Scott at 2020-05-17T08:46:38-04:00
Remove duplicate Note [When to print foralls] in GHC.Core.TyCo.Ppr

There are two different Notes named `[When to print foralls]`. The
most up-to-date one is in `GHC.Iface.Type`, but there is a second
one in `GHC.Core.TyCo.Ppr`. The latter is less up-to-date, as it was
written before GHC switched over to using ifaces to pretty-print
types. I decided to just remove the latter and replace it with a
reference to the former.

[ci skip]

- - - - -
55f0e783 by Fumiaki Kinoshita at 2020-05-21T12:10:44-04:00
base: Add Generic instances to various datatypes under GHC.*

* GHC.Fingerprint.Types: Fingerprint
* GHC.RTS.Flags: GiveGCStats, GCFlags, ConcFlags, DebugFlags, CCFlags, DoHeapProfile, ProfFlags, DoTrace, TraceFlags, TickyFlags, ParFlags and RTSFlags
* GHC.Stats: RTSStats and GCStats
* GHC.ByteOrder: ByteOrder
* GHC.Unicode: GeneralCategory
* GHC.Stack.Types: SrcLoc

Metric Increase:
    haddock.base

- - - - -
a9311cd5 by Gert-Jan Bottu at 2020-05-21T12:11:31-04:00
Explicit Specificity

Implementation for Ticket #16393.
Explicit specificity allows users to manually create inferred type variables,
by marking them with braces.
This way, the user determines which variables can be instantiated through
visible type application.

The additional syntax is included in the parser, allowing users to write
braces in type variable binders (type signatures, data constructors etc).
This information is passed along through the renamer and verified in the
type checker.
The AST for type variable binders, data constructors, pattern synonyms,
partial signatures and Template Haskell has been updated to include the
specificity of type variables.

Minor notes:
- Bumps haddock submodule
- Disables pattern match checking in GHC.Iface.Type with GHC 8.8

- - - - -
24e61aad by Ben Price at 2020-05-21T12:12:17-04:00
Lint should say when it is checking a rule

It is rather confusing that when lint finds an error in a rule attached
to a binder, it reports the error as in the RHS, not the rule:
  ...
  In the RHS of foo

We add a clarifying line:
  ...
  In the RHS of foo
  In a rule attached to foo

The implication that the rule lives inside the RHS is a bit odd, but
this niggle is already present for unfoldings, whose pattern we are
following.

- - - - -
78c6523c by Ben Gamari at 2020-05-21T12:13:01-04:00
nonmoving: Optimise the write barrier

- - - - -
13f6c9d0 by Andreas Klebinger at 2020-05-21T12:13:45-04:00
Refactor linear reg alloc to remember past assignments.

When assigning registers we now first try registers we
assigned to in the past, instead of picking the "first"
one.

This is in extremely helpful when dealing with loops for
which variables are dead for part of the loop.

This is important for patterns like this:

        foo = arg1
    loop:
        use(foo)
        ...
        foo = getVal()
        goto loop;

There we:
* assign foo to the register of arg1.
* use foo, it's dead after this use as it's overwritten after.
* do other things.
* look for a register to put foo in.

If we pick an arbitrary one it might differ from the register the
start of the loop expect's foo to be in.
To fix this we simply look for past register assignments for
the given variable. If we find one and the register is free we
use that register.

This reduces the need for fixup blocks which match the register
assignment between blocks. In the example above between the end
and the head of the loop.

This patch also moves branch weight estimation ahead of register
allocation and adds a flag to control it (cmm-static-pred).
* It means the linear allocator is more likely to assign the hotter
  code paths first.
* If it assign these first we are:
  + Less likely to spill on the hot path.
  + Less likely to introduce fixup blocks on the hot path.

These two measure combined are surprisingly effective. Based on nofib
we get in the mean:

* -0.9% instructions executed
* -0.1% reads/writes
* -0.2% code size.
* -0.1% compiler allocations.
* -0.9% compile time.
* -0.8% runtime.

Most of the benefits are simply a result of removing redundant moves
and spills.

Reduced compiler allocations likely are the result of less code being
generated. (The added lookup is mostly non-allocating).

- - - - -
edc2cc58 by Andreas Klebinger at 2020-05-21T12:14:25-04:00
NCG: Codelayout: Distinguish conditional and other branches.

In #18053 we ended up with a suboptimal code layout because
the code layout algorithm didn't distinguish between conditional
and unconditional control flow.

We can completely eliminate unconditional control flow instructions
by placing blocks next to each other, not so much for conditionals.

In terms of implementation we simply give conditional branches less
weight before computing the layout.

Fixes #18053

- - - - -
b7a6b2f4 by Gleb Popov at 2020-05-21T12:15:26-04:00
gitlab-ci: Set locale to C.UTF-8.

- - - - -
a8c27cf6 by Stefan Holdermans at 2020-05-21T12:16:08-04:00
Allow spaces in GHCi :script file names

This patch updates the user interface of GHCi so that file names passed
to the ':script' command may contain spaces escaped with a backslash.

For example:

  :script foo\ bar.script

The implementation uses a modified version of 'words' that does not
break on escaped spaces.

Fixes #18027.

- - - - -
82663959 by Stefan Holdermans at 2020-05-21T12:16:08-04:00
Add extra tests for GHCi :script syntax checks

The syntax for GHCi's ":script" command allows for only a single file
name to be passed as an argument. This patch adds a test for the cases
in which a file name is missing or multiple file names are passed.

Related to #T18027.

- - - - -
a0b79e1b by Stefan Holdermans at 2020-05-21T12:16:08-04:00
Allow GHCi :script file names in double quotes

This patch updates the user interface of GHCi so that file names passed
to the ':script' command can be wrapped in double quotes.

For example:

  :script "foo bar.script"

The implementation uses a modified version of 'words' that treats
character sequences enclosed in double quotes as single words.

Fixes #18027.

- - - - -
cf566330 by Stefan Holdermans at 2020-05-21T12:16:08-04:00
Update documentation for GHCi :script

This patch adds the fixes that allow for file names containing spaces to
be passed to GHCi's ':script' command to the release notes for 8.12 and
expands the user-guide documentation for ':script' by mentioning how
such file names can be passed.

Related to #18027.

- - - - -
0004ccb8 by Tuan Le at 2020-05-21T12:16:46-04:00
llvmGen: Consider Relocatable read-only data as not constantReferences: #18137

- - - - -
964d3ea2 by John Ericson at 2020-05-21T12:17:30-04:00
Use `Checker` for `tc_pat`

- - - - -
b797aa42 by John Ericson at 2020-05-21T12:17:30-04:00
Use `Checker` for `tc_lpat` and `tc_lpats`

- - - - -
5108e84a by John Ericson at 2020-05-21T12:17:30-04:00
More judiciously panic in `ts_pat`

- - - - -
510e0451 by John Ericson at 2020-05-21T12:17:30-04:00
Put `PatEnv` first in `GHC.Tc.Gen.Pat.Checker`

- - - - -
cb4231db by John Ericson at 2020-05-21T12:17:30-04:00
Tiny cleaup eta-reduce away a function argument

In GHC, not in the code being compiled!

- - - - -
6890c38d by John Ericson at 2020-05-21T12:17:30-04:00
Use braces with do in `SplicePat` case for consistency

- - - - -
3451584f by buggymcbugfix at 2020-05-21T12:18:06-04:00
Fix spelling mistakes and typos

- - - - -
b552e531 by buggymcbugfix at 2020-05-21T12:18:06-04:00
Add INLINABLE pragmas to Enum list producers

The INLINABLE pragmas ensure that we export stable (unoptimised) unfoldings in
the interface file so we can do list fusion at usage sites.

Related tickets: #15185, #8763, #18178.

- - - - -
e7480063 by buggymcbugfix at 2020-05-21T12:18:06-04:00
Piggyback on Enum Word methods for Word64

If we are on a 64 bit platform, we can use the efficient Enum Word
methods for the Enum Word64 instance.

- - - - -
892b0c41 by buggymcbugfix at 2020-05-21T12:18:06-04:00
Document INLINE(ABLE) pragmas that enable fusion

- - - - -
2b363ebb by Richard Eisenberg at 2020-05-21T12:18:45-04:00
MR template should ask for key part
- - - - -
a95bbd0b by Sebastian Graf at 2020-05-21T12:19:37-04:00
Make `Int`'s `mod` and `rem` strict in their first arguments

They used to be strict until 4d2ac2d (9 years ago).

It's obviously better to be strict for performance reasons.
It also blocks #18067.

NoFib results:

```
--------------------------------------------------------------------------------
        Program         Allocs    Instrs
--------------------------------------------------------------------------------
        integer          -1.1%     +0.4%
   wheel-sieve2         +21.2%    +20.7%
--------------------------------------------------------------------------------
            Min          -1.1%     -0.0%
            Max         +21.2%    +20.7%
 Geometric Mean          +0.2%     +0.2%
```

The regression in `wheel-sieve2` is due to reboxing that likely will go
away with the resolution of #18067. See !3282 for details.

Fixes #18187.

- - - - -
d3d055b8 by Galen Huntington at 2020-05-21T12:20:18-04:00
Clarify pitfalls of NegativeLiterals; see #18022.
- - - - -
1b508a9e by Alexey Kuleshevich at 2020-05-21T12:21:02-04:00
Fix wording in primops documentation to reflect the correct reasoning:

* Besides resizing functions, shrinking ones also mutate the
  size of a mutable array and because of those two `sizeofMutabeByteArray`
  and `sizeofSmallMutableArray` are now deprecated
* Change reference in documentation to the newer functions `getSizeof*`
  instead of `sizeof*` for shrinking functions
* Fix incorrect mention of "byte" instead of "small"

- - - - -
4ca0c8a1 by Andreas Klebinger at 2020-05-21T12:21:53-04:00
Don't variable-length encode magic iface constant.

We changed to use variable length encodings for many types by default,
including Word32. This makes sense for numbers but not when Word32 is
meant to represent four bytes.

I added a FixedLengthEncoding newtype to Binary who's instances
interpret their argument as a collection of bytes instead of a number.

We then use this when writing/reading magic numbers to the iface file.

I also took the libery to remove the dummy iface field.

This fixes #18180.

- - - - -
a1275081 by Krzysztof Gogolewski at 2020-05-21T12:22:35-04:00
Add a regression test for #11506

The testcase works now.
See explanation in https://gitlab.haskell.org/ghc/ghc/issues/11506#note_273202

- - - - -
8a816e5f by Krzysztof Gogolewski at 2020-05-21T12:23:55-04:00
Sort deterministically metric output

Previously, we sorted according to the test name and way,
but the metrics (max_bytes_used/peak_megabytes_allocated etc.)
were appearing in nondeterministic order.

- - - - -
566cc73f by Sylvain Henry at 2020-05-21T12:24:45-04:00
Move isDynLinkName into GHC.Types.Name

It doesn't belong into GHC.Unit.State

- - - - -
d830bbc9 by Adam Sandberg Ericsson at 2020-05-23T13:36:20-04:00
docs: fix formatting and add some links

[skip ci]

- - - - -
49301ad6 by Andrew Martin at 2020-05-23T13:37:01-04:00
Implement cstringLength# and FinalPtr

This function and its accompanying rule resolve issue #5218.
A future PR to the bytestring library will make the internal
Data.ByteString.Internal.unsafePackAddress compute string length
with cstringLength#. This will improve the status quo because it is
eligible for constant folding.

Additionally, introduce a new data constructor to ForeignPtrContents
named FinalPtr. This additional data constructor, when used in the
IsString instance for ByteString, leads to more Core-to-Core
optimization opportunities, fewer runtime allocations, and smaller
binaries.

Also, this commit re-exports all the functions from GHC.CString
(including cstringLength#) in GHC.Exts. It also adds a new test
driver. This test driver is used to perform substring matches on Core
that is dumped after all the simplifier passes. In this commit, it is
used to check that constant folding of cstringLength# works.

- - - - -
dcd6bdcc by Ben Gamari at 2020-05-23T13:37:48-04:00
simplCore: Ignore ticks in rule templates

This fixes #17619, where a tick snuck in to the template of a rule,
resulting in a panic during rule matching. The tick in question was
introduced via post-inlining, as discussed in `Note [Simplifying
rules]`. The solution we decided upon was to simply ignore ticks in the
rule template, as discussed in `Note [Tick annotations in RULE
matching]`.

Fixes #18162.
Fixes #17619.

- - - - -
82cb8913 by John Ericson at 2020-05-23T13:38:32-04:00
Fix #18145 and also avoid needless work with implicit vars

 - `forAllOrNothing` now is monadic, so we can trace whether we bind
   an explicit `forall` or not.

 - #18145 arose because the free vars calculation was needlessly
   complex. It is now greatly simplified.

 - Replaced some other implicit var code with `filterFreeVarsToBind`.

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

- - - - -
a60dc835 by Ben Gamari at 2020-05-23T13:39:12-04:00
Bump process submodule

Fixes #17926.

- - - - -
856adf54 by Ben Gamari at 2020-05-23T13:40:21-04:00
users-guide: Clarify meaning of -haddock flag

Fixes #18206.

- - - - -
7ae57afd by Ben Gamari at 2020-05-23T13:41:03-04:00
git: Add ignored commits file

This can be used to tell git to ignore bulk renaming commits like the
recently-finished module hierarchy refactoring. Configured with,

    git config blame.ignoreRevsFile .git-ignore-revs

- - - - -
63d30e60 by jneira at 2020-05-24T01:54:42-04:00
Add hie-bios script for windows systems
It is a direct translation of the sh script

- - - - -
59182b88 by jneira at 2020-05-24T01:54:42-04:00
Honour previous values for CABAL and CABFLAGS
The immediate goal is let the hie-bios.bat script
set CABFLAGS with `-v0` and remove all cabal output
except the compiler arguments

- - - - -
932dc54e by jneira at 2020-05-24T01:54:42-04:00
Add specific configuration for windows in hie.yaml

- - - - -
e0eda070 by jneira at 2020-05-24T01:54:42-04:00
Remove not needed hie-bios output

- - - - -
a0ea59d6 by Sylvain Henry at 2020-05-24T01:55:24-04:00
Move Config module into GHC.Settings

- - - - -
37430251 by Sylvain Henry at 2020-05-24T01:55:24-04:00
Rename GHC.Core.Arity into GHC.Core.Opt.Arity

- - - - -
a426abb9 by Sylvain Henry at 2020-05-24T01:55:24-04:00
Rename GHC.Hs.Types into GHC.Hs.Type

See discussion in https://gitlab.haskell.org/ghc/ghc/issues/13009#note_268610

- - - - -
1c91a7a0 by Sylvain Henry at 2020-05-24T01:55:24-04:00
Bump haddock submodule

- - - - -
66bd24d1 by Ryan Scott at 2020-05-24T01:56:03-04:00
Add orderingTyCon to wiredInTyCons (#18185)

`Ordering` needs to be wired in for use in the built-in `CmpNat` and
`CmpSymbol` type families, but somehow it was never added to the list
of `wiredInTyCons`, leading to the various oddities observed
in #18185. Easily fixed by moving `orderingTyCon` from
`basicKnownKeyNames` to `wiredInTyCons`.

Fixes #18185.

- - - - -
01c43634 by Matthew Pickering at 2020-05-24T01:56:42-04:00
Remove unused hs-boot file

- - - - -
7a07aa71 by Sylvain Henry at 2020-05-24T15:22:17-04:00
Hadrian: fix cross-compiler build (#16051)

- - - - -
15ccca16 by Sylvain Henry at 2020-05-24T15:22:17-04:00
Hadrian: fix distDir per stage

- - - - -
b420fb24 by Sylvain Henry at 2020-05-24T15:22:17-04:00
Hadrian: fix hp2ps error during cross-compilation

Fixed by @alp (see https://gitlab.haskell.org/ghc/ghc/issues/16051#note_274265)

- - - - -
cd339ef0 by Joshua Price at 2020-05-24T15:22:56-04:00
Make Unicode brackets opening/closing tokens (#18225)

The tokens `[|`, `|]`, `(|`, and `|)` are opening/closing tokens as
described in GHC Proposal #229. This commit makes the unicode
variants (`⟦`, `⟧`, `⦇`, and `⦈`) act the same as their ASCII
counterparts.

- - - - -
013d7120 by Ben Gamari at 2020-05-25T09:48:17-04:00
Revert "Specify kind variables for inferred kinds in base."

As noted in !3132, this has rather severe knock-on consequences in
user-code. We'll need to revisit this before merging something along
these lines.

This reverts commit 9749fe1223d182b1f8e7e4f7378df661c509f396.

- - - - -
4c4312ed by Ben Gamari at 2020-05-25T09:48:53-04:00
Coverage: Drop redundant ad-hoc boot module check

To determine whether the module is a boot module
Coverage.addTicksToBinds was checking for a `boot` suffix in the module
source filename. This is quite ad-hoc and shouldn't be necessary; the
callsite in `deSugar` already checks that the module isn't a boot
module.

- - - - -
1abf3c84 by Ben Gamari at 2020-05-25T09:48:53-04:00
Coverage: Make tickBoxCount strict

This could otherwise easily cause a leak of (+) thunks.

- - - - -
b2813750 by Ben Gamari at 2020-05-25T09:48:53-04:00
Coverage: Make ccIndices strict

This just seems like a good idea.

- - - - -
02e278eb by Ben Gamari at 2020-05-25T09:48:53-04:00
Coverage: Don't produce ModBreaks if not HscInterpreted

emptyModBreaks contains a bottom and consequently it's important that we
don't use it unless necessary.

- - - - -
b8c014ce by Ben Gamari at 2020-05-25T09:48:53-04:00
Coverage: Factor out addMixEntry

- - - - -
53814a64 by Zubin Duggal at 2020-05-26T03:03:24-04:00
Add info about typeclass evidence to .hie files

See `testsuite/tests/hiefile/should_run/HieQueries.hs` and
`testsuite/tests/hiefile/should_run/HieQueries.stdout` for an example of this

We add two new fields, `EvidenceVarBind` and `EvidenceVarUse` to the
`ContextInfo` associated with an Identifier. These are associated with the
appropriate identifiers for the evidence variables collected when we come across
`HsWrappers`, `TcEvBinds` and `IPBinds` while traversing the AST.

Instance dictionary and superclass selector dictionaries from `tcg_insts` and
classes defined in `tcg_tcs` are also recorded in the AST as originating from
their definition span

This allows us to save a complete picture of the evidence constructed by the
constraint solver, and will let us report this to the user, enabling features
like going to the instance definition from the invocation of a class method(or
any other method taking a constraint) and finding all usages of a particular
instance.

Additionally,

- Mark NodeInfo with an origin so we can differentiate between bindings
  origininating in the source vs those in ghc
- Along with typeclass evidence info, also include information on Implicit
  Parameters
- Add a few utility functions to HieUtils in order to query the new info

Updates haddock submodule

- - - - -
6604906c by Sebastian Graf at 2020-05-26T03:04:04-04:00
Make WorkWrap.Lib.isWorkerSmallEnough aware of the old arity

We should allow a wrapper with up to 82 parameters when the original
function had 82 parameters to begin with.

I verified that this made no difference on NoFib, but then again
it doesn't use huge records...

Fixes #18122.

- - - - -
cf772f19 by Sylvain Henry at 2020-05-26T03:04:45-04:00
Enhance Note [About units] for Backpack

- - - - -
ede24126 by Takenobu Tani at 2020-05-27T00:13:55-04:00
core-spec: Modify file paths according to new module hierarchy

This patch updates file paths according to new module hierarchy [1]:

  * GHC/Core.hs                <= coreSyn/CoreSyn.hs
  * GHC/Core/Coercion.hs       <= types/Coercion.hs
  * GHC/Core/Coercion/Axiom.hs <= types/CoAxiom.hs
  * GHC/Core/Coercion/Opt.hs   <= types/OptCoercion.hs
  * GHC/Core/DataCon.hs        <= basicTypes/DataCon.hs
  * GHC/Core/FamInstEnv.hs     <= types/FamInstEnv.hs
  * GHC/Core/Lint.hs           <= coreSyn/CoreLint.hs
  * GHC/Core/Subst.hs          <= coreSyn/CoreSubst.hs
  * GHC/Core/TyCo/Rep.hs       <= types/TyCoRep.hs
  * GHC/Core/TyCon.hs          <= types/TyCon.hs
  * GHC/Core/Type.hs           <= types/Type.hs
  * GHC/Core/Unify.hs          <= types/Unify.hs
  * GHC/Types/Literal.hs       <= basicTypes/Literal.hs
  * GHC/Types/Var.hs           <= basicTypes/Var.hs

[1]: https://gitlab.haskell.org/ghc/ghc/-/wikis/Make-GHC-codebase-more-modular

[skip ci]

- - - - -
04750304 by Ben Gamari at 2020-05-27T00:14:33-04:00
eventlog: Fix racy flushing

Previously no attempt was made to avoid multiple threads writing their
capability-local eventlog buffers to the eventlog writer simultaneously.
This could result in multiple eventlog streams being interleaved. Fix
this by documenting that the EventLogWriter's write() and flush()
functions may be called reentrantly and fix the default writer to
protect its FILE* by a mutex.

Fixes #18210.

- - - - -
d6203f24 by Joshua Price at 2020-05-27T00:15:17-04:00
Make `identifier` parse unparenthesized `->` (#18060)

- - - - -
28deee28 by Ben Gamari at 2020-05-28T16:23:21-04:00
GHC.Core.Unfold: Refactor traceInline

This reduces duplication as well as fixes a bug wherein -dinlining-check
would override -ddump-inlinings. Moreover, the new variant

- - - - -
1f393e1e by Ben Gamari at 2020-05-28T16:23:21-04:00
Avoid unnecessary allocations due to tracing utilities

While ticky-profiling the typechecker I noticed that hundreds of
millions of SDocs are being allocated just in case -ddump-*-trace is
enabled. This is awful.

We avoid this by ensuring that the dump flag check is inlined into the
call site, ensuring that the tracing document needn't be allocated
unless it's actually needed.

See Note [INLINE conditional tracing utilities] for details.

Fixes #18168.

Metric Decrease:
  T9961
  haddock.Cabal
  haddock.base
  haddock.compiler

- - - - -
5f621a78 by Vladislav Zavialov at 2020-05-28T16:23:58-04:00
Add Semigroup/Monoid for Q (#18123)

- - - - -
dc5f004c by Xavier Denis at 2020-05-28T16:24:37-04:00
Fix #18071

Run the core linter on candidate instances to ensure they are
well-kinded.

Better handle quantified constraints by using a CtWanted to avoid
having unsolved constraints thrown away at the end by the solver.

- - - - -
10e6982c by Sebastian Graf at 2020-05-28T16:25:14-04:00
FloatOut: Only eta-expand dead-end RHS if arity will increase (#18231)

Otherwise we risk turning trivial RHS into non-trivial RHS, introducing
unnecessary bindings in the next Simplifier run, resulting in more
churn.

Fixes #18231.

- - - - -
08dab5f7 by Sebastian Graf at 2020-05-28T16:25:14-04:00
DmdAnal: Recognise precise exceptions from case alternatives (#18086)

Consider

```hs
m :: IO ()
m = do
  putStrLn "foo"
  error "bar"
```

`m` (from #18086) always throws a (precise or imprecise) exception or
diverges. Yet demand analysis infers `<L,A>` as demand signature instead
of `<L,A>x` for it.

That's because the demand analyser sees `putStrLn` occuring in a case
scrutinee and decides that it has to `deferAfterPreciseException`,
because `putStrLn` throws a precise exception on some control flow
paths. This will mask the `botDiv` `Divergence`of the single case alt
containing `error` to `topDiv`. Since `putStrLn` has `topDiv` itself,
the final `Divergence` is `topDiv`.

This is easily fixed: `deferAfterPreciseException` works by `lub`ing
with the demand type of a virtual case branch denoting the precise
exceptional control flow. We used `nopDmdType` before, but we can be
more precise and use `exnDmdType`, which is `nopDmdType` with `exnDiv`.

Now the `Divergence` from the case alt will degrade `botDiv` to `exnDiv`
instead of `topDiv`, which combines with the result from the scrutinee
to `exnDiv`, and all is well.

Fixes #18086.

- - - - -
aef95f11 by Ben Gamari at 2020-05-28T16:25:53-04:00
Ticky-ticky: Record DataCon name in ticker name

This makes it significantly easier to spot the nature of
allocations regressions and comes at a reasonably low cost.

- - - - -
8f021b8c by Ben Gamari at 2020-05-28T16:26:34-04:00
hadrian: Don't track GHC's verbosity argument

Teach hadrian to ignore GHC's -v argument in its recompilation check,
thus fixing #18131.

- - - - -
13d9380b by Ben Gamari at 2020-05-28T16:27:20-04:00
Rip out CmmStackInfo(updfr_space)

As noted in #18232, this field is currently completely unused and
moreover doesn't have a clear meaning.

- - - - -
f10d11fa by Andreas Klebinger at 2020-05-29T01:38:42-04:00
Fix "build/elem" RULE.

An redundant constraint prevented the rule from matching.

Fixing this allows a call to elem on a known list to be translated
into a series of equality checks, and eventually a simple case
expression.

Surprisingly this seems to regress elem for strings. To avoid
this we now also allow foldrCString to inline and add an UTF8
variant. This results in elem being compiled to a tight
non-allocating loop over the primitive string literal which
performs a linear search.

In the process this commit adds UTF8 variants for some of the
functions in GHC.CString. This is required to make this work for
both ASCII and UTF8 strings.

There are also small tweaks to the CString related rules.
We now allow ourselfes the luxury to compare the folding function
via eqExpr, which helps to ensure the rule fires before we inline
foldrCString*. Together with a few changes to allow matching on both
the UTF8 and ASCII variants of the CString functions.

- - - - -
bbeb2389 by Ben Gamari at 2020-05-29T01:39:19-04:00
CoreToStg: Add Outputable ArgInfo instance

- - - - -
0e3361ca by Simon Peyton Jones at 2020-05-29T01:39:19-04:00
Make Lint check return type of a join point

Consider
   join x = rhs in body
It's important that the type of 'rhs' is the same as the type of
'body', but Lint wasn't checking that invariant.

Now it does!  This was exposed by investigation into !3113.

- - - - -
c49f7df0 by Simon Peyton Jones at 2020-05-29T01:39:19-04:00
Do not float join points in exprIsConApp_maybe

We hvae been making exprIsConApp_maybe cleverer in recent times:

    commit b78cc64e923716ac0512c299f42d4d0012306c05
    Date:   Thu Nov 15 17:14:31 2018 +0100
    Make constructor wrappers inline only during the final phase

    commit 7833cf407d1f608bebb1d38bb99d3035d8d735e6
    Date:   Thu Jan 24 17:58:50 2019 +0100
    Look through newtype wrappers (Trac #16254)

    commit c25b135ff5b9c69a90df0ccf51b04952c2dc6ee1
    Date:   Thu Feb 21 12:03:22 2019 +0000
    Fix exprIsConApp_maybe

But alas there was still a bug, now immortalised in
  Note [Don't float join points]
in SimpleOpt.

It's quite hard to trigger because it requires a dead
join point, but it came up when compiling Cabal
Cabal.Distribution.Fields.Lexer.hs, when working on
!3113.

Happily, the fix is extremly easy.  Finding the
bug was not so easy.

- - - - -
46720997 by Ben Gamari at 2020-05-29T01:39:19-04:00
Allow simplification through runRW#

Because runRW# inlines so late, we were previously able to do very
little simplification across it. For instance, given even a simple
program like

    case runRW# (\s -> let n = I# 42# in n) of
      I# n# -> f n#

we previously had no way to avoid the allocation of the I#.

This patch allows the simplifier to push strict contexts into the
continuation of a runRW# application, as explained in
in Note [Simplification of runRW#] in GHC.CoreToStg.Prep.

Fixes #15127.

Metric Increase:
    T9961
Metric Decrease:
    ManyConstructors

Co-Authored-By: Simon Peyton-Jone <simonpj at microsoft.com>

- - - - -
277c2f26 by Ben Gamari at 2020-05-29T01:39:55-04:00
Eta expand un-saturated primops

Now since we no longer try to predict CAFfyness we have no need for the
solution to #16846. Eta expanding unsaturated primop applications is
conceptually simpler, especially in the presence of levity polymorphism.

This essentially reverts cac8dc9f51e31e4c0a6cd9bc302f7e1bc7c03beb,
as suggested in #18079.

Closes #18079.

- - - - -
f44d7ae0 by Simon Jakobi at 2020-05-29T01:40:34-04:00
base: Scrap deprecation plan for Data.Monoid.{First,Last}

See the discussion on the libraries mailing list for context:

https://mail.haskell.org/pipermail/libraries/2020-April/030357.html

- - - - -
8b494895 by Jeremy Schlatter at 2020-05-29T01:41:12-04:00
Fix typo in documentation

- - - - -
998450f4 by Gleb Popov at 2020-05-29T01:41:53-04:00
Always define USE_PTHREAD_FOR_ITIMER for FreeBSD.

- - - - -
f9a513e0 by Alp Mestanogullari at 2020-05-29T01:42:36-04:00
hadrian: introduce 'install' target

Its logic is very simple. It `need`s the `binary-dist-dir` target
and runs suitable `configure` and `make install` commands for the
user. A new `--prefix` command line argument is introduced to
specify where GHC should be installed.

- - - - -
67738db1 by Travis Whitaker at 2020-05-29T13:34:48-04:00
Build a threaded stage 1 if the bootstrapping GHC supports it.

- - - - -
aac19e6c by Peter Trommler at 2020-05-29T13:35:24-04:00
PPC NCG: No per-symbol .section ".toc" directives

All position independent symbols are collected during code generation
and emitted in one go. Prepending each symbol with a .section ".toc"
directive is redundant. This patch drops the per-symbol directives
leading to smaller assembler files.

Fixes #18250

- - - - -
4413828b by Ben Gamari at 2020-05-30T06:07:31-04:00
rts: Teach getNumProcessors to return available processors

Previously we would report the number of physical processors, which
can be quite wrong in a containerized setting. Now we rather return how
many processors are in our affinity mask when possible.

I also refactored the code to prefer platform-specific since this will
report logical CPUs instead of physical (using
`machdep.cpu.thread_count` on Darwin and `cpuset_getaffinity` on FreeBSD).

Fixes #14781.

- - - - -
1449435c by Ben Gamari at 2020-05-30T06:07:31-04:00
users-guide: Note change in getNumProcessors in users guide

- - - - -
3d960169 by Ben Gamari at 2020-05-30T06:07:31-04:00
rts: Drop compatibility shims for Windows Vista

We can now assume that the thread and processor group interfaces are
available.

- - - - -
7f8f948c by Peter Trommler at 2020-05-30T06:08:07-04:00
PPC NCG: Fix .size directive on powerpc64 ELF v1

Thanks to Sergei Trofimovich for pointing out the issue.

Fixes #18237

- - - - -
7c555b05 by Andreas Klebinger at 2020-05-30T06:08:43-04:00
Optimize GHC.Utils.Monad.

Many functions in this module are recursive and as such are marked
loop breakers. Which means they are unlikely to get an unfolding.

This is *bad*. We always want to specialize them to specific Monads.
Which requires a visible unfolding at the use site.

I rewrote the recursive ones from:

    foo f x = ... foo x' ...

to

    foo f x = go x
      where
        go x = ...

As well as giving some pragmas to make all of them available
for specialization.

The end result is a reduction of allocations of about -1.4% for
nofib/spectral/simple/Main.hs when compiled with `-O`.

-------------------------
Metric Decrease:
    T12425
    T14683
    T5631
    T9233
    T9675
    T9961
    WWRec
-------------------------

- - - - -
8b1cb5df by Ben Gamari at 2020-05-30T06:09:20-04:00
Windows: Bump Windows toolchain to 0.2

- - - - -
6947231a by Zubin Duggal at 2020-05-30T06:10:02-04:00
Simplify contexts in GHC.Iface.Ext.Ast

- - - - -
2ee4f36c by Daniel Gröber at 2020-06-01T06:32:56-04:00
Cleanup OVERWRITING_CLOSURE logic

The code is just more confusing than it needs to be. We don't need to mix
the threaded check with the ldv profiling check since ldv's init already
checks for this. Hence they can be two separate checks. Taking the sanity
checking into account is also cleaner via DebugFlags.sanity. No need for
checking the DEBUG define.

The ZERO_SLOP_FOR_LDV_PROF and ZERO_SLOP_FOR_SANITY_CHECK definitions the
old code had also make things a lot more opaque IMO so I removed those.

- - - - -
6159559b by Daniel Gröber at 2020-06-01T06:32:56-04:00
Fix OVERWRITING_CLOSURE assuming closures are not inherently used

The new ASSERT in LDV_recordDead() was being tripped up by MVars when
removeFromMVarBlockedQueue() calls OVERWRITING_CLOSURE() via
OVERWRITE_INFO().

- - - - -
38992085 by Daniel Gröber at 2020-06-01T06:32:56-04:00
Always zero shrunk mutable array slop when profiling

When shrinking arrays in the profiling way we currently don't always zero
the leftover slop. This means we can't traverse such closures in the heap
profiler. The old Note [zeroing slop] and #8402 have some rationale for why
this is so but I belive the reasoning doesn't apply to mutable
closures. There users already have to ensure multiple threads don't step on
each other's toes so zeroing should be safe.

- - - - -
b0c1f2a6 by Ben Gamari at 2020-06-01T06:33:37-04:00
testsuite: Add test for #18151

- - - - -
9a99a178 by Ben Gamari at 2020-06-01T06:33:37-04:00
testsuite: Add test for desugaring of PostfixOperators

- - - - -
2b89ca5b by Ben Gamari at 2020-06-01T06:33:37-04:00
HsToCore: Eta expand left sections

Strangely, the comment next to this code already alluded to the fact
that even simply eta-expanding will sacrifice laziness. It's quite
unclear how we regressed so far.

See #18151.

- - - - -
d412d7a3 by Kirill Elagin at 2020-06-01T06:34:21-04:00
Winferred-safe-imports: Do not exit with error

Currently, when -Winferred-safe-imports is enabled, even when it is not
turned into an error, the compiler will still exit with exit code 1 if
this warning was emitted.

Make sure it is really treated as a warning.

- - - - -
f945eea5 by Ben Gamari at 2020-06-01T06:34:58-04:00
nonmoving: Optimise log2_ceil

- - - - -
aab606e4 by Bodigrim at 2020-06-01T06:35:36-04:00
Clarify description of fromListN
- - - - -
7e5220e2 by Bodigrim at 2020-06-01T06:35:36-04:00
Apply suggestion to libraries/base/GHC/Exts.hs
- - - - -
f3fb1ce9 by fendor at 2020-06-01T06:36:18-04:00
Add `isInScope` check to `lintCoercion`

Mirrors the behaviour of `lintType`.

- - - - -
5ac4d946 by fendor at 2020-06-01T06:36:18-04:00
Lint rhs of IfaceRule

- - - - -
1cef6126 by Jeremy Schlatter at 2020-06-01T06:37:00-04:00
Fix wording in documentation

The duplicate "orphan instance" phrase here doesn't make sense, and was
probably an accident.

- - - - -
5aaf08f2 by Takenobu Tani at 2020-06-01T06:37:43-04:00
configure: Modify aclocal.m4 according to new module hierarchy

This patch updates file paths according to new module hierarchy [1]:

* Rename:
  * compiler/GHC/Parser.hs       <= compiler/parser/Parser.hs
  * compiler/GHC/Parser/Lexer.hs <= compiler/Parser/Lexer.hs

* Add:
  * compiler/GHC/Cmm/Lexer.hs

[1]: https://gitlab.haskell.org/ghc/ghc/-/wikis/Make-GHC-codebase-more-modular

- - - - -
15857ad8 by Ben Gamari at 2020-06-01T06:38:26-04:00
testsuite: Don't fail if we can't unlink __symlink_test

Afterall, it's possible we were unable to create it due to lack of
symlink permission.

- - - - -
4a7229ef by Ben Gamari at 2020-06-01T06:38:26-04:00
testsuite: Refactor ghostscript detection

Tamar reported that he saw crashes due to unhandled exceptions.

- - - - -
2ab37eaf by Ben Gamari at 2020-06-01T06:38:26-04:00
testsuite/perf_notes: Fix ill-typed assignments

- - - - -
e45d5b66 by Ben Gamari at 2020-06-01T06:38:26-04:00
testsuite/testutil: Fix bytes/str mismatch

- - - - -
7002d0cb by Ben Gamari at 2020-06-01T06:38:26-04:00
testsuite: Work around spurious mypy failure

- - - - -
11390e3a by Takenobu Tani at 2020-06-01T06:39:05-04:00
Clean up file paths for new module hierarchy

This updates comments only.
This patch replaces file references according to new module hierarchy.

See also:
* https://gitlab.haskell.org/ghc/ghc/-/wikis/Make-GHC-codebase-more-modular
* https://gitlab.haskell.org/ghc/ghc/issues/13009

- - - - -
8f2e5732 by Takenobu Tani at 2020-06-01T06:39:05-04:00
Modify file paths to module paths for new module hierarchy

This updates comments only.

This patch replaces module references according to new module
hierarchy [1][2].

For files under the `compiler/` directory, I replace them as
module paths instead of file paths. For instance,
`GHC.Unit.State` instead of `compiler/GHC/Unit/State.hs` [3].

For current and future haddock's markup, this patch encloses
the module name with "" [4].

[1]: https://gitlab.haskell.org/ghc/ghc/-/wikis/Make-GHC-codebase-more-modular
[2]: https://gitlab.haskell.org/ghc/ghc/issues/13009
[3]: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/3375#note_276613
[4]: https://haskell-haddock.readthedocs.io/en/latest/markup.html#linking-to-modules

- - - - -
68b71c4a by Tom Ellis at 2020-06-01T06:39:55-04:00
Rename the singleton tuple GHC.Tuple.Unit to GHC.Tuple.Solo

- - - - -
95da76c2 by Sylvain Henry at 2020-06-01T06:40:41-04:00
Hadrian: fix binary-dist target for cross-compilation

- - - - -
730fcd54 by Vladislav Zavialov at 2020-06-01T06:41:18-04:00
Improve parser error messages for the @-operator

Since GHC diverges from the Haskell Report by allowing the user
to define (@) as an infix operator, we better give a good
error message when the user does so unintentionally.

In general, this is rather hard to do, as some failures will be
discovered only in the renamer or the type checker:

	x :: (Integer, Integer)
	x @ (a, b) = (1, 2)

This patch does *not* address this general case.

However, it gives much better error messages when the binding
is not syntactically valid:

	pairs xs @ (_:xs') = zip xs xs'

Before this patch, the error message was rather puzzling:

	<interactive>:1:1: error: Parse error in pattern: pairs

After this patch, the error message includes a hint:

	<interactive>:1:1: error:
	    Parse error in pattern: pairs
	    In a function binding for the ‘@’ operator.
	    Perhaps you meant an as-pattern, which must not be surrounded by whitespace

- - - - -
0fde5377 by Vladislav Zavialov at 2020-06-01T06:41:18-04:00
Improve parser error messages for TypeApplications

With this patch, we always parse  f @t  as a type application,
thereby producing better error messages.

This steals two syntactic forms:

* Prefix form of the @-operator in expressions. Since the @-operator is
  a divergence from the Haskell Report anyway, this is not a major loss.

* Prefix form of @-patterns. Since we are stealing loose infix form
  anyway, might as well sacrifice the prefix form for the sake of much
  better error messages.

- - - - -
c68e7e1e by Vladislav Zavialov at 2020-06-01T06:41:18-04:00
Improve parser error messages for TemplateHaskellQuotes

While [e| |], [t| |], [d| |], and so on, steal syntax from list
comprehensions, [| |] and [|| ||] do not steal any syntax.

Thus we can improve error messages by always accepting them in the
lexer. Turns out the renamer already performs necessary validation.

- - - - -
120aedbd by Ben Gamari at 2020-06-01T16:07:02-04:00
gitlab-ci: Disable use of ld.lld on ARMv7

It turns out that lld non-deterministically fails on ARMv7. I suspect
this may be due to the a kernel regression as this only started
happening when we upgraded to 5.4. Nevertheless, easily avoided by
simply sticking with gold.

Works around #18280.

- - - - -
d6279ff0 by Ben Gamari at 2020-06-02T13:03:30-04:00
gitlab-ci: Ensure that workaround for #18280 applies to bindisttest

We need to ensure that the `configure` flags working around #18280 are
propagated to the bindisttest `configure` as well.

- - - - -
cb5c31b5 by Ben Gamari at 2020-06-03T17:55:04-04:00
gitlab-ci: Allow ARMv7 job to fail

Due to #18298.

- - - - -
32a4ae90 by John Ericson at 2020-06-04T04:34:42-04:00
Clean up boot vs non-boot disambiguating types

We often have (ModuleName, Bool) or (Module, Bool) pairs for "extended"
module names (without or with a unit id) disambiguating boot and normal
modules. We think this is important enough across the compiler that it
deserves a new nominal product type. We do this with synnoyms and a
functor named with a `Gen` prefix, matching other newly created
definitions.

It was also requested that we keep custom `IsBoot` / `NotBoot` sum type.
So we have it too. This means changing many the many bools to use that
instead.

Updates `haddock` submodule.

- - - - -
c05756cd by Niklas Hambüchen at 2020-06-04T04:35:24-04:00
docs: Add more details on InterruptibleFFI.

Details from https://gitlab.haskell.org/ghc/ghc/issues/8684
and https://github.com/takano-akio/filelock/pull/7#discussion_r280332430

- - - - -
1b975aed by Andrew Martin at 2020-06-04T04:36:03-04:00
Allow finalizeForeignPtr to be called on FinalPtr/PlainPtr.

MR 2165 (commit 49301ad6226d9a83d110bee8c419615dd94f5ded) regressed
finalizeForeignPtr by throwing exceptions when PlainPtr was encounterd.
This regression did not make it into a release of GHC. Here, the
original behavior is restored, and FinalPtr is given the same treatment
as PlainPtr.

- - - - -
2bd3929a by Luke Lau at 2020-06-04T04:36:41-04:00
Fix documentation on type families not being extracted

It looks like the location of the Names used for CoAxioms on type
families are now located at their type constructors. Previously, Docs.hs
thought the Names were located in the RHS, so the RealSrcSpan in the
instanceMap and getInstLoc didn't match up. Fixes #18241

- - - - -
6735b9d9 by Ben Gamari at 2020-06-04T04:37:21-04:00
GHC.Hs.Instances: Compile with -O0

This module contains exclusively Data instances, which are going to be
slow no matter what we do. Furthermore, they are incredibly slow to
compile with optimisation (see #9557). Consequently we compile this with
-O0.  See #18254.

- - - - -
c330331a by nineonine at 2020-06-04T04:37:59-04:00
Add test for #17669

- - - - -
cab684f0 by Ben Gamari at 2020-06-04T04:38:36-04:00
rts: Add Windows-specific implementation of rtsSleep

Previously we would use the POSIX path, which uses `nanosleep`. However,
it turns out that `nanosleep` is provided by `libpthread` on Windows. In
general we don't want to incur such a dependency. Avoid this by simply
using `Sleep` on Windows.

Fixes #18272.

- - - - -
ad44b504 by Ben Gamari at 2020-06-04T04:38:36-04:00
compiler: Disable use of process jobs with process < 1.6.9

Due to #17926.

- - - - -
6a4098a4 by Moritz Angermann at 2020-06-04T04:55:51-04:00
[linker] Adds void printLoadedObjects(void);

This allows us to dump in-memory object code locations for debugging.

Fixup printLoadedObjects prototype

- - - - -
af5e3a88 by Artem Pelenitsyn at 2020-06-05T03:18:49-04:00
base: fix sign confusion in log1mexp implementation (fix #17125)

author: claude (https://gitlab.haskell.org/trac-claude)

The correct threshold for log1mexp is -(log 2) with the current specification
of log1mexp. This change improves accuracy for large negative inputs.

To avoid code duplication, a small helper function is added;
it isn't the default implementation in Floating because it needs Ord.

This patch does nothing to address that the Haskell specification is
different from that in common use in other languages.

- - - - -
2b792fac by Simon Peyton Jones at 2020-06-05T09:27:50-04:00
Simple subsumption

This patch simplifies GHC to use simple subsumption.
  Ticket #17775

Implements GHC proposal #287
   https://github.com/ghc-proposals/ghc-proposals/blob/master/
   proposals/0287-simplify-subsumption.rst

All the motivation is described there; I will not repeat it here.
The implementation payload:
 * tcSubType and friends become noticably simpler, because it no
   longer uses eta-expansion when checking subsumption.
 * No deeplyInstantiate or deeplySkolemise

That in turn means that some tests fail, by design; they can all
be fixed by eta expansion.  There is a list of such changes below.

Implementing the patch led me into a variety of sticky corners, so
the patch includes several othe changes, some quite significant:

* I made String wired-in, so that
    "foo" :: String   rather than
    "foo" :: [Char]
  This improves error messages, and fixes #15679

* The pattern match checker relies on knowing about in-scope equality
  constraints, andd adds them to the desugarer's environment using
  addTyCsDs.  But the co_fn in a FunBind was missed, and for some reason
  simple-subsumption ends up with dictionaries there. So I added a
  call to addTyCsDs.  This is really part of #18049.

* I moved the ic_telescope field out of Implication and into
  ForAllSkol instead.  This is a nice win; just expresses the code
  much better.

* There was a bug in GHC.Tc.TyCl.Instance.tcDataFamInstHeader.
  We called checkDataKindSig inside tc_kind_sig, /before/
  solveEqualities and zonking.  Obviously wrong, easily fixed.

* solveLocalEqualitiesX: there was a whole mess in here, around
  failing fast enough.  I discovered a bad latent bug where we
  could successfully kind-check a type signature, and use it,
  but have unsolved constraints that could fill in coercion
  holes in that signature --  aargh.

  It's all explained in Note [Failure in local type signatures]
  in GHC.Tc.Solver. Much better now.

* I fixed a serious bug in anonymous type holes. IN
    f :: Int -> (forall a. a -> _) -> Int
  that "_" should be a unification variable at the /outer/
  level; it cannot be instantiated to 'a'.  This was plain
  wrong.  New fields mode_lvl and mode_holes in TcTyMode,
  and auxiliary data type GHC.Tc.Gen.HsType.HoleMode.

  This fixes #16292, but makes no progress towards the more
  ambitious #16082

* I got sucked into an enormous refactoring of the reporting of
  equality errors in GHC.Tc.Errors, especially in
      mkEqErr1
      mkTyVarEqErr
      misMatchMsg
      misMatchMsgOrCND
  In particular, the very tricky mkExpectedActualMsg function
  is gone.

  It took me a full day.  But the result is far easier to understand.
  (Still not easy!)  This led to various minor improvements in error
  output, and an enormous number of test-case error wibbles.

  One particular point: for occurs-check errors I now just say
     Can't match 'a' against '[a]'
  rather than using the intimidating language of "occurs check".

* Pretty-printing AbsBinds

Tests review

* Eta expansions
   T11305: one eta expansion
   T12082: one eta expansion (undefined)
   T13585a: one eta expansion
   T3102:  one eta expansion
   T3692:  two eta expansions (tricky)
   T2239:  two eta expansions
   T16473: one eta
   determ004: two eta expansions (undefined)
   annfail06: two eta (undefined)
   T17923: four eta expansions (a strange program indeed!)
   tcrun035: one eta expansion

* Ambiguity check at higher rank.  Now that we have simple
  subsumption, a type like
     f :: (forall a. Eq a => Int) -> Int
  is no longer ambiguous, because we could write
     g :: (forall a. Eq a => Int) -> Int
     g = f
  and it'd typecheck just fine.  But f's type is a bit
  suspicious, and we might want to consider making the
  ambiguity check do a check on each sub-term.  Meanwhile,
  these tests are accepted, whereas they were previously
  rejected as ambiguous:
     T7220a
     T15438
     T10503
     T9222

* Some more interesting error message wibbles
   T13381: Fine: one error (Int ~ Exp Int)
           rather than two (Int ~ Exp Int, Exp Int ~ Int)
   T9834:  Small change in error (improvement)
   T10619: Improved
   T2414:  Small change, due to order of unification, fine
   T2534:  A very simple case in which a change of unification order
           means we get tow unsolved constraints instead of one
   tc211: bizarre impredicative tests; just accept this for now

Updates Cabal and haddock submodules.

Metric Increase:
  T12150
  T12234
  T5837
  haddock.base
Metric Decrease:
  haddock.compiler
  haddock.Cabal
  haddock.base

Merge note: This appears to break the
`UnliftedNewtypesDifficultUnification` test. It has been marked as
broken in the interest of merging.

(cherry picked from commit 66b7b195cb3dce93ed5078b80bf568efae904cc5)

- - - - -
2dff8141 by Ryan Scott at 2020-06-05T14:21:24-04:00
Simplify bindLHsTyVarBndrs and bindHsQTyVars

Both `bindLHsTyVarBndrs` and `bindHsQTyVars` take two separate
`Maybe` arguments, which I find terribly confusing. Thankfully, it's
possible to remove one `Maybe` argument from each of these functions,
which this patch accomplishes:

* `bindHsQTyVars` takes a `Maybe SDoc` argument, which is `Just` if
  GHC should warn about any of the quantified type variables going
  unused. However, every call site uses `Nothing` in practice. This
  makes sense, since it doesn't really make sense to warn about
  unused type variables bound by an `LHsQTyVars`. For instance, you
  wouldn't warn about the `a` in `data Proxy a = Proxy` going unused.

  As a result, I simply remove this `Maybe SDoc` argument altogether.
* `bindLHsTyVarBndrs` also takes a `Maybe SDoc` argument for the same
  reasons that `bindHsQTyVars` took one. To make things more
  confusing, however, `bindLHsTyVarBndrs` also takes a separate
  `HsDocContext` argument, which is pretty-printed (to an `SDoc`) in
  warnings and error messages.

  In practice, the `Maybe SDoc` and the `HsDocContext` often contain
  the same text. See the call sites for `bindLHsTyVarBndrs` in
  `rnFamInstEqn` and `rnConDecl`, for instance. There are only a
  handful of call sites where the text differs between the
  `Maybe SDoc` and `HsDocContext` arguments:

  * In `rnHsRuleDecl`, where the `Maybe SDoc` says "`In the rule`"
    and the `HsDocContext` says "`In the transformation rule`".
  * In `rnHsTyKi`/`rn_ty`, where the `Maybe SDoc` says
    "`In the type`" but the `HsDocContext` is inhereted from the
    surrounding context (e.g., if `rnHsTyKi` were called on a
    top-level type signature, the `HsDocContext` would be
    "`In the type signature`" instead)

  In both cases, warnings/error messages arguably _improve_ by
  unifying making the `Maybe SDoc`'s text match that of the
  `HsDocContext`. As a result, I decided to remove the `Maybe SDoc`
  argument to `bindLHsTyVarBndrs` entirely and simply reuse the text
  from the `HsDocContext`. (I decided to change the phrase
  "transformation rule" to "rewrite rule" while I was in the area.)

  The `Maybe SDoc` argument has one other purpose: signaling when to
  emit "`Unused quantified type variable`" warnings. To recover this
  functionality, I replaced the `Maybe SDoc` argument with a
  boolean-like `WarnUnusedForalls` argument. The only
  `bindLHsTyVarBndrs` call site that chooses _not_ to emit these
  warnings in `bindHsQTyVars`.

- - - - -
e372331b by Ben Gamari at 2020-06-07T08:46:41-04:00
hadrian: Add missing deriveConstants dependency on ghcplatform.h

deriveConstants wants to compile C sources which #include PosixSource.h,
which itself #includes ghcplatform.h. Make sure that Hadrian knows
about this dependency.

Fixes #18290.

- - - - -
b022051a by Moritz Angermann at 2020-06-07T08:46:42-04:00
ghc-prim needs to depend on libc and libm

libm is just an empty shell on musl, and all the math functions are contained in
libc.

- - - - -
6dae6548 by Moritz Angermann at 2020-06-07T08:46:42-04:00
Disable DLL loading if without system linker

Some platforms (musl, aarch64) do not have a working dynamic linker
implemented in the libc, even though we might see dlopen.  It will
ultimately just return that this is not supported.  Hence we'll add
a flag to the compiler to flat our disable loading dlls.  This is
needed as we will otherwise try to load the shared library even
if this will subsequently fail.  At that point we have given up
looking for static options though.

- - - - -
4a158ffc by Moritz Angermann at 2020-06-07T08:46:43-04:00
Range is actually +/-2^32, not +/-2^31

See also: https://static.docs.arm.com/ihi0056/g/aaelf64.pdf

- - - - -
f1bfb806 by Ben Gamari at 2020-06-07T10:49:30-04:00
OccurAnal: Avoid exponential behavior due to where clauses

Previously the `Var` case of `occAnalApp` could in some cases (namely
in the case of `runRW#` applications) call `occAnalRhs` two. In the case
of nested `runRW#`s this results in exponential complexity. In some
cases the compilation time that resulted would be very long indeed
(see #18296).

Fixes #18296.

Metric Decrease:
    T9961
    T12150
    T12234

- - - - -
926b058d by Ben Gamari at 2020-06-10T13:30:22-04:00
testsuite: Increase size of T12150

As noted in #18319, this test was previously very fragile. Increase its
size to make it more likely that its fails with its newly-increased
acceptance threshold.

- - - - -


30 changed files:

- + .git-ignore-revs
- .gitlab-ci.yml
- .gitlab/ci.sh
- .gitlab/merge_request_templates/merge-request.md
- aclocal.m4
- compiler/GHC.hs
- compiler/prelude/PrelNames.hs → compiler/GHC/Builtin/Names.hs
- compiler/prelude/THNames.hs → compiler/GHC/Builtin/Names/TH.hs
- compiler/prelude/PrimOp.hs → compiler/GHC/Builtin/PrimOps.hs
- + compiler/GHC/Builtin/PrimOps.hs-boot
- compiler/prelude/TysWiredIn.hs → compiler/GHC/Builtin/Types.hs
- compiler/prelude/TysWiredIn.hs-boot → compiler/GHC/Builtin/Types.hs-boot
- compiler/typecheck/TcTypeNats.hs → compiler/GHC/Builtin/Types/Literals.hs
- compiler/prelude/TysPrim.hs → compiler/GHC/Builtin/Types/Prim.hs
- compiler/prelude/KnownUniques.hs → compiler/GHC/Builtin/Uniques.hs
- compiler/prelude/KnownUniques.hs-boot → compiler/GHC/Builtin/Uniques.hs-boot
- compiler/prelude/PrelInfo.hs → compiler/GHC/Builtin/Utils.hs
- compiler/prelude/primops.txt.pp → compiler/GHC/Builtin/primops.txt.pp
- compiler/GHC/ByteCode/Asm.hs
- compiler/GHC/ByteCode/InfoTable.hs
- compiler/GHC/ByteCode/Instr.hs
- compiler/GHC/ByteCode/Linker.hs
- compiler/GHC/ByteCode/Types.hs
- compiler/GHC/Cmm.hs
- compiler/GHC/Cmm/BlockId.hs
- compiler/GHC/Cmm/CLabel.hs
- compiler/GHC/Cmm/CallConv.hs
- compiler/GHC/Cmm/CommonBlockElim.hs
- compiler/GHC/Cmm/ContFlowOpt.hs
- compiler/GHC/Cmm/Dataflow.hs


The diff was not included because it is too large.


View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b1f9eda52d389bae0877b7dafad0830563bee662...926b058d8874c52976cc6c3973153b87c992222a

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b1f9eda52d389bae0877b7dafad0830563bee662...926b058d8874c52976cc6c3973153b87c992222a
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/20200610/7f7410a6/attachment-0001.html>


More information about the ghc-commits mailing list