[Git][ghc/ghc][wip/andreask/ticker] 159 commits: Improve error handling for VTA + deferred type errors

Andreas Klebinger gitlab at gitlab.haskell.org
Thu Apr 2 10:03:31 UTC 2020



Andreas Klebinger pushed to branch wip/andreask/ticker at Glasgow Haskell Compiler / GHC


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

This fixes #17792

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

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

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

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

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

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

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

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

	newtype BufPos = BufPos { bufPos :: Int }

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

Updates haddock submodule.

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

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

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

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

Convert hadrian buildscripts to unsuffixed, dashed form

final cleanups

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Fixes #17886.

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

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

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

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

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

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

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

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

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

This fixes #17893

[skip-ci]

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

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

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

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

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

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

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

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

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

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

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

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

Fixes #17899.

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

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

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

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

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

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

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

Closes #17904

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

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

Test case: typecheck/should_compile/T17024

Fixes #17024.

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

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

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

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

Clarify code added in #17852 and MR !2724

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

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

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

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

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

Fixes #17906.

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

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

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

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

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

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

Fixes #17710.

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

As noted in #17018.

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

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

I see quite a few warnings like:

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

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

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

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

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

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

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

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

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

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

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

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

* slight refactoring of `ExternalInterp` so that we can read the iserv
  configuration (which is pure) without reading an MVar.

- - - - -
a6989971 by Sylvain Henry at 2020-03-11T20:33:37-04:00
Use a Set to represent Ways

Should make `member` queries faster and avoid messing up with missing
`nubSort`.

Metric Increase:
    hie002

- - - - -
cb93a1a4 by Ryan Scott at 2020-03-11T20:34:14-04:00
Make DeriveFunctor-generated code require fewer beta reductions

Issue #17880 demonstrates that `DeriveFunctor`-generated code is
surprisingly fragile when rank-_n_ types are involved. The culprit is
that `$fmap` (the algorithm used to generate `fmap` implementations)
was too keen on applying arguments with rank-_n_ types to lambdas,
which fail to typecheck more often than not.

In this patch, I change `$fmap` (both the specification and the
implementation) to produce code that avoids creating as many lambdas,
avoiding problems when rank-_n_ field types arise.
See the comments titled "Functor instances" in `TcGenFunctor` for a
more detailed description. Not only does this fix #17880, but it also
ensures that the code that `DeriveFunctor` generates will continue
to work after simplified subsumption is implemented (see #17775).

What is truly amazing is that #17880 is actually a regression
(introduced in GHC 7.6.3) caused by commit
49ca2a37bef18aa57235ff1dbbf1cc0434979b1e, the fix #7436. Prior to
that commit, the version of `$fmap` that was used was almost
identical to the one used in this patch! Why did that commit change
`$fmap` then? It was to avoid severe performance issues that would
arise for recursive `fmap` implementations, such as in the example
below:

```hs
data List a = Nil | Cons a (List a) deriving Functor

-- ===>

instance Functor List where
  fmap f Nil = Nil
  fmap f (Cons x xs) = Cons (f x) (fmap (\y -> f y) xs)
```

The fact that `\y -> f y` was eta expanded caused significant
performance overheads. Commit
49ca2a37bef18aa57235ff1dbbf1cc0434979b1e fixed this performance
issue, but it went too far. As a result, this patch partially
reverts 49ca2a37bef18aa57235ff1dbbf1cc0434979b1e.

To ensure that the performance issues pre-#7436 do not resurface,
I have taken some precautionary measures:

* I have added a special case to `$fmap` for situations where the
  last type variable in an application of some type occurs directly.
  If this special case fires, we avoid creating a lambda expression.
  This ensures that we generate
  `fmap f (Cons x xs) = Cons (f x) (fmap f xs)` in the derived
  `Functor List` instance above. For more details, see
  `Note [Avoid unnecessary eta expansion in derived fmap implementations]`
  in `TcGenFunctor`.
* I have added a `T7436b` test case to ensure that the performance
  of this derived `Functor List`-style code does not regress.

When implementing this, I discovered that `$replace`, the algorithm
which generates implementations of `(<$)`, has a special case that is
very similar to the `$fmap` special case described above. `$replace`
marked this special case with a custom `Replacer` data type, which
was a bit overkill. In order to use the same machinery for both
`Functor` methods, I ripped out `Replacer` and instead implemented
a simple way to detect the special case. See the updated commentary
in `Note [Deriving <$]` for more details.

- - - - -
1f9db3e7 by Kirill Elagin at 2020-03-12T09:45:51-04:00
pretty-printer: Properly parenthesise LastStmt

After ApplicatveDo strips the last `return` during renaming, the pretty
printer has to restore it. However, if the return was followed by `$`,
the dollar was stripped too and not restored.

For example, the last stamement in:

```
  foo = do
    x <- ...
    ...
    return $ f x
```

would be printed as:

```
    return f x
```

This commit preserved the dolar, so it becomes:

```
    return $ f x
```

- - - - -
5cb93af7 by Kirill Elagin at 2020-03-12T09:45:51-04:00
pretty-printer: Do not print ApplicativeDo join

* Do not print `join` in ApplictiveStmt, unless ppr-debug
* Print parens around multiple parallel binds

When ApplicativeDo is enabled, the renamer analyses the statements of a
`do` block and in certain cases marks them as needing to be rewritten
using `join`.

For example, if you have:

```
foo = do
  a <- e1
  b <- e2
  doSomething a b
```

it will be desugared into:

```
foo = join (doSomething <$> e1 <*> e2)
```

After renaming but before desugaring the expression is stored
essentially as:

```
foo = do
  [will need join] (a <- e1 | b <- e2)
  [no return] doSomething a b
```

Before this change, the pretty printer would print a call to `join`,
even though it is not needed at this stage at all. The expression will be
actually rewritten into one using join only at desugaring, at which
point a literal call to join will be inserted.

- - - - -
3a259092 by Simon Peyton Jones at 2020-03-12T09:46:29-04:00
Expose compulsory unfoldings always

The unsafeCoerce# patch requires that unsafeCoerce# has
a compulsory unfolding that is always available.  So we have
to be careful to expose compulsory unfoldings unconditionally
and consistently.

We didn't get this quite right: #17871.  This patch fixes
it.  No real surprises here.

See Note [Always expose compulsory unfoldings] in GHC.Iface.Tidy

- - - - -
6a65b8c2 by Alp Mestanogullari at 2020-03-13T02:29:20-04:00
hadrian: improve dependency tracking for the check-* programs

The code in Rules.Register responsible for finding all the build artifacts
that Cabal installs when registering a library (static/shared libs, .hi files,
...) was looking in the wrong place. This patch fixes that logic and makes sure
we gather all those artifacts in a list to declare that the rule for a given
`.conf` file, our proxy for "Hadrian, please install this package in the package
db for this stage", also produces those artifacts under the said package
database.

We also were completely missing some logic to declare that the check-* programs
have dependencies besides their source code, at least when testing an in-tree
compiler.

Finally, this patch also removes redundant packages from 'testsuitePackages',
since they should already be covered by the stage<N>Packages lists from
Settings.Default.

With this patch, after a complete build and freezing stage 1, a change to
`compiler/parser/Parser.y` results in rebuilding the ghc lib, reinstalling it,
and rebuilding the few programs that depend on it, _including_ `check-ppr` and
`check-api-annotations` (therefore fixing #17273).

- - - - -
44fad4a9 by Sylvain Henry at 2020-03-13T02:30:22-04:00
Rename isDllName

I wanted to fix the dangling comment in `isDllName` ("This is the cause
of #", #8696 is already mentioned earlier). I took the opportunity to
change the function name to better reflect what it does.

- - - - -
2f292db8 by Paavo at 2020-03-13T02:31:03-04:00
Update documentation for closureSize

- - - - -
f124ff0d by Ben Gamari at 2020-03-13T02:31:40-04:00
gitlab-ci: Rework triggering of release builds

Use a push option instead of tagging.

- - - - -
7f25557a by Ben Gamari at 2020-03-13T10:38:09-04:00
gitlab-ci: Distinguish integer-simple test envs

Previously two integer-simple jobs declared the same test environment. One (the nightly job) was built in the perf way, the other in the validate way. Consequently they had appreciably different performance characteristics, causing in the nightly job to spuriously fail with performance changes.
- - - - -
c12a2ec5 by Simon Peyton Jones at 2020-03-14T05:25:30-04:00
Fix Lint

Ticket #17590 pointed out a bug in the way the linter dealt with
type lets, exposed by the new uniqAway story.

The fix is described in Note [Linting type lets]. I ended up
putting the in-scope Ids in a different env field, le_ids,
rather than (as before) sneaking them into the TCvSubst.

Surprisingly tiresome, but done.

Metric Decrease:
    hie002

- - - - -
b989845e by Sylvain Henry at 2020-03-14T05:26:11-04:00
Hadrian: fix absolute buildroot support (#17822)

Shake's "**" wildcard doesn't match absolute root. We must use "//" instead.

- - - - -
4f117135 by Sylvain Henry at 2020-03-14T05:26:49-04:00
Make: refactor GMP rules

Document and use simpler rules for the ghc-gmp.h header.

- - - - -
7432b327 by Sylvain Henry at 2020-03-14T05:27:28-04:00
Use correct option name (-opti) (fix #17314)

s/pgmo/opti

- - - - -
8f7dd571 by Judah Jacobson at 2020-03-14T05:28:07-04:00
Allow overriding LD_STAGE0 and AR_STAGE0 in the configure script.

Previously it was possible to override the stage0 C compiler via `CC_STAGE0`,
but you couldn't override `ld` or `ar` in stage0.  This change allows overriding them
by setting `LD_STAGE0` or `AR_STAGE0`, respectively.

Our team uses this feature internally to take more control of our GHC build
and make it run more hermetically.

- - - - -
7c3e39a9 by Judah Jacobson at 2020-03-14T05:28:07-04:00
Use AC_ARG_VAR for LD_STAGE0 and AR_STAGE0.

- - - - -
20d4d676 by Ben Gamari at 2020-03-14T05:28:43-04:00
nonmoving: Don't traverse filled segment list in pause

The non-moving collector would previously walk the entire filled segment
list during the preparatory pause. However, this is far more work than
is strictly necessary. We can rather get away with merely collecting the
allocators' filled segment list heads and process the lists themselves
during the concurrent phase. This can significantly reduce the maximum
gen1 GC pause time in programs with high rates of long-lived allocations.

- - - - -
fdfa2d01 by Ben Gamari at 2020-03-14T05:29:18-04:00
nonmoving: Remove redundant bitmap clearing

nonmovingSweep already clears the bitmap in the sweep loop. There is no
reason to do so a second time.

- - - - -
2f8c7767 by Simon Peyton Jones at 2020-03-14T05:29:55-04:00
Simple refactor of cheapEqExpr

No change in functionality.  Just seems tidier (and signficantly more
efficient) to deal with ticks directly than to call stripTicksTopE.

- - - - -
88f7a762 by Simon Peyton Jones at 2020-03-14T05:29:55-04:00
Improve CSE.combineAlts

This patch improves the way that CSE combines identical
alternatives.  See #17901.

I'm still not happy about the duplication between CSE.combineAlts
and GHC.Core.Utils.combineIdenticalAlts; see the Notes with those
functions.  But this patch is a step forward.

Metric Decrease:
    T12425
    T5642

- - - - -
8b95ddd3 by Ben Gamari at 2020-03-14T05:30:31-04:00
gitlab-ci: Add integer-simple release build for Windows

Closes #16144.

- - - - -
e3c374cc by Simon Peyton Jones at 2020-03-14T05:31:07-04:00
Wrap an implication around class-sig kind errors

Ticket #17841 showed that we can get a kind error
in a class signature, but lack an enclosing implication
that binds its skolems.

This patch

* Adds the wrapping implication: the new call to
  checkTvConstraints in tcClassDecl1

* Simplifies the API to checkTvConstraints, which
  was not otherwise called at all.

* Simplifies TcErrors.report_unsolved by *not*
  initialising the TidyEnv from the typechecker lexical
  envt.  It's enough to do so from the free vars of the
  unsolved constraints; and we get silly renamings if
  we add variables twice: once from the lexical scope
  and once from the implication constraint.

- - - - -
73133a3b by Simon Peyton Jones at 2020-03-14T05:31:07-04:00
Refactoring in TcSMonad

This patch is just refactoring: no change in
behaviour.

I removed the rather complicated
    checkConstraintsTcS
    checkTvConstraintsTcS

in favour of simpler functions
    emitImplicationTcS
    emitTvImplicationTcS
    pushLevelNoWorkList

The last of these is a little strange, but overall
it's much better I think.

- - - - -
93c88c26 by Ben Gamari at 2020-03-14T05:31:42-04:00
base: Make `open` calls interruptible

As noted in #17912, `open` system calls were `safe` rather than
`interruptible`. Consequently, the program could not be interrupted with
SIGINT if stuck in a slow open operation. Fix this by marking
`c_safe_open` as interruptible.

- - - - -
bee4cdad by Vladislav Zavialov at 2020-03-14T05:32:18-04:00
Remove second tcLookupTcTyCon in tcDataDefn

Before this patch, tcDataDefn used to call tcLookupTcTyCon twice in a row:
	1. in bindTyClTyVars itself
	2. in the continuation passed to it

Now bindTyClTyVars passes the TcTyCon to the continuation, making
the second lookup unnecessary.

- - - - -
3f116d35 by Cale Gibbard at 2020-03-14T19:34:42-04:00
Enable stage1 build of haddock

The submodule has already been bumped to contain the fix.

- - - - -
49e9d739 by Ömer Sinan Ağacan at 2020-03-14T19:35:24-04:00
rts: Fix printClosure when printing fwd ptrs

- - - - -
1de3ab4a by Krzysztof Gogolewski at 2020-03-14T19:36:04-04:00
Remove unused field var_inline (#17915)

- - - - -
d30aeb4b by Krzysztof Gogolewski at 2020-03-15T03:57:41-04:00
Document restriction on SCC pragma syntax

Currently, the names of cost centres must be quoted or
be lowercase identifiers.

Fixes #17916.

- - - - -
b4774598 by Brian Foley at 2020-03-15T03:58:18-04:00
Remove some dead code

>From the notes.ghc.drop list found using weeder in #17713

- - - - -
dd6ffe6b by Viktor Dukhovni at 2020-03-15T03:58:55-04:00
Note platform-specific Foreign.C.Types in context

Also fix the markup in the general note at the top of the module.  Haddock
(usability trade-off), does not support multi-line emphasised text.

- - - - -
2e82465f by Sylvain Henry at 2020-03-15T10:57:10-04:00
Refactor CmmToAsm (disentangle DynFlags)

This patch disentangles a bit more DynFlags from the native code
generator (CmmToAsm).

In more details:

- add a new NCGConfig datatype in GHC.CmmToAsm.Config which contains the
  configuration of a native code generation session
- explicitly pass NCGConfig/Platform arguments when necessary
- as a consequence `sdocWithPlatform` is gone and there are only a few
  `sdocWithDynFlags` left
- remove the use of `unsafeGlobalDynFlags` from GHC.CmmToAsm.CFG
- remove `sdocDebugLevel` (now we pass the debug level via NCGConfig)

There are still some places where DynFlags is used, especially because
of pretty-printing (CLabel), because of Cmm helpers (such as
`cmmExprType`) and because of `Outputable` instance for the
instructions. These are left for future refactoring as this patch is
already big.

- - - - -
c35c545d by Judah Jacobson at 2020-03-15T10:57:48-04:00
Add a -no-haddock flag.

This flag undoes the effect of a previous "-haddock" flag.  Having both flags makes it easier
for build systems to enable Haddock parsing in a set of global flags, but then disable it locally for
specific targets (e.g., third-party packages whose comments don't pass the validation in the latest GHC).

I added the flag to expected-undocumented-flags.txt since `-haddock` was alreadyin that list.

- - - - -
cfcc3c9a by Ömer Sinan Ağacan at 2020-03-15T10:58:27-04:00
Fix global_link of TSOs for threads reachable via dead weaks

Fixes #17785

Here's how the problem occurs:

- In generation 0 we have a TSO that is finished (i.e. it has no more
  work to do or it is killed).

- The TSO only becomes reachable after collectDeadWeakPtrs().

- After collectDeadWeakPtrs() we switch to WeakDone phase where we don't
  move TSOs to different lists anymore (like the next gen's thread list
  or the resurrected_threads list).

- So the TSO will never be moved to a generation's thread list, but it
  will be promoted to generation 1.

- Generation 1 collected via mark-compact, and because the TSO is
  reachable it is marked, and its `global_link` field, which is bogus at
  this point (because the TSO is not in a list), will be threaded.

- Chaos ensues.

In other words, when these conditions hold:

- A TSO is reachable only after collectDeadWeakPtrs()
- It's finished (what_next is ThreadComplete or ThreadKilled)
- It's retained by mark-compact collector (moving collector doesn't
  evacuate the global_list field)

We end up doing random mutations on the heap because the TSO's
global_list field is not valid, but it still looks like a heap pointer
so we thread it during compacting GC.

The fix is simple: when we traverse old_threads lists to resurrect
unreachable threads the threads that won't be resurrected currently
stays on the old_threads lists. Those threads will never be visited
again by MarkWeak so we now reset the global_list fields. This way
compacting GC does not thread pointers to nowhere.

Testing
-------

The reproducer in #17785 is quite large and hard to build, because of
the dependencies, so I'm not adding a regression test.

In my testing the reproducer would take a less than 5 seconds to run,
and once in every ~5 runs would fail with a segfault or an assertion
error. In other cases it also fails with a test failure. Because the
tests never fail with the bug fix, assuming the code is correct, this
also means that this bug can sometimes lead to incorrect runtime
results.

After the fix I was able to run the reproducer repeatedly for about an
hour, with no runtime crashes or test failures.

To run the reproducer clone the git repo:

    $ git clone https://github.com/osa1/streamly --branch ghc-segfault

Then clone primitive and atomic-primops from their git repos and point
to the clones in cabal.project.local. The project should then be
buildable using GHC HEAD. Run the executable `properties` with `+RTS -c
-DZ`.

In addition to the reproducer above I run the test suite using:

    $ make slowtest EXTRA_HC_OPTS="-debug -with-rtsopts=-DS \
        -with-rtsopts=-c +RTS -c -RTS" SKIPWAY='nonmoving nonmoving_thr'

This enables compacting GC always in both GHC when building the test
programs and when running the test programs, and also enables sanity
checking when running the test programs. These set of flags are not
compatible for all tests so there are some failures, but I got the same
set of failures with this patch compared to GHC HEAD.

- - - - -
818b3c38 by Lysxia at 2020-03-16T23:52:42-04:00
base: add strict IO functions: readFile', getContents', hGetContents'

- - - - -
18a346a4 by Sylvain Henry at 2020-03-16T23:53:24-04:00
Modules: Core (#13009)

Update submodule: haddock

- - - - -
92327e3a by Ömer Sinan Ağacan at 2020-03-16T23:54:04-04:00
Update sanity checking for TSOs:

- Remove an invalid assumption about GC checking what_next field. The GC
  doesn't care about what_next at all, if a TSO is reachable then all
  its pointers are followed (other than global_tso, which is only
  followed by compacting GC).

- Remove checkSTACK in checkTSO: TSO stacks will be visited in
  checkHeapChain, or checkLargeObjects etc.

- Add an assertion in checkTSO to check that the global_link field is
  sane.

- Did some refactor to remove forward decls in checkGlobalTSOList and
  added braces around single-statement if statements.

- - - - -
e1aa4052 by PHO at 2020-03-17T07:36:09-04:00
Don't use non-portable operator "==" in configure.ac

The test operator "==" is a Bash extension and produces a wrong result
if /bin/sh is not Bash.

- - - - -
89f034dd by Maximilian Tagher at 2020-03-17T07:36:48-04:00
Document the units of -ddump-timings

Right now, in the output of -ddump-timings to a file, you can't tell what the units are:

```
CodeGen [TemplateTestImports]: alloc=22454880 time=14.597
```

I believe bytes/milliseconds are the correct units, but confirmation would be appreciated. I'm basing it off of this snippet from `withTiming'`:

```
when (verbosity dflags >= 2 && prtimings == PrintTimings)
  $ liftIO $ logInfo dflags (defaultUserStyle dflags)
      (text "!!!" <+> what <> colon <+> text "finished in"
       <+> doublePrec 2 time
       <+> text "milliseconds"
       <> comma
       <+> text "allocated"
       <+> doublePrec 3 (realToFrac alloc / 1024 / 1024)
       <+> text "megabytes")
```

which implies time is in milliseconds, and allocations in bytes (which divided by 1024 would be KB, and again would be MB)

- - - - -
beffa147 by Simon Peyton Jones at 2020-03-17T07:37:25-04:00
Implement mapTyCo like foldTyCo

This patch makes mapType use the successful idiom described
in TyCoRep
   Note [Specialising foldType]

I have not yet changed any functions to use mapType, though there
may be some suitable candidates.

This patch should be a no-op in terms of functionality but,
because it inlines the mapper itself, I'm hoping that there may
be some modest perf improvements.

Metric Decrease:
    T5631
    T5642
    T3064
    T9020
    T14683
    hie002
    haddock.Cabal
    haddock.base
    haddock.compiler

- - - - -
5800ebfe by Ömer Sinan Ağacan at 2020-03-17T07:38:08-04:00
Don't update ModDetails with CafInfos when opts are disabled

This is consistent with the interface file behavior where we omit
HsNoCafRefs annotations with -fomit-interface-pragmas (implied by -O0).

ModDetails and ModIface are just different representations of the same
thing, so they really need to be in sync. This patch does the right
thing and does not need too much explanation, but here's an example of a
problem not doing this causes in !2842:

    -- MyInteger.hs
    module MyInteger
      ( MyInteger (MyInteger)
      , ToMyInteger (toMyInteger)
      ) where

    newtype MyInteger = MyInteger Integer

    class ToMyInteger a where
      toMyInteger :: a -> MyInteger

    instance ToMyInteger Integer where
      toMyInteger = MyInteger {- . succ -}

    -- Main.hs
    module Main
      ( main
      ) where

    import MyInteger (MyInteger (MyInteger), toMyInteger)

    main :: IO ()
    main = do
      let (MyInteger i) = (id . toMyInteger) (41 :: Integer)
      print i

If I build this with -O0, without this fix, we generate a ModDetails with
accurate LFInfo for toMyInteger (MyInteger.$fToMyIntegerInteger) which says that
it's a LFReEntrant with arity 1. This means in the use site (Main) we tag the
value:

    R3 = MyInteger.$fToMyIntegerInteger_closure + 1;
    R2 = GHC.Base.id_closure;
    R1 = GHC.Base.._closure;
    Sp = Sp - 16;
    call stg_ap_ppp_fast(R4, R3, R2, R1) args: 24, res: 0, upd: 24;

Now we change the definition by uncommenting the `succ` part and it becomes a thunk:

    MyInteger.$fToMyIntegerInteger [InlPrag=INLINE (sat-args=0)]
      :: MyInteger.ToMyInteger GHC.Integer.Type.Integer
    [GblId[DFunId(nt)]] =
        {} \u [] $ctoMyInteger_rEA;

and its LFInfo is now LFThunk. This change in LFInfo makes a difference in the
use site: we can no longer tag it.

But becuase the interface fingerprint does not change (because ModIface does not
change) we don't rebuild Main and tag the thunk.

(1.2% increase in allocations when building T12545 on armv7 because we
generate more code without CafInfos)

Metric Increase:
    T12545

- - - - -
5b632dad by Paavo at 2020-03-17T07:38:48-04:00
Add example for Data.Semigroup.diff

- - - - -
4d85d68b by Paavo at 2020-03-17T07:38:48-04:00
Clean up

- - - - -
75168d07 by Paavo at 2020-03-17T07:38:48-04:00
Make example collapsible

- - - - -
53ff2cd0 by Richard Eisenberg at 2020-03-17T13:46:57+00:00
Fix #17021 by checking more return kinds

All the details are in new Note [Datatype return kinds] in
TcTyClsDecls.

Test case: typecheck/should_fail/T17021{,b}
           typecheck/should_compile/T17021a

Updates haddock submodule

- - - - -
528df8ec by Sylvain Henry at 2020-03-18T10:06:43-04:00
Modules: Core operations (#13009)

- - - - -
4e8a71c1 by Richard Eisenberg at 2020-03-18T10:07:19-04:00
Add release note about fix to #16502.

We thought we needed to update the manual, but the fix for #16502
actually brings the implementation in line with the manual. So we
just alert users of how to update their code.

- - - - -
5cbf9934 by Andreas Klebinger at 2020-03-19T00:39:27-04:00
Update "GHC differences to the FFI Chapter" in user guide.

The old entry had a heavy focus on how things had been. Which is
not what I generally look for in a user guide.

I also added a small section on behaviour of nested safe ffi calls.

[skip-ci]

- - - - -
b03fd3bc by Sebastian Graf at 2020-03-19T00:40:06-04:00
PmCheck: Use ConLikeSet to model negative info

In #17911, Simon recognised many warnings stemming from over-long list
unions while coverage checking Cabal's `LicenseId` module.

This patch introduces a new `PmAltConSet` type which uses a `UniqDSet`
instead of an association list for `ConLike`s. For `PmLit`s, it will
still use an assocation list, though, because a similar map data
structure would entail a lot of busy work.

Fixes #17911.

- - - - -
64f20756 by Sylvain Henry at 2020-03-19T12:16:49-04:00
Refactoring: use Platform instead of DynFlags when possible

Metric Decrease:
    ManyConstructors
    T12707
    T13035
    T1969

- - - - -
cb1785d9 by Ömer Sinan Ağacan at 2020-03-19T12:16:54-04:00
FastString: fix eager reading of string ptr in hashStr

This read causes NULL dereferencing when len is 0.

Fixes #17909

In the reproducer in #17909 this bug is triggered as follows:

- SimplOpt.dealWithStringLiteral is called with a single-char string
  ("=" in #17909)

- tailFS gets called on the FastString of the single-char string.

- tailFS checks the length of the string, which is 1, and calls
  mkFastStringByteString on the tail of the ByteString, which is an
  empty ByteString as the original ByteString has only one char.

- ByteString's unsafeUseAsCStringLen returns (NULL, 0) for the empty
  ByteString, which is passed to mkFastStringWith.

- mkFastStringWith gets hash of the NULL pointer via hashStr, which
  fails on empty strings because of this bug.

- - - - -
73a7383e by Richard Eisenberg at 2020-03-20T20:42:56-04:00
Simplify treatment of heterogeneous equality

Previously, if we had a [W] (a :: k1) ~ (rhs :: k2), we would
spit out a [D] k1 ~ k2 and part the W as irreducible, hoping for
a unification. But we needn't do this. Instead, we now spit out
a [W] co :: k2 ~ k1 and then use co to cast the rhs of the original
Wanted. This means that we retain the connection between the
spat-out constraint and the original.

The problem with this new approach is that we cannot use the
casted equality for substitution; it's too like wanteds-rewriting-
wanteds. So, we forbid CTyEqCans that mention coercion holes.

All the details are in Note [Equalities with incompatible kinds]
in TcCanonical.

There are a few knock-on effects, documented where they occur.

While debugging an error in this patch, Simon and I ran into
infelicities in how patterns and matches are printed; we made
small improvements.

This patch includes mitigations for #17828, which causes spurious
pattern-match warnings. When #17828 is fixed, these lines should
be removed.

- - - - -
faa36e5b by Sylvain Henry at 2020-03-20T20:43:41-04:00
Hadrian: ignore in-tree GMP objects with ``--lint``

- - - - -
9a96ff6b by Richard Eisenberg at 2020-03-20T20:44:17-04:00
Update core spec to reflect changes to Core.

Key changes:
 * Adds a new rule for forall-coercions over coercion variables, which
was implemented but conspicuously missing from the spec.
 * Adds treatment for FunCo.
 * Adds treatment for ForAllTy over coercion variables.
 * Improves commentary (including restoring a Note lost in
03d4852658e1b7407abb4da84b1b03bfa6f6db3b) in the source.

No changes to running code.

- - - - -
7e0451c6 by Sergej Jaskiewicz at 2020-03-20T20:44:55-04:00
Fix event message in withTiming'

This typo caused generating 'end' events without the corresponding 'begin' events.

- - - - -
1542a626 by Ben Gamari at 2020-03-22T22:37:47-04:00
fs.h: Add missing declarations on Windows

- - - - -
3bcf2ccd by Ben Gamari at 2020-03-22T22:37:47-04:00
Bump process submodule

Avoids redundant case alternative warning.

- - - - -
3b363ef9 by Ben Gamari at 2020-03-22T22:37:47-04:00
testsuite: Normalize slashes in ghc-api annotations output

Enable `normalise_slashes` on `annotations`, `listcomps`, and
`parseTree` to fix Windows failures.

- - - - -
25fc9429 by Ben Gamari at 2020-03-22T22:37:47-04:00
testsuite: Update expected output on Windows

- - - - -
7f58ec6d by Ben Gamari at 2020-03-22T22:37:47-04:00
testsuite: Fix TOP of T17786

- - - - -
aadcd909 by GHC GitLab CI at 2020-03-22T22:37:47-04:00
testsuite: Update expected output on Windows

- - - - -
dc1eb10d by GHC GitLab CI at 2020-03-22T22:37:47-04:00
hadrian: Fix executable extension passed to testsuite driver

- - - - -
58f62e2c by GHC GitLab CI at 2020-03-22T22:37:47-04:00
gitlab-ci: Require that Windows-hadrian job passes

- - - - -
8dd2415d by Ben Gamari at 2020-03-22T22:37:47-04:00
hadrian: Eliminate redundant .exe from GHC path

Previously we were invoking:

    bash -c
    "c:/GitLabRunner/builds/eEQrxK4p/0/ghc/ghc/toolchain/bin/ghc.exe.exe
    testsuite/mk/ghc-config.hs -o _build/test/bin/ghc-config.exe"

- - - - -
373621f6 by Ben Gamari at 2020-03-22T22:37:47-04:00
Bump hsc2hs submodule

- - - - -
abc02b40 by Hécate at 2020-03-22T22:38:33-04:00
Annotate the non-total function in Data.Foldable as such

- - - - -
19f12557 by Josef Svenningsson at 2020-03-23T14:05:33-04:00
Fix ApplicativeDo regression #17835

A previous fix for #15344 made sure that monadic 'fail' is used properly
when translating ApplicativeDo. However, it didn't properly account
for when a 'fail' will be inserted which resulted in some programs
failing with a type error.

- - - - -
2643ba46 by Paavo at 2020-03-24T08:31:32-04:00
Add example and doc for Arg (Fixes #17153)

- - - - -
703221f4 by Roland Senn at 2020-03-25T14:45:04-04:00
Use export list of Main module in function TcRnDriver.hs:check_main (Fix #16453)

- Provide the export list of the `Main` module as parameter to the
  `compiler/typecheck/TcRnDriver.hs:check_main` function.
- Instead of `lookupOccRn_maybe` call the function `lookupInfoOccRn`.
  It returns the list `mains_all` of all the main functions in scope.
- Select from this list `mains_all` all `main` functions that are in
  the export list of the `Main` module.
- If this new list contains exactly one single `main` function, then
  typechecking continues.
- Otherwise issue an appropriate error message.

- - - - -
3e27205a by Sebastian Graf at 2020-03-25T14:45:40-04:00
Remove -fkill-absence and -fkill-one-shot flags

They seem to be a benchmarking vestige of the Cardinality paper and
probably shouldn't have been merged to HEAD in the first place.

- - - - -
262e42aa by Peter Trommler at 2020-03-25T22:41:39-04:00
Do not panic on linker errors

- - - - -
0de03cd7 by Sylvain Henry at 2020-03-25T22:42:02-04:00
DynFlags refactoring III

Use Platform instead of DynFlags when possible:
* `tARGET_MIN_INT` et al. replaced with `platformMinInt` et al.
* no more DynFlags in PreRules: added a new `RuleOpts` datatype
* don't use `wORD_SIZE` in the compiler
* make `wordAlignment` use `Platform`
* make `dOUBLE_SIZE` a constant

Metric Decrease:
    T13035
    T1969

- - - - -
7a04920b by Tristan Cacqueray at 2020-03-25T22:42:06-04:00
Base: fix a typo in liftA doc

This change removes an extra '|' that should not be rendered in
the liftA documentation.

Tracking: #17929

- - - - -
1c5a15f7 by Tristan Cacqueray at 2020-03-25T22:42:06-04:00
Base: add Control.Applicative optional example

This change adds an optional example.

Tracking: #17929

- - - - -
6d172e63 by Tristan Cacqueray at 2020-03-25T22:42:06-04:00
Base: add markup around Except

- - - - -
eb2162c8 by John Ericson at 2020-03-26T12:37:08-04:00
Remove unused `ghciTablesNextToCode` from compiler proper

- - - - -
f51efc4b by Joachim Breitner at 2020-03-26T12:37:09-04:00
Prepare to use run-time tablesNextToCode in compiler exclusively

Factor out CPP as much as possible to prepare for runtime
determinattion.

Progress towards #15548

- - - - -
1c446220 by Joachim Breitner at 2020-03-26T12:37:09-04:00
Use run-time tablesNextToCode in compiler exclusively (#15548)

Summary:

 - There is no more use of the TABLES_NEXT_TO_CODE CPP macro in
   `compiler/`. GHCI_TABLES_NEXT_TO_CODE is also removed entirely.
   The field within `PlatformMisc` within `DynFlags` is used instead.

 - The field is still not exposed as a CLI flag. We might consider some
   way to ensure the right RTS / libraries are used before doing that.

Original reviewers:

Original subscribers: TerrorJack, rwbarton, carter

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

- - - - -
1941ef4f by Sylvain Henry at 2020-03-29T17:28:51-04:00
Modules: Types (#13009)

Update Haddock submodule

Metric Increase:
   haddock.compiler

- - - - -
1c7c6f1a by Sylvain Henry at 2020-03-29T17:28:51-04:00
Remove GHC.Types.Unique.Map module

This module isn't used anywhere in GHC.

- - - - -
f1a6c73d by Sylvain Henry at 2020-03-29T17:28:51-04:00
Merge GHC.Types.CostCentre.Init into GHC.Driver.CodeOutput

- - - - -
54250f2d by Simon Peyton Jones at 2020-03-29T17:29:30-04:00
Demand analysis: simplify the demand for a RHS

Ticket #17932 showed that we were using a stupid demand for the RHS
of a let-binding, when the result is a product.  This was the result
of a "fix" in 2013, which (happily) turns out to no longer be
necessary.

So I just deleted the code, which simplifies the demand analyser,
and fixes #17932. That in turn uncovered that the anticipation
of worker/wrapper in CPR analysis was inaccurate, hence the logic
that decides whether to unbox an argument in WW was extracted into
a function `wantToUnbox`, now consulted by CPR analysis.

I tried nofib, and got 0.0% perf changes.

All this came up when messing about with !2873 (ticket #17917),
but is idependent of it.

Unfortunately, this patch regresses #4267 and realised that it is now
blocked on #16335.

- - - - -
03060b2f by Ben Gamari at 2020-03-29T17:30:05-04:00
testsuite: Fix T17786 on Windows

Fixes line ending normalization issue.

- - - - -
1f7995ba by Ben Gamari at 2020-03-29T17:30:05-04:00
testsuite: Fix T17786

Fix missing quoting and expected exit code.

- - - - -
ef9c608e by Ben Gamari at 2020-03-29T17:30:05-04:00
testsuite: Mark T12971 as broken on Windows

Due to #17945.

- - - - -
e54500c1 by Sylvain Henry at 2020-03-29T17:30:47-04:00
Store ComponentId details

As far as GHC is concerned, installed package components ("units") are
identified by an opaque ComponentId string provided by Cabal. But we
don't want to display it to users (as it contains a hash) so GHC queries
the database to retrieve some infos about the original source package
(name, version, component name).

This patch caches these infos in the ComponentId itself so that we don't
need to provide DynFlags (which contains installed package informations)
to print a ComponentId.

In the future we want GHC to support several independent package states
(e.g. for plugins and for target code), hence we need to avoid
implicitly querying a single global package state.

- - - - -
7e7cb714 by Marius Bakke at 2020-03-29T17:31:27-04:00
testsuite: Remove test that dlopens a PIE object.

glibc 2.30 disallowed dlopening PIE objects, so just remove the test.
Fixes #17952.

- - - - -
6c8f80d8 by Andreas Klebinger at 2020-03-29T17:32:04-04:00
Correct haddocks for testBit in Data.Bits

It conflated the nth bit with the bit at offset n.

Now we instead give the definition in terms of `bit and `.&.`
on top of clearer phrasing.

- - - - -
c916f190 by Andreas Klebinger at 2020-03-29T17:32:04-04:00
Apply suggestion to libraries/base/Data/Bits.hs
- - - - -
64bf7f51 by Ben Gamari at 2020-03-29T17:32:41-04:00
gitlab-ci: Add FreeBSD release job

- - - - -
a0d8e92e by Ryan Scott at 2020-03-29T17:33:20-04:00
Run checkNewDataCon before constraint-solving newtype constructors

Within `checkValidDataCon`, we used to run `checkValidType` on the
argument types of a newtype constructor before running
`checkNewDataCon`, which ensures that the user does not attempt
non-sensical things such as newtypes with multiple arguments or
constraints. This works out in most situations, but this falls over
on a corner case revealed in #17955:

```hs
newtype T = Coercible () T => T ()
```

`checkValidType`, among other things, peforms an ambiguity check on
the context of a data constructor, and that it turn invokes the
constraint solver. It turns out that there is a special case in the
constraint solver for representational equalities (read: `Coercible`
constraints) that causes newtypes to be unwrapped (see
`Note [Unwrap newtypes first]` in `TcCanonical`). This special case
does not know how to cope with an ill formed newtype like `T`, so
it ends up panicking.

The solution is surprisingly simple: just invoke `checkNewDataCon`
before `checkValidType` to ensure that the illicit newtype
constructor context is detected before the constraint solver can
run amok with it.

Fixes #17955.

- - - - -
45eb9d8c by Krzysztof Gogolewski at 2020-03-29T17:33:59-04:00
Minor cleanup

- Simplify mkBuildExpr, the function newTyVars was called
  only on a one-element list.
- TTG: use noExtCon in more places. This is more future-proof.
- In zonkExpr, panic instead of printing a warning.

- - - - -
f024b6e3 by Sylvain Henry at 2020-03-30T12:48:39+02:00
Expect T4267 to pass

Since 54250f2d8de910b094070c1b48f086030df634b1 we expected T4267 to
fail, but it passes on CI.

- - - - -
57b888c0 by Ryan Scott at 2020-03-31T10:54:20-04:00
Require GHC 8.8 as the minimum compiler for bootstrapping

This allows us to remove several bits of CPP that are either always
true or no longer reachable. As an added bonus, we no longer need to
worry about importing `Control.Monad.Fail.fail` qualified to avoid
clashing with `Control.Monad.fail`, since the latter is now the same
as the former.

- - - - -
33f09551 by Ryan Scott at 2020-03-31T10:54:57-04:00
Add regression test for #17963

The panic in #17963 happened to be fixed by commit
e3c374cc5bd7eb49649b9f507f9f7740697e3f70. This patch adds a
regression test to ensure that it remains fixed.

Fixes #17963.

- - - - -
09a36e80 by Ömer Sinan Ağacan at 2020-03-31T10:55:37-04:00
Simplify stderrSupportsAnsiColors

The combinator andM is used only once, and the code is shorter and
simpler if you inline it.

- - - - -
95bccdd0 by Ben Gamari at 2020-03-31T10:56:19-04:00
base: Ensure that encoding global variables aren't inlined

As noted in #17970, these (e.g. `getFileSystemEncoding` and
`setFileSystemEncoding`) previously had unfoldings, which would
break their global-ness.

While not strictly necessary, I also add a NOINLINE on
`initLocaleEncoding` since it is used in `System.IO`, ensuring that we
only system's query the locale encoding once.

Fixes #17970.

- - - - -
982aaa83 by Andreas Klebinger at 2020-03-31T10:56:55-04:00
Update hadrian index revision.

Required in order to build hadrian using ghc-8.10

- - - - -
4b9c5864 by Ben Gamari at 2020-03-31T10:57:32-04:00
integer-gmp: Bump version and add changelog entry

- - - - -
9b39f2e6 by Ryan Scott at 2020-04-01T01:20:00-04:00
Clean up "Eta reduction for data families" Notes

Before, there were two distinct Notes named
"Eta reduction for data families". This renames one of them to
"Implementing eta reduction for data families" to disambiguate the
two and fixes references in other parts of the codebase to ensure
that they are pointing to the right place.

Fixes #17313.

[ci skip]

- - - - -
7627eab5 by Ryan Scott at 2020-04-01T01:20:38-04:00
Fix the changelog/@since information for hGetContents'/getContents'/readFile'

Fixes #17979.

[ci skip]

- - - - -
0002db1b by Sylvain Henry at 2020-04-01T01:21:27-04:00
Kill wORDS_BIGENDIAN and replace it with platformByteOrder (#17957)

Metric Decrease:
    T13035
    T1969

- - - - -
7b217179 by Sebastian Graf at 2020-04-01T15:03:24-04:00
PmCheck: Adjust recursion depth for inhabitation test

In #17977, we ran into the reduction depth limit of the typechecker.
That was only a symptom of a much broader issue: The recursion depth
of the coverage checker for trying to instantiate strict fields in the
`nonVoid` test was far too high (100, the `defaultMaxTcBound`).

As a result, we were performing quite poorly on `T17977`.
Short of a proper termination analysis to prove emptyness of a type,
we just arbitrarily default to a much lower recursion limit of 3.

Fixes #17977.

- - - - -
3c09f636 by Andreas Klebinger at 2020-04-01T15:03:59-04:00
Make hadrian pass on the no-colour setting to GHC.

Fixes #17983.

- - - - -
b943b25d by Simon Peyton Jones at 2020-04-02T01:45:58-04:00
Re-engineer the binder-swap transformation

The binder-swap transformation is implemented by the occurrence
analyser -- see Note [Binder swap] in OccurAnal. However it had
a very nasty corner in it, for the case where the case scrutinee
was a GlobalId.  This led to trouble and hacks, and ultimately
to #16296.

This patch re-engineers how the occurrence analyser implements
the binder-swap, by actually carrying out a substitution rather
than by adding a let-binding.  It's all described in
Note [The binder-swap substitution].

I did a few other things along the way

* Fix a bug in StgCse, which could allow a loop breaker to be CSE'd
  away.  See Note [Care with loop breakers] in StgCse.  I think it can
  only show up if occurrence analyser sets up bad loop breakers, but
  still.

* Better commenting in SimplUtils.prepareAlts

* A little refactoring in CoreUnfold; nothing significant
  e.g. rename CoreUnfold.mkTopUnfolding to mkFinalUnfolding

* Renamed CoreSyn.isFragileUnfolding to hasCoreUnfolding

* Move mkRuleInfo to CoreFVs

We observed respectively 4.6% and 5.9% allocation decreases for the following
tests:

Metric Decrease:
    T9961
    haddock.base

- - - - -
42d68364 by Sebastian Graf at 2020-04-02T01:46:34-04:00
Preserve precise exceptions in strictness analysis

Fix #13380 and #17676 by

1. Changing `raiseIO#` to have `topDiv` instead of `botDiv`
2. Give it special treatment in `Simplifier.Util.mkArgInfo`, treating it
   as if it still had `botDiv`, to recover dead code elimination.

This is the first commit of the plan outlined in
https://gitlab.haskell.org/ghc/ghc/-/merge_requests/2525#note_260886.

- - - - -
0a88dd11 by Ömer Sinan Ağacan at 2020-04-02T01:47:25-04:00
Fix a pointer format string in RTS

- - - - -
5beac042 by Ömer Sinan Ağacan at 2020-04-02T01:48:05-04:00
Remove unused closure stg_IND_direct

- - - - -
88f38b03 by Ben Gamari at 2020-04-02T01:48:42-04:00
Session: Memoize stderrSupportsAnsiColors

Not only is this a reasonable efficiency measure but it avoids making
reentrant calls into ncurses, which is not thread-safe. See #17922.

- - - - -
27740f24 by Ryan Scott at 2020-04-02T01:49:21-04:00
Make Hadrian build with Cabal-3.2

GHC 8.10 ships with `Cabal-3.2.0.0`, so it would be convenient to
make Hadrian supporting building against 3.2.* instead of having to
rebuild the entirety of `Cabal-3.0.0.0`. There is one API change in
`Cabal-3.2.*` that affects Hadrian: the `synopsis` and `description`
functions now return `ShortText` instead of `String`. Since Hadrian
manipulates these `String`s in various places, I found that the
simplest fix was to use CPP to convert `ShortText` to `String`s
where appropriate.

- - - - -
49802002 by Sylvain Henry at 2020-04-02T01:50:00-04:00
Update Stack resolver for hadrian/build-stack

Broken by 57b888c0e90be7189285a6b078c30b26d0923809

- - - - -
30a63e79 by Ryan Scott at 2020-04-02T01:50:36-04:00
Fix two ASSERT buglets in reifyDataCon

Two `ASSERT`s in `reifyDataCon` were always using `arg_tys`, but
`arg_tys` is not meaningful for GADT constructors. In fact, it's
worse than non-meaningful, since using `arg_tys` when reifying a
GADT constructor can lead to failed `ASSERT`ions, as #17305
demonstrates.

This patch applies the simplest possible fix to the immediate
problem. The `ASSERT`s now use `r_arg_tys` instead of `arg_tys`, as
the former makes sure to give something meaningful for GADT
constructors. This makes the panic go away at the very least. There
is still an underlying issue with the way the internals of
`reifyDataCon` work, as described in
https://gitlab.haskell.org/ghc/ghc/issues/17305#note_227023, but we
leave that as future work, since fixing the underlying issue is
much trickier (see
https://gitlab.haskell.org/ghc/ghc/issues/17305#note_227087).

- - - - -
38c072c7 by Andreas Klebinger at 2020-04-02T12:03:13+02:00
Move windows RTS timers to a QueryPerformanceCounter based API.

This code was initially part of WINIO and the initial version
was written by Phyx (Tamar Christina).

- - - - -


30 changed files:

- .ghcid
- .gitlab-ci.yml
- .gitlab/ci.sh
- .gitlab/linters/check-cpp.py
- compiler/GHC.hs
- 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/BlockId.hs-boot
- compiler/GHC/Cmm/CLabel.hs
- compiler/GHC/Cmm/CallConv.hs
- compiler/GHC/Cmm/CommonBlockElim.hs
- compiler/GHC/Cmm/Dataflow.hs
- compiler/GHC/Cmm/Dataflow/Block.hs
- compiler/GHC/Cmm/Dataflow/Label.hs
- compiler/GHC/Cmm/DebugBlock.hs
- compiler/GHC/Cmm/Expr.hs
- compiler/GHC/Cmm/Graph.hs
- compiler/GHC/Cmm/Info.hs
- compiler/GHC/Cmm/Info/Build.hs
- compiler/GHC/Cmm/LayoutStack.hs
- compiler/GHC/Cmm/Lexer.x
- compiler/GHC/Cmm/Lint.hs
- compiler/GHC/Cmm/MachOp.hs
- compiler/GHC/Cmm/Node.hs
- compiler/GHC/Cmm/Opt.hs


The diff was not included because it is too large.


View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/dbc9e1eac851a4657c067f94efd31419216a144e...38c072c70de8272c009f7bb36a9cf6713afde94d

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/dbc9e1eac851a4657c067f94efd31419216a144e...38c072c70de8272c009f7bb36a9cf6713afde94d
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/20200402/8977b38e/attachment-0001.html>


More information about the ghc-commits mailing list