ghc.git
9 months agoFix some test wibbles wip/T14880-2-step2-c123
Tobias Dammers [Fri, 12 Oct 2018 09:22:40 +0000 (11:22 +0200)] 
Fix some test wibbles

9 months agoClose over kinds exactly once per var (#14880)
Tobias Dammers [Thu, 13 Sep 2018 07:56:02 +0000 (09:56 +0200)] 
Close over kinds exactly once per var (#14880)

Summary:
As discussed in Trac:14880, comment:123, we have the issue that we want to
avoid processing the same var more than once. The original plan was to move
closing over kinds to the very end of the `tyCoVarsOfType` function, however,
this turns out to be inefficient and unnecessary.

Instead, we simply change the code in `ty_co_vars_of_type` such that
closing over kinds doesn't happen if we've already seen the var in question.

Test Plan: ./validate, nofib

Reviewers: simonpj, goldfire, bgamari

Subscribers: rwbarton, carter

GHC Trac Issues: #14880

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

9 months agoBugfix
Tobias Dammers [Mon, 10 Sep 2018 20:46:31 +0000 (22:46 +0200)] 
Bugfix

9 months agoUse an accumulator version of tyCoVarsOfType
Simon Peyton Jones [Fri, 31 Aug 2018 13:18:55 +0000 (14:18 +0100)] 
Use an accumulator version of tyCoVarsOfType

Summary:
This is part 1 from #14880: factor out a worker for the tyCoVarsOf... family of
function, implementing them in terms of VarSet, but with accumulator-style
(like in `FV`) built in, and with the same kind of pre-insert lookup; this
has shown to perform better than either FV or plain VarSet in this particular
scenario.

Original notes from simonpj:

In TyCoRep we now have tyCoVarsOfType implemented

1) Using FV -- this is the baseline version in GHC today

2) Using VarSets via unionVarSet

3) Using VarSets in accumulator-style

In this patch (3) is enabled.

When compiling perf/compiler/T5631 we get

         Compiler allocs
   (1)   1,144M
   (2)   1,175M
   (3)   1,142M

The key new insight in (3) is this:

  ty_co_vars_of_type (TyVarTy v) is acc
    | v `elemVarSet` is  = acc
    | v `elemVarSet` acc = acc   <---- NB!
    | otherwise          = ty_co_vars_of_type (tyVarKind v) is (extendVarSet acc v)

Notice the second line! If the variable is already in the
accumulator, don't re-add it.  This makes big difference.
Without it, allocation is 1,169M or so.

One cause is that we only take the free vars of its kind once;
that problem will go away when we do the main part of #14088 and
close over kinds /afterwards/.  But still, another cause is perhaps
that every insert into a set overwrites the previous item, and so
allocates a new path to the item; it's not a no-op even if the
item is there already.

Why use (3) rather than (1)?  Becuase it just /has/ to
be better;

* FV carries around an InterestingVarFun, which does nothing
  useful here, but is tested at every variable

* FV carries around a [Var] for the deterministic version.

For this very hot operation (finding free vars) I think it
makes sense to have speical purpose code.

On the way I also simplified the (less used) coVarsOfType/Co family
to use FV, by making serious use of the InterestingVarFun!

Test Plan: validate, nofib

Reviewers: simonpj, bgamari

Subscribers: rwbarton, carter

GHC Trac Issues: #14880

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

9 months agoDocument TyCoRep changes better
Tobias Dammers [Wed, 10 Oct 2018 12:01:52 +0000 (14:01 +0200)] 
Document TyCoRep changes better

9 months agoRemove commented-out code, turn it into Note text instead.
Tobias Dammers [Mon, 8 Oct 2018 07:53:01 +0000 (09:53 +0200)] 
Remove commented-out code, turn it into Note text instead.

9 months agoUse an accumulator version of tyCoVarsOfType
Simon Peyton Jones [Fri, 31 Aug 2018 13:18:55 +0000 (14:18 +0100)] 
Use an accumulator version of tyCoVarsOfType

Summary:
This is part 1 from #14880: factor out a worker for the tyCoVarsOf... family of
function, implementing them in terms of VarSet, but with accumulator-style
(like in `FV`) built in, and with the same kind of pre-insert lookup; this
has shown to perform better than either FV or plain VarSet in this particular
scenario.

Original notes from simonpj:

In TyCoRep we now have tyCoVarsOfType implemented

1) Using FV -- this is the baseline version in GHC today

2) Using VarSets via unionVarSet

3) Using VarSets in accumulator-style

In this patch (3) is enabled.

When compiling perf/compiler/T5631 we get

         Compiler allocs
   (1)   1,144M
   (2)   1,175M
   (3)   1,142M

The key new insight in (3) is this:

  ty_co_vars_of_type (TyVarTy v) is acc
    | v `elemVarSet` is  = acc
    | v `elemVarSet` acc = acc   <---- NB!
    | otherwise          = ty_co_vars_of_type (tyVarKind v) is (extendVarSet acc v)

Notice the second line! If the variable is already in the
accumulator, don't re-add it.  This makes big difference.
Without it, allocation is 1,169M or so.

One cause is that we only take the free vars of its kind once;
that problem will go away when we do the main part of #14088 and
close over kinds /afterwards/.  But still, another cause is perhaps
that every insert into a set overwrites the previous item, and so
allocates a new path to the item; it's not a no-op even if the
item is there already.

Why use (3) rather than (1)?  Becuase it just /has/ to
be better;

* FV carries around an InterestingVarFun, which does nothing
  useful here, but is tested at every variable

* FV carries around a [Var] for the deterministic version.

For this very hot operation (finding free vars) I think it
makes sense to have speical purpose code.

On the way I also simplified the (less used) coVarsOfType/Co family
to use FV, by making serious use of the InterestingVarFun!

Test Plan: validate, nofib

Reviewers: simonpj, bgamari

Subscribers: rwbarton, carter

GHC Trac Issues: #14880

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

9 months agoMake GHC (the library) flexible in the choice of integer library
Joachim Breitner [Wed, 3 Oct 2018 13:36:55 +0000 (15:36 +0200)] 
Make GHC (the library) flexible in the choice of integer library

Summary:
We have more and more users of GHC as a library, for example the
Haskell-to-WebAssembly-compiler https://github.com/tweag/asterius.
These need to make different decisions about various aspects of
code generation than the host compiler, and ideally GHC-the-library
allows them to set the `DynFlags` as needed.

This patch adds a new `DynFlag` that configures which `integer`
library to use. This flag is initialized by `cIntegerLibraryType`
(as before), and is only used in `CorePrep` to decide whether to
use `S#` or not.

The other code paths that were varying based on `cIntegerLibraryType`
are no now longer varying: The trick is to use `integer-wired-in`
as the `-this-unit-id` when compiling either `integer-gmp` or
`integer-simple`.

Test Plan: Validate is happy.

Reviewers: hvr, bgamari

Reviewed By: bgamari

Subscribers: TerrorJack, adamse, simonpj, rwbarton, carter

GHC Trac Issues: #13477

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

9 months agodistrib: Remove mention of no-longer-existent make target
Ben Gamari [Wed, 3 Oct 2018 13:35:32 +0000 (15:35 +0200)] 
distrib: Remove mention of no-longer-existent make target

Summary:
`show-install-setup` used to be defined by `distrib/Makefile` which hasn't been
used in a very long time and was removed from the tree in
a1c008b30fc60a327afe098cf16bd14ca1e5e381.

Reviewers: monoidal

Reviewed By: monoidal

Subscribers: rwbarton, carter

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

9 months agoDrop accidental write-attributes request
Tamar Christina [Wed, 3 Oct 2018 13:34:56 +0000 (15:34 +0200)] 
Drop accidental write-attributes request

Summary:
The new filesystem code accidentally asks for write attributes
permissions when doing read-only access.

I believe this is what's causing the GHC 8.6.1 tarballs to fail
when installed to a privileged location.
I haven't been able to reproduce the issue yet, but this permission
bit is wrong anyway.

Test Plan: I'm still trying to workout how to test that this works,
changing the permissions on the folder doesn't seem to reproduce
the error on a tarball I made from before the change.

Reviewers: bgamari, tdammers

Reviewed By: bgamari

Subscribers: tdammers, monoidal, rwbarton, carter

GHC Trac Issues: #15667

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

9 months agoDrop GHC 8.2 compatibility
Ryan Scott [Wed, 3 Oct 2018 12:41:56 +0000 (08:41 -0400)] 
Drop GHC 8.2 compatibility

Summary:
GHC 8.6.1 is out, so now GHC's support window only extends
back to GHC 8.4. This means we can delete gobs of code that were
only used for GHC 8.2 support. Hooray!

Test Plan: ./validate

Reviewers: bgamari, Phyx, erikd

Reviewed By: bgamari, Phyx

Subscribers: rwbarton, erikd, carter

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

9 months agoGHCi should not filter instances involving cTuples
Alec Theriault [Tue, 2 Oct 2018 12:48:00 +0000 (14:48 +0200)] 
GHCi should not filter instances involving cTuples

Summary: See the new T12005 test case for an example of this.

Test Plan: make TEST=T12005

Reviewers: bgamari, osa1

Reviewed By: osa1

Subscribers: osa1, rwbarton, carter

GHC Trac Issues: #12005

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

9 months agorts.cabal.in: add more flags to control the extra flavours (for hadrian)
Alp Mestanogullari [Tue, 2 Oct 2018 12:46:28 +0000 (14:46 +0200)] 
rts.cabal.in: add more flags to control the extra flavours (for hadrian)

Summary:
In order to properly honor the different ways in which the RTS must
be built by hadrian, and in particular to have fine grained control over that,
I'm introducing new Cabal flags in rts.cabal[.in]. This should not affect the
make build system and will only be used and picked up by hadrian, which uses
Cabal directly to operate on cabal packages, including libHSrts.

Reviewers: bgamari, erikd, simonmar

Reviewed By: bgamari

Subscribers: rwbarton, carter

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

9 months agoresolve T13704
chessai [Tue, 2 Oct 2018 12:46:08 +0000 (14:46 +0200)] 
resolve T13704

Summary: allow -main-is to change export list for default module
header, allowing one to change the entry point to one's program.

Test Plan: ./validate

Reviewers: bgamari, nomeata, mpickering

Reviewed By: mpickering

Subscribers: mpickering, rwbarton, carter

GHC Trac Issues: #13704

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

9 months agocircleci: Create missing test-results directory
Ben Gamari [Tue, 2 Oct 2018 13:16:27 +0000 (09:16 -0400)] 
circleci: Create missing test-results directory

9 months agoQuantify class variables first in associated families' kinds
Ryan Scott [Mon, 1 Oct 2018 16:05:12 +0000 (12:05 -0400)] 
Quantify class variables first in associated families' kinds

Summary:
Previously, `kcLHsQTyVars` would always quantify class-bound
variables invisibly in the kinds of associated types, resulting in
#15591. We counteract this by explicitly passing the class-bound
variables to `kcLHsQTyVars` and quantifying over the ones that are
mentioned in the associated type such that (1) they are specified,
and (2) they come before other kind variables.
See `Note [Kind variable ordering for associated types]`.

Test Plan: make test TEST=T15591

Reviewers: goldfire, simonpj, bgamari

Reviewed By: simonpj

Subscribers: rwbarton, carter

GHC Trac Issues: #15591

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

9 months agoFix #15637 by using VTA more in GND
Ryan Scott [Mon, 1 Oct 2018 16:00:52 +0000 (12:00 -0400)] 
Fix #15637 by using VTA more in GND

Summary:
The code that GND was generating before could crumple over
if it derived an instance for a class with an ambiguous type variable
in the class head, such as the example in #15637. The solution is
straightforward: simply instantiate all variables bound by the class
head explicitly using visible type application, which will nip any
ambiguity in the bud.

Test Plan: make test TEST=T15637

Reviewers: bgamari, simonpj, goldfire

Reviewed By: simonpj

Subscribers: simonpj, rwbarton, carter

GHC Trac Issues: #15637

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

9 months agocircleci: Run slowtest with multiple threads
Ben Gamari [Mon, 1 Oct 2018 15:46:54 +0000 (11:46 -0400)] 
circleci: Run slowtest with multiple threads

9 months agoghc-prim: Fix typo in traceBinaryEvent# changelog entry
Ben Gamari [Thu, 27 Sep 2018 22:46:53 +0000 (18:46 -0400)] 
ghc-prim: Fix typo in traceBinaryEvent# changelog entry

9 months agoghc-prim: Add missing changelog entry
Ben Gamari [Thu, 27 Sep 2018 22:46:37 +0000 (18:46 -0400)] 
ghc-prim: Add missing changelog entry

9 months agoprimops: Fix documentation of compactAllocateBlock#
Ben Gamari [Wed, 26 Sep 2018 20:03:44 +0000 (16:03 -0400)] 
primops: Fix documentation of compactAllocateBlock#

Pointed out by @andrewthad.

9 months agoghc-bin.cabal.in: add a 'threaded' flag for hadrian
Alp Mestanogullari [Mon, 1 Oct 2018 13:14:23 +0000 (15:14 +0200)] 
ghc-bin.cabal.in: add a 'threaded' flag for hadrian

Summary:
hadrian will explicitly enable this flag, but more importantly needs it
as otherwise we just never end up passing -threaded to GHC when building
a new GHC binary. We could quite likely unconditionally pass -threaded,
as the corresponding logic for GhcThreaded in mk/config.mk.in seems to
always lead to it being set to True, but we instead leave a way out for
anyone in need of a GHC linked against a non-threaded runtime system in
the future.

Test Plan: T8242 (with a GHC built by hadrian)

Reviewers: bgamari

Reviewed By: bgamari

Subscribers: rwbarton, carter

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

9 months agoCodeGen: Teach CodeGen about aliasing of XMM/YMM/ZMM registers
Ben Gamari [Mon, 1 Oct 2018 13:13:32 +0000 (15:13 +0200)] 
CodeGen: Teach CodeGen about aliasing of XMM/YMM/ZMM registers

Reviewers: simonmar

Reviewed By: simonmar

Subscribers: rwbarton, carter

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

9 months agoAlways check the relocation value for x86_64
Zejun Wu [Mon, 1 Oct 2018 13:12:29 +0000 (15:12 +0200)] 
Always check the relocation value for x86_64

Summary:
Always check that no overflow happens during relocation for x86_64.
It's not safe to assume the result returned by `ocAllocateSymbolExtras` is
always valid if we allocate it neither in lower 2G nor in a contiguous range
with the image.

There are also some minor fixes in this diff:

* `off >= 0x7fffffffL` should be `>`
* use of unaligned pointer is undefined behavior, use `memcpy` instead, gcc
  will be able to optimize it to `mov %edx, (%rax)`.

Test Plan:
build ghci with:

```
DYNAMIC_GHC_PROGRAMS = NO
DYNAMIC_BY_DEFAULT = NO
```

and play with it.

  ./validate

Reviewers: simonmar, austin, bgamari, erikd

Reviewed By: simonmar

Subscribers: alpmestan, rwbarton, carter

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

9 months agoAdd -fkeep-cafs
Simon Marlow [Fri, 28 Sep 2018 12:27:22 +0000 (14:27 +0200)] 
Add -fkeep-cafs

Summary:
I noticed while playing around with
https://github.com/fbsamples/ghc-hotswap/ that the main binary needs to
have a custom main function to set `config.keep_cafs = true` when
initialising the runtime. This is pretty annoying, it means an extra
C file with some cryptic incantations in it, and a `-no-hs-main` flag.

So I've replaced this with a link-time flag to GHC, `-fkeep-cafs` that
does the same thing.

Test Plan:
New unit test that tests for the RTS's GC'd CAFs assertion, and also
the -keep-cafs flag.

Reviewers: bgamari, osa1, erikd, noamz

Reviewed By: osa1

Subscribers: rwbarton, carter

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

9 months agoExpose wopt_set/unset_fatal in DynFlags
Neil Mitchell [Wed, 26 Sep 2018 09:58:38 +0000 (10:58 +0100)] 
Expose wopt_set/unset_fatal in DynFlags

PR: https://github.com/ghc/ghc/pull/199/

9 months agoNormalise EmptyCase types using the constraint solver
Ryan Scott [Fri, 28 Sep 2018 12:22:48 +0000 (14:22 +0200)] 
Normalise EmptyCase types using the constraint solver

Summary:
Certain `EmptyCase` expressions were mistakently producing
warnings since their types did not have as many type families reduced
as they could have. The most direct way to fix this is to normalise
these types initially using the constraint solver to solve for any
local equalities that may be in scope.

Test Plan: make test TEST=T14813

Reviewers: simonpj, bgamari, goldfire

Reviewed By: simonpj

Subscribers: rwbarton, carter

GHC Trac Issues: #14813

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

9 months agoFix for recover with -fexternal-interpreter (#15418)
Simon Marlow [Wed, 26 Sep 2018 20:32:29 +0000 (15:32 -0500)] 
Fix for recover with -fexternal-interpreter (#15418)

Summary:
When using -fexternal-interpreter, recover was not treating a Q
compuation that simply registered an error with addErrTc as failing.

Test Plan:
New unit tests:
* T15418 is the repro from in the ticket
* TH_recover_warns is a new test to ensure that we're keeping warnings when
  the body of recover succeeds.

Reviewers: bgamari, RyanGlScott, angerman, goldfire, erikd

Subscribers: rwbarton, carter

GHC Trac Issues: #15418

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

9 months agousers' guide: document -freverse-errors
quasicomputational [Wed, 26 Sep 2018 09:57:38 +0000 (10:57 +0100)] 
users' guide: document -freverse-errors

9 months agoFix constant-folding for Integer shifts
Simon Peyton Jones [Wed, 26 Sep 2018 03:29:19 +0000 (04:29 +0100)] 
Fix constant-folding for Integer shifts

In this patch
    commit 869f69fd4a78371c221e6d9abd69a71440a4679a
    Author: Simon Peyton Jones <simonpj@microsoft.com>
    Date:   Wed Dec 11 18:19:34 2013 +0000

    Guarding against silly shifts

we deal with silly shifts like (Sll 1 9223372036854775807).  But
I only dealt with primops that Int# and Word#.

Alas, the same problem affects shifts of Integer, as Trac #15673
showed.  Fortunately, the problem is easy to fix.

9 months agoFix Lint of unsaturated type families
Simon Peyton Jones [Tue, 25 Sep 2018 14:19:22 +0000 (15:19 +0100)] 
Fix Lint of unsaturated type families

GHC allows types to have unsaturated type synonyms and type families,
provided they /are/ saturated if you expand all type synonyms.

TcValidity carefully checked this; see check_syn_tc_app.  But
Lint only did half the job, adn that led to Trac #15664.

This patch just teaches Core Lint to be as clever as TcValidity.

9 months agoExpand the Note on let-bound skolems
Simon Peyton Jones [Sun, 23 Sep 2018 14:23:09 +0000 (15:23 +0100)] 
Expand the Note on let-bound skolems

9 months agoAdd regression test for #15666
Ryan Scott [Tue, 25 Sep 2018 12:33:06 +0000 (08:33 -0400)] 
Add regression test for #15666

Commit 59f38587d44efd00b10a6d98f6a7a1b22e87f13a ended up
fixing #15666. Let's add a regression test to ensure that it stays
fixed.

9 months agoDon't show constraint tuples in errors (#14907)
Alec Theriault [Tue, 25 Sep 2018 09:58:12 +0000 (11:58 +0200)] 
Don't show constraint tuples in errors (#14907)

Summary:
This means that 'GHC.Classes.(%,%)' is no longer mentioned in
error messages for things like

   class (a,b,c)  -- outside of 'GHC.Classes'
   class (a,Bool)

Test Plan: make TEST=T14907a && make TEST=T14907b

Reviewers: RyanGlScott, bgamari

Reviewed By: RyanGlScott

Subscribers: rwbarton, carter

GHC Trac Issues: #14907

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

9 months agoaclocal.m4: fix shell comment syntax: '#', not '$'
Sergei Trofimovich [Tue, 25 Sep 2018 09:57:35 +0000 (11:57 +0200)] 
aclocal.m4: fix shell comment syntax: '#', not '$'

Summary:
Reported-by: Evan Laforge
Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
Reviewers: bgamari

Subscribers: rwbarton, erikd, carter

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

9 months agoFix a MSG_BLACKHOLE sanity check, add some comments
Ömer Sinan Ağacan [Mon, 24 Sep 2018 13:21:27 +0000 (16:21 +0300)] 
Fix a MSG_BLACKHOLE sanity check, add some comments

Reviewers: simonmar, bgamari, erikd

Reviewed By: simonmar

Subscribers: rwbarton, carter

GHC Trac Issues: #15508

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

9 months agoAdd a recursivity check in nonVoid
Ryan Scott [Sun, 23 Sep 2018 12:15:13 +0000 (08:15 -0400)] 
Add a recursivity check in nonVoid

Summary:
Previously `nonVoid` outright refused to call itself
recursively to avoid the risk of hitting infinite loops when
checking recurisve types. But this is too conservative—we //can//
call `nonVoid` recursively as long as we incorporate a way to detect
the presence of recursive types, and bail out if we do detect one.
Happily, such a mechanism already exists in the form of `checkRecTc`,
so let's use it.

Test Plan: make test TEST=T15584

Reviewers: simonpj, bgamari

Reviewed By: simonpj

Subscribers: rwbarton, carter

GHC Trac Issues: #15584

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

9 months agoFix get getIdFromTrivialExpr
Simon Peyton Jones [Sat, 22 Sep 2018 23:44:14 +0000 (00:44 +0100)] 
Fix get getIdFromTrivialExpr

This bug, discovered by Trac #15325, has been lurking since

  commit 1c9fd3f1c5522372fcaf250c805b959e8090a62c
  Author: Simon Peyton Jones <simonpj@microsoft.com>
  Date:   Thu Dec 3 12:57:54 2015 +0000

    Case-of-empty-alts is trivial (Trac #11155)

I'd forgotttnen to modify getIdFromTrivialExpr when I
modified exprIsTrivial.   Easy to fix, though.

9 months agoComments only
Simon Peyton Jones [Thu, 20 Sep 2018 19:05:05 +0000 (20:05 +0100)] 
Comments only

9 months agoDon't look up unnecessary return in LastStmt
Simon Peyton Jones [Thu, 20 Sep 2018 19:02:39 +0000 (20:02 +0100)] 
Don't look up unnecessary return in LastStmt

This fixes Trac #15607. The general pattern is well
established (e.g. see the guard_op binding in rnStmt
of BodyStme), but we weren't using it for LastStmt.

9 months agoBuglet in reporting out of scope errors in rules
Simon Peyton Jones [Thu, 20 Sep 2018 18:53:56 +0000 (19:53 +0100)] 
Buglet in reporting out of scope errors in rules

Most out of scope errors get reported by the type checker these
days, but not all.  Example, the function on the LHS of a RULE.

Trace #15659 pointed out that this less-heavily-used code path
produce a "wacky" error message.  Indeed so.  Easily fixed.

9 months agotestsuite: Bump T9630 expected allocations
Ben Gamari [Sat, 22 Sep 2018 15:12:59 +0000 (11:12 -0400)] 
testsuite: Bump T9630 expected allocations

This failed on Darwin.

9 months agotestsuite: Bump expected allocations for T12707
Ben Gamari [Fri, 21 Sep 2018 22:51:38 +0000 (18:51 -0400)] 
testsuite: Bump expected allocations for T12707

9 months agotestsuite: Bump expected allocations of T9675
Ben Gamari [Fri, 21 Sep 2018 20:24:32 +0000 (16:24 -0400)] 
testsuite: Bump expected allocations of T9675

This inexplicably started with 989dca6cbd93, which appears to be a bump of the
`text` submodule. This is very fishy so I've opened #15663 to ensure we
investigate.

9 months agotestsuite: Fix readFail048 and readFail032 brokenness declarations
Ben Gamari [Fri, 21 Sep 2018 20:18:08 +0000 (16:18 -0400)] 
testsuite: Fix readFail048 and readFail032 brokenness declarations

Whoops.

9 months agotestsuite: Mark readFail032 and readFail048 as broken on Darwin
Ben Gamari [Fri, 21 Sep 2018 16:16:35 +0000 (12:16 -0400)] 
testsuite: Mark readFail032 and readFail048 as broken on Darwin

It looks like Clang's CPP implementation has an off-by-one error here.

9 months agotestsuite: Don't force run of llvm ways in T14251
Ben Gamari [Fri, 21 Sep 2018 15:44:35 +0000 (11:44 -0400)] 
testsuite: Don't force run of llvm ways in T14251

This breaks if LLVM is not available.

9 months agoRemove redundant slop zeroing
Ömer Sinan Ağacan [Fri, 21 Sep 2018 07:08:18 +0000 (10:08 +0300)] 
Remove redundant slop zeroing

OVERWRITE_INFO already does zero slopping by calling OVERWRITING_CLOSURE

9 months agoFix slop zeroing for AP_STACK eager blackholes in debug build
Ömer Sinan Ağacan [Fri, 21 Sep 2018 06:33:38 +0000 (09:33 +0300)] 
Fix slop zeroing for AP_STACK eager blackholes in debug build

As #15571 reports, eager blackholing breaks sanity checks as we can't
zero the payload when eagerly blackholing (because we'll be using the
payload after blackholing), but by the time we blackhole a previously
eagerly blackholed object (in `threadPaused()`) we don't have the
correct size information for the object (because the object's type
becomes BLACKHOLE when we eagerly blackhole it) so can't properly zero
the slop.

This problem can be solved for AP_STACK eager blackholing (which unlike
eager blackholing in general, is not optional) by zeroing the payload
after entering the stack. This patch implements this idea.

Fixes #15571.

Test Plan:
Previously concprog001 when compiled and run with sanity checks

    ghc-stage2 Mult.hs -debug -rtsopts
    ./Mult +RTS -DS

was failing with

    Mult: internal error: checkClosure: stack frame
        (GHC version 8.7.20180821 for x86_64_unknown_linux)
        Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug

thic patch fixes this panic. The test still panics, but it runs for a while
before panicking (instead of directly panicking as before), and the new problem
seems unrelated:

    Mult: internal error: ASSERTION FAILED: file rts/sm/Sanity.c, line 296
        (GHC version 8.7.20180919 for x86_64_unknown_linux)
        Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug

The new problem will be fixed in another diff.

I also tried slow validate (which requires D5164): this does not introduce any
new failures.

Reviewers: simonmar, bgamari, erikd

Reviewed By: simonmar

Subscribers: rwbarton, carter

GHC Trac Issues: #15571

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

9 months agouser-guide: Allow build with sphinx < 1.8
Ben Gamari [Thu, 20 Sep 2018 21:35:05 +0000 (17:35 -0400)] 
user-guide: Allow build with sphinx < 1.8

Apparently the override argument to add_directive_to_domain was added in sphinx
1.8.

9 months agousers_guide: fix sphinx error caused by non-explicit override
Zejun Wu [Thu, 20 Sep 2018 20:05:28 +0000 (16:05 -0400)] 
users_guide: fix sphinx error caused by non-explicit override

Encouter following error when `make`:

```
Extension error:
The 'ghc-flag' directive is already registered to domain std
```

as we register `ghc-flag` to `std` in `add_object_type` first and then
overtride it in `add_directive_to_domain`.

Test Plan:
  make -C utils/haddock/doc html SPHINX_BUILD=/usr/bin/sphinx-build

Reviewers: austin, bgamari, patrickdoc

Subscribers: rwbarton, carter

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

9 months agousers-guide: Fix build with sphinx 1.8
Ben Gamari [Thu, 20 Sep 2018 12:27:37 +0000 (08:27 -0400)] 
users-guide: Fix build with sphinx 1.8

It seems that both add_object_type and add_directive_to_domain both register a
directive. Previously sphinx didn't seem to mind this but as of Sphinx 1.8 it
crashes with an exception.

9 months agoRevert "adds -latomic to. ghc-prim"
Ben Gamari [Wed, 19 Sep 2018 19:23:27 +0000 (15:23 -0400)] 
Revert "adds -latomic to. ghc-prim"

This commit was never properly justified and relies on the existence of
libatomic, which doesn't appear to exist on Darwin.

This reverts commit ec9aacf3eb2975fd302609163aaef429962ecd87.

9 months agoAdd testcase for #14251
Ben Gamari [Wed, 19 Sep 2018 19:04:11 +0000 (15:04 -0400)] 
Add testcase for #14251

9 months agousers guide: Fix a few issues
Frank Steffahn [Tue, 21 Aug 2018 21:37:33 +0000 (23:37 +0200)] 
users guide: Fix a few issues

9 months agoRemove -Waggregate-return when building RTS
Ömer Sinan Ağacan [Thu, 20 Sep 2018 13:04:11 +0000 (16:04 +0300)] 
Remove -Waggregate-return when building RTS

This causes slow validate build to fail (in Profiling.c:countTickss), and
there's nothing wrong with struct returns.

Reviewers: simonmar, bgamari, erikd

Subscribers: rwbarton, carter

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

9 months agoUse predefined known-key names when possible
Chaitanya Koparkar [Wed, 19 Sep 2018 07:19:53 +0000 (09:19 +0200)] 
Use predefined known-key names when possible

Summary:
For certain entities in 'PrelNames', we were creating new 'Name's
instead of reusing the ones already defined. Easily fixed.

Test Plan: ./validate

Reviewers: dfeuer, RyanGlScott, bgamari, simonpj

Reviewed By: simonpj

Subscribers: simonpj, rwbarton, carter

GHC Trac Issues: #13279

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

9 months agodocs: fix example code
john [Mon, 17 Sep 2018 06:21:39 +0000 (06:21 +0000)] 
docs: fix example code

PR: https://github.com/ghc/ghc/pull/197/

9 months agoDon't shortcut SRTs for static functions (#15544)
Simon Marlow [Tue, 18 Sep 2018 15:47:56 +0000 (11:47 -0400)] 
Don't shortcut SRTs for static functions (#15544)

Shortcutting the SRT for a static function can lead to resurrecting a
static object at runtime, which violates assumptions in the GC. See
comments for details.

Test Plan:
- manual testing (in progress)
- validate

Reviewers: osa1, bgamari, erikd

Reviewed By: bgamari

Subscribers: rwbarton, carter

GHC Trac Issues: #15544

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

9 months agoBump deepseq submodule
Ben Gamari [Sun, 16 Sep 2018 20:56:16 +0000 (16:56 -0400)] 
Bump deepseq submodule

(cherry picked from commit c4209ba8a448b501a11d66640d280fe1e194f847)

9 months agoBump text submodule
Ben Gamari [Sun, 16 Sep 2018 20:55:21 +0000 (16:55 -0400)] 
Bump text submodule

(cherry picked from commit a512f1e32bd4d6079559e3172522591863321fe7)

9 months agoBump stm submodule
Ben Gamari [Sun, 16 Sep 2018 20:51:53 +0000 (16:51 -0400)] 
Bump stm submodule

(cherry picked from commit f458bca3a9667af95b8782747eab5b0e70cba4b4)

9 months agoInvert FP conditions to eliminate the explicit NaN check.
klebinger.andreas@gmx.at [Tue, 18 Sep 2018 15:46:38 +0000 (17:46 +0200)] 
Invert FP conditions to eliminate the explicit NaN check.

Summary:
Optimisation: we don't have to test the parity flag if we
know the test has already excluded the unordered case: eg >
and >= test for a zero carry flag, which can only occur for
ordered operands.

By reversing comparisons we can avoid testing the parity
for < and <= as well. This works since:
* If any of the arguments is an NaN CF gets set. Resulting in a false result.
* Since this allows us to rule out NaN we can exchange the arguments and invert the
  direction of the arrows.

Test Plan: ci/nofib

Reviewers: carter, bgamari, alpmestan

Reviewed By: alpmestan

Subscribers: alpmestan, simonpj, jmct, rwbarton, thomie

GHC Trac Issues: #15196

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

9 months agoFix check whether GCC supports __atomic_ builtins
Ilias Tsitsimpis [Tue, 18 Sep 2018 15:45:17 +0000 (17:45 +0200)] 
Fix check whether GCC supports __atomic_ builtins

Summary:
C11 atomics are never used because:

* The program used for checking whether GCC supports
__atomic_ builtins fails with the following error:

```
  error: size mismatch in argument 2 of `__atomic_load`
   int test(int *x) { int y; __atomic_load(&x, &y, __ATOMIC_SEQ_CST); return x; }
```

* There is a typo when checking if CONF_GCC_SUPPORTS__ATOMICS equals YES,
resulting in PRIM_CFLAGS and PRIM_EXTRA_LIBRARIES never being set.

Reviewers: bgamari

Reviewed By: bgamari

Subscribers: rwbarton, erikd, carter

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

9 months agoNoImplicitPrelude in ghc-boot-th, ghc-boot, ghc-heap, ghci
Shayne Fletcher [Tue, 21 Aug 2018 11:58:16 +0000 (07:58 -0400)] 
NoImplicitPrelude in ghc-boot-th, ghc-boot, ghc-heap, ghci

PR: https://github.com/ghc/ghc/pull/184

9 months agoUsers guide: EmptyDataDecls on by default
Chris Martin [Thu, 30 Aug 2018 17:23:59 +0000 (13:23 -0400)] 
Users guide: EmptyDataDecls on by default

10 months agoUpdated PE linker, section alignment and cleanup.
Tamar Christina [Mon, 17 Sep 2018 21:06:05 +0000 (22:06 +0100)] 
Updated PE linker, section alignment and cleanup.

Summary:
This patch is to address a couple of short comings of the PE linker.

The first thing it does is properly honor section alignments, so SSE code
will work reliably.

While doing this I've also changed how it reads and stores ObjectFile
information. Previously the entire object file was read in and treated
as one blob, including headers, symbol tables etc.

Now the ObjectFile is read in but stored in chunks, tables go into a temporary
info struct and code/data into a new private heap. This allows me to free all
meta data once we're done relocating. Which means we can reclaim this memory.

As I've mentioned above I've also moved from using VirtualAlloc to HeapAlloc.
The reason is VirtualAlloc is meant to be used for more low level memory
allocation, it's very fast because it can only allocate whole blocks,
(64k) by default, and the memory must be paged (4k) aligned.

So when you ask for e.g. 30k of memory, you're given a whole block where 34k
will be wasted memory. Nothing else can ever access that untill you free the 30k.

One downside of HeapAlloc is that you're not in control of how the heap grows,
and heap memory is always committed. So it's harder to tell how much we're
actually using now.

Another big upside of splitting off the ObjectCode tables to info structs
is that I can adjust them, so that later addressings can just use array
subscripts to index into them. This simplifies the code a lot and a lot of
complicated casts and indexing can be removed. Leaving less and more simple
code.

This patch doesn't fix the memprotection but it doesn't regress it either.
It does however make the next changes smaller and fixes the alignments.

Test Plan: ./validate , new test T13617

Reviewers: bgamari, erikd, simonmar, hvr, angerman

Reviewed By: angerman

Subscribers: nickkuk, carter, RyanGlScott, rwbarton, thomie

GHC Trac Issues: #13617

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

10 months agoMake sure forM_ and related functions fuse cleanly
Sebastian Graf [Mon, 17 Sep 2018 19:11:09 +0000 (21:11 +0200)] 
Make sure forM_ and related functions fuse cleanly

Summary:
It was revealed in #8763 that it's hard to come up with a list fusion
helper for `efdtIntFB` that doesn't duplicated occurrences of `c`,
which is crucial in guaranteeing that it is inlined.

Not inlining `c` led to spoiled join points, in turn leading to unnecessary
heap allocation. This patch tackles the problem from a different angle:
Fixing all consumers instead of the less often used producer
`efdtIntFB` by inserting an INLINE pragma in the appropriate places.
See https://ghc.haskell.org/trac/ghc/ticket/8763#comment:76 and the new
Note [List fusion and continuations in 'c'].

A quick run of NoFib revealed no regression or improvements whatsoever.

Reviewers: hvr, bgamari, simonpj

Reviewed By: simonpj

Subscribers: simonpj, rwbarton, carter

GHC Trac Issues: #8763

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

10 months agousers-guide: Fix code-block layout for QuantifiedConstraints
Takenobu Tani [Mon, 17 Sep 2018 14:47:02 +0000 (16:47 +0200)] 
users-guide: Fix code-block layout for QuantifiedConstraints

Summary:
Fix code-block layout for QuantifiedConstraints.

[ci skip]

Test Plan: build

Reviewers: bgamari, monoidal

Reviewed By: monoidal

Subscribers: rwbarton, carter

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

10 months agobase: Add bangs to GHC.IO.Handle.Text hGet* functions
Ben Gamari [Mon, 17 Sep 2018 14:46:26 +0000 (16:46 +0200)] 
base: Add bangs to GHC.IO.Handle.Text hGet* functions

Summary:
I believe that demand analysis doesn't notice that these are morally strict in
the pointer argument due to the `count == 0` special case. Fixes #15638.

Test Plan: Validate

Reviewers: andrewthad, hvr

Reviewed By: andrewthad

Subscribers: rwbarton, carter

GHC Trac Issues: #15638

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

10 months agoStable name comment wibbles
David Feuer [Mon, 17 Sep 2018 14:46:05 +0000 (16:46 +0200)] 
Stable name comment wibbles

Summary:
Some comments in the `StableName` code still referred to
stable pointer details. Fix that.

Reviewers: bgamari, erikd, simonmar

Reviewed By: simonmar

Subscribers: rwbarton, carter

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

10 months agoFix for #13862: Optional "-v" not allowed with :load in GHCi
roland [Sun, 16 Sep 2018 16:06:13 +0000 (19:06 +0300)] 
Fix for #13862: Optional "-v" not allowed with :load in GHCi

Replace the error message
    `Use -v to see a list of the files searched for.`
with
    `Use -v (or :set -v` in ghci) to see a list of the files searched for.`

Reviewers: bgamari, monoidal, thomie, osa1

Subscribers: rwbarton, carter

GHC Trac Issues: #13862

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

10 months agoCorrect submodule update for haddock
Richard Eisenberg [Sat, 15 Sep 2018 19:41:39 +0000 (15:41 -0400)] 
Correct submodule update for haddock

Previous commit (Coercion Quantification) was missing a
commit on the haddock submodule. This (hopefully) corrects it.

10 months agoCoercion Quantification
ningning [Sat, 15 Sep 2018 14:16:47 +0000 (10:16 -0400)] 
Coercion Quantification

This patch corresponds to #15497.

According to https://ghc.haskell.org/trac/ghc/wiki/DependentHaskell/Phase2,
 we would like to have coercion quantifications back. This will
allow us to migrate (~#) to be homogeneous, instead of its current
heterogeneous definition. This patch is (lots of) plumbing only. There
should be no user-visible effects.

An overview of changes:

- Both `ForAllTy` and `ForAllCo` can quantify over coercion variables,
but only in *Core*. All relevant functions are updated accordingly.
- Small changes that should be irrelevant to the main task:
    1. removed dead code `mkTransAppCo` in Coercion
    2. removed out-dated Note Computing a coercion kind and
       roles in Coercion
    3. Added `Eq4` in Note Respecting definitional equality in
       TyCoRep, and updated `mkCastTy` accordingly.
    4. Various updates and corrections of notes and typos.
- Haddock submodule needs to be changed too.

Acknowledgments:
This work was completed mostly during Ningning Xie's Google Summer
of Code, sponsored by Google. It was advised by Richard Eisenberg,
supported by NSF grant 1704041.

Test Plan: ./validate

Reviewers: goldfire, simonpj, bgamari, hvr, erikd, simonmar

Subscribers: RyanGlScott, monoidal, rwbarton, carter

GHC Trac Issues: #15497

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

10 months agoMark code related symbols as @function not @object
Sergei Azovskov [Fri, 14 Sep 2018 14:09:59 +0000 (15:09 +0100)] 
Mark code related symbols as @function not @object

Summary:
This diff is a part of the bigger project which goal is to improve
common profiling tools support (perf) for GHC binaries.

A similar job was already done and reverted in the past:
 * https://phabricator.haskell.org/rGHCb1f453e16f0ce11a2ab18cc4c350bdcbd36299a6
 * https://phabricator.haskell.org/rGHCf1f3c4f50650110ad0f700d6566a44c515b0548f

Reasoning:

`Perf` and similar tools build in memory symbol table from the .symtab
section of the ELF file to display human-readable function names instead
of the addresses in the output. `Perf` uses only two types of symbols:
`@function` and `@notype` but GHC is not capable to produce any
`@function` symbols so the `perf` output is pretty useless (All the
haskell symbols that you can see in `perf` now are `@notype` internal
symbols extracted by mistake/hack).

The changes:
 * mark code related symbols as @function
 * small hack to mark InfoTable symbols as code if TABLES_NEXT_TO_CODE is true

Limitations:
 * The perf symbolization support is not complete after this patch but
   I'm working on the second patch.
 * Constructor symbols are not supported. To fix that we can issue extra
   local symbols which mark code sections as code and will be only used
   for debug.

Test Plan:
tests
any additional ideas?

Perf output on stock ghc 8.4.1:
```
     9.78%  FibbSlow  FibbSlow            [.] ckY_info
     9.59%  FibbSlow  FibbSlow            [.] cjqd_info
     7.17%  FibbSlow  FibbSlow            [.] c3sg_info
     6.62%  FibbSlow  FibbSlow            [.] c1X_info
     5.32%  FibbSlow  FibbSlow            [.] cjsX_info
     4.18%  FibbSlow  FibbSlow            [.] s3rN_info
     3.82%  FibbSlow  FibbSlow            [.] c2m_info
     3.68%  FibbSlow  FibbSlow            [.] cjlJ_info
     3.26%  FibbSlow  FibbSlow            [.] c3sb_info
     3.19%  FibbSlow  FibbSlow            [.] cjPQ_info
     3.05%  FibbSlow  FibbSlow            [.] cjQd_info
     2.97%  FibbSlow  FibbSlow            [.] cjAB_info
     2.78%  FibbSlow  FibbSlow            [.] cjzP_info
     2.40%  FibbSlow  FibbSlow            [.] cjOS_info
     2.38%  FibbSlow  FibbSlow            [.] s3rK_info
     2.27%  FibbSlow  FibbSlow            [.] cjq0_info
     2.18%  FibbSlow  FibbSlow            [.] cKQ_info
     2.13%  FibbSlow  FibbSlow            [.] cjSl_info
     1.99%  FibbSlow  FibbSlow            [.] s3rL_info
     1.98%  FibbSlow  FibbSlow            [.] c2cC_info
     1.80%  FibbSlow  FibbSlow            [.] s3rO_info
     1.37%  FibbSlow  FibbSlow            [.] c2f2_info
...
```

Perf output on patched ghc:
```
     7.97%  FibbSlow  FibbSlow            [.] c3rM_info
     6.75%  FibbSlow  FibbSlow            [.] 0x000000000032cfa8
     6.63%  FibbSlow  FibbSlow            [.] cifA_info
     4.98%  FibbSlow  FibbSlow            [.] integerzmgmp_GHCziIntegerziType_eqIntegerzh_info
     4.55%  FibbSlow  FibbSlow            [.] chXn_info
     4.52%  FibbSlow  FibbSlow            [.] c3rH_info
     4.45%  FibbSlow  FibbSlow            [.] chZB_info
     4.04%  FibbSlow  FibbSlow            [.] Main_fibbzuslow_info
     4.03%  FibbSlow  FibbSlow            [.] stg_ap_0_fast
     3.76%  FibbSlow  FibbSlow            [.] chXA_info
     3.67%  FibbSlow  FibbSlow            [.] cifu_info
     3.25%  FibbSlow  FibbSlow            [.] ci4r_info
     2.64%  FibbSlow  FibbSlow            [.] s3rf_info
     2.42%  FibbSlow  FibbSlow            [.] s3rg_info
     2.39%  FibbSlow  FibbSlow            [.] integerzmgmp_GHCziIntegerziType_eqInteger_info
     2.25%  FibbSlow  FibbSlow            [.] integerzmgmp_GHCziIntegerziType_minusInteger_info
     2.17%  FibbSlow  FibbSlow            [.] ghczmprim_GHCziClasses_zeze_info
     2.09%  FibbSlow  FibbSlow            [.] cicc_info
     2.03%  FibbSlow  FibbSlow            [.] 0x0000000000331e15
     2.02%  FibbSlow  FibbSlow            [.] s3ri_info
     1.91%  FibbSlow  FibbSlow            [.] 0x0000000000331bb8
     1.89%  FibbSlow  FibbSlow            [.] ci4N_info
...
```

Reviewers: simonmar, niteria, bgamari, goldfire

Reviewed By: simonmar, bgamari

Subscribers: lelf, rwbarton, thomie, carter

GHC Trac Issues: #15501

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

10 months agoMark system and internal symbols as private symbols in asm
Sergei Azovskov [Fri, 14 Sep 2018 13:56:37 +0000 (14:56 +0100)] 
Mark system and internal symbols as private symbols in asm

Summary:
This marks system and internal symbols as private in asm output so those
random generated sysmbols won't appear in .symtab

Reasoning:
 * internal symbols don't help to debug because names are just random
 * the symbols style breaks perf logic
 * internal symbols can take ~75% of the .symtab. In the same time
   .symtab can take about 20% of the binary file size

Notice:
This diff mostly makes sense on top of the D4713 (or similar)

Test Plan:
tests

Perf from D4713
```
     7.97%  FibbSlow  FibbSlow            [.] c3rM_info
     6.75%  FibbSlow  FibbSlow            [.] 0x000000000032cfa8
     6.63%  FibbSlow  FibbSlow            [.] cifA_info
     4.98%  FibbSlow  FibbSlow            [.] integerzmgmp_GHCziIntegerziType_eqIntegerzh_info
     4.55%  FibbSlow  FibbSlow            [.] chXn_info
     4.52%  FibbSlow  FibbSlow            [.] c3rH_info
     4.45%  FibbSlow  FibbSlow            [.] chZB_info
     4.04%  FibbSlow  FibbSlow            [.] Main_fibbzuslow_info
     4.03%  FibbSlow  FibbSlow            [.] stg_ap_0_fast
     3.76%  FibbSlow  FibbSlow            [.] chXA_info
     3.67%  FibbSlow  FibbSlow            [.] cifu_info
     3.25%  FibbSlow  FibbSlow            [.] ci4r_info
     2.64%  FibbSlow  FibbSlow            [.] s3rf_info
     2.42%  FibbSlow  FibbSlow            [.] s3rg_info
     2.39%  FibbSlow  FibbSlow            [.] integerzmgmp_GHCziIntegerziType_eqInteger_info
     2.25%  FibbSlow  FibbSlow            [.] integerzmgmp_GHCziIntegerziType_minusInteger_info
     2.17%  FibbSlow  FibbSlow            [.] ghczmprim_GHCziClasses_zeze_info
     2.09%  FibbSlow  FibbSlow            [.] cicc_info
     2.03%  FibbSlow  FibbSlow            [.] 0x0000000000331e15
     2.02%  FibbSlow  FibbSlow            [.] s3ri_info
     1.91%  FibbSlow  FibbSlow            [.] 0x0000000000331bb8
     1.89%  FibbSlow  FibbSlow            [.] ci4N_info
...
```

Perf from this patch:
```
    15.37%  FibbSlow  FibbSlow            [.] Main_fibbzuslow_info
    15.33%  FibbSlow  FibbSlow            [.] integerzmgmp_GHCziIntegerziType_minusInteger_info
    13.34%  FibbSlow  FibbSlow            [.] integerzmgmp_GHCziIntegerziType_eqIntegerzh_info
     9.24%  FibbSlow  FibbSlow            [.] integerzmgmp_GHCziIntegerziType_plusInteger_info
     9.08%  FibbSlow  FibbSlow            [.] frame_dummy
     8.25%  FibbSlow  FibbSlow            [.] integerzmgmp_GHCziIntegerziType_eqInteger_info
     4.29%  FibbSlow  FibbSlow            [.] 0x0000000000321ab0
     3.84%  FibbSlow  FibbSlow            [.] stg_ap_0_fast
     3.07%  FibbSlow  FibbSlow            [.] ghczmprim_GHCziClasses_zeze_info
     2.39%  FibbSlow  FibbSlow            [.] 0x0000000000321ab7
     1.90%  FibbSlow  FibbSlow            [.] 0x00000000003266b8
     1.88%  FibbSlow  FibbSlow            [.] base_GHCziNum_zm_info
     1.83%  FibbSlow  FibbSlow            [.] 0x0000000000326915
     1.34%  FibbSlow  FibbSlow            [.] 0x00000000003248cc
     1.07%  FibbSlow  FibbSlow            [.] base_GHCziNum_zp_info
     0.98%  FibbSlow  FibbSlow            [.] 0x00000000003247c8
     0.80%  FibbSlow  FibbSlow            [.] 0x0000000000121498
     0.79%  FibbSlow  FibbSlow            [.] stg_gc_noregs
     0.75%  FibbSlow  FibbSlow            [.] 0x0000000000321ad6
     0.67%  FibbSlow  FibbSlow            [.] 0x0000000000321aca
     0.64%  FibbSlow  FibbSlow            [.] 0x0000000000321b4a
     0.61%  FibbSlow  FibbSlow            [.] 0x00000000002ff633
```

Reviewers: simonmar, niteria, bgamari

Reviewed By: simonmar

Subscribers: lelf, angerman, olsner, rwbarton, thomie, carter

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

10 months agoFix T15502 on 32-bit
Krzysztof Gogolewski [Fri, 14 Sep 2018 12:38:42 +0000 (14:38 +0200)] 
Fix T15502 on 32-bit

Summary:
The expected output uses a hardcoded value for
maxBound :: Int.

This should fix one of circleci failures on i386.

Test Plan: make test TEST=T15502

Reviewers: RyanGlScott, bgamari

Reviewed By: RyanGlScott

Subscribers: rwbarton, carter

GHC Trac Issues: #15502

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

10 months agotests: increase (compile) timeout multiplier for T13701 and MultiLayerModules
Alp Mestanogullari [Fri, 14 Sep 2018 12:01:09 +0000 (14:01 +0200)] 
tests: increase (compile) timeout multiplier for T13701 and MultiLayerModules

Summary:
Those tests are currently making our i386 validation fail on CircleCI:

  https://circleci.com/gh/ghc/ghc/8827

Test Plan: Using my Phab<->CircleCI bridge to run i386 validation for this diff.

Reviewers: bgamari, monoidal

Reviewed By: monoidal

Subscribers: rwbarton, carter

GHC Trac Issues: #15484, #15383

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

10 months agoAdd support for ImplicitParams and RecursiveDo in TH
Michael Sloan [Fri, 14 Sep 2018 10:17:13 +0000 (12:17 +0200)] 
Add support for ImplicitParams and RecursiveDo in TH

Summary:
This adds TH support for the ImplicitParams and RecursiveDo extensions.

I'm submitting this as one review because I cannot cleanly make
the two commits independent.

Initially, my goal was just to add ImplicitParams support, and
I found that reasonably straightforward, so figured I might
as well use my newfound knowledge to address some other TH omissions.

Test Plan: Validate

Reviewers: goldfire, austin, bgamari, RyanGlScott

Reviewed By: RyanGlScott

Subscribers: carter, RyanGlScott, thomie

GHC Trac Issues: #1262

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

10 months agoUpdate hsc2hs submodule
Chaitanya Koparkar [Thu, 13 Sep 2018 22:15:18 +0000 (18:15 -0400)] 
Update hsc2hs submodule

Test Plan: ./validate

Reviewers: bgamari, hvr, RyanGlScott

Reviewed By: RyanGlScott

Subscribers: monoidal, rwbarton, carter

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

10 months agobase: showEFloat: Handle negative precisions the same of zero precision
Ben Gamari [Thu, 13 Sep 2018 21:09:56 +0000 (17:09 -0400)] 
base: showEFloat: Handle negative precisions the same of zero precision

Test Plan: Validate

Reviewers: hvr, alpmestan

Reviewed By: alpmestan

Subscribers: rwbarton, carter

GHC Trac Issues: #15509

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

10 months agoeventlog: Factor out eventlog header generation into separate function
Ben Gamari [Thu, 13 Sep 2018 15:31:08 +0000 (11:31 -0400)] 
eventlog: Factor out eventlog header generation into separate function

10 months agoFix build
Krzysztof Gogolewski [Thu, 13 Sep 2018 20:52:05 +0000 (22:52 +0200)] 
Fix build

10 months agoRemove dead variable binding
Simon Peyton Jones [Thu, 13 Sep 2018 16:47:50 +0000 (17:47 +0100)] 
Remove dead variable binding

Fallout from earlier commit, sorry.

10 months agoMore info for Implication with -dppr-debug
Simon Peyton Jones [Thu, 13 Sep 2018 11:56:29 +0000 (12:56 +0100)] 
More info for Implication with -dppr-debug

10 months agoAdd regression test for Trac #15629
Simon Peyton Jones [Thu, 13 Sep 2018 11:56:09 +0000 (12:56 +0100)] 
Add regression test for Trac #15629

10 months agoAllow (~) in the head of a quantified constraints
Simon Peyton Jones [Thu, 13 Sep 2018 10:23:53 +0000 (11:23 +0100)] 
Allow (~) in the head of a quantified constraints

Since the introduction of quantified constraints, GHC has rejected
a quantified constraint with (~) in the head, thus
  f :: (forall a. blah => a ~ ty) => stuff

I am frankly dubious that this is ever useful.  But /is/ necessary for
Coercible (representation equality version of (~)) and it does no harm
to allow it for (~) as well.  Plus, our users are asking for it
(Trac #15359, #15625).

It was really only excluded by accident, so
this patch lifts the restriction. See TcCanonical
Note [Equality superclasses in quantified constraints]

There are a number of wrinkles:

* If the context of the quantified constraint is empty, we
  can get trouble when we get down to unboxed equality (a ~# b)
  or (a ~R# b), as Trac #15625 showed. This is even more of
  a corner case, but it produced an outright crash, so I elaborated
  the superclass machinery in TcCanonical.makeStrictSuperClasses
  to add a void argument in this case.  See
  Note [Equality superclasses in quantified constraints]

* The restriction on (~) was in TcValidity.checkValidInstHead.
  In lifting the restriction I discovered an old special case for
  (~), namely
      | clas_nm `elem` [ heqTyConName, eqTyConName]
      , nameModule clas_nm /= this_mod
  This was (solely) to support the strange instance
      instance a ~~ b => a ~ b
  in Data.Type.Equality. But happily that is no longer
  with us, since
     commit f265008fb6f70830e7e92ce563f6d83833cef071
     Refactor (~) to reduce the suerpclass stack
  So I removed the special case.

* I found that the Core invariants on when we could have
       co = <expr>
  were entirely not written down. (Getting this wrong ws
  the proximate source of the crash in Trac #15625.  So

  - Documented them better in CoreSyn
      Note [CoreSyn type and coercion invariant],
  - Modified CoreOpt and CoreLint to match
  - Modified CoreUtils.bindNonRec to match
  - Made MkCore.mkCoreLet use bindNonRec, rather
    than duplicate its logic
  - Made Simplify.rebuildCase case-to-let respect
      Note [CoreSyn type and coercion invariant],

10 months agoComments only (on IfDataInstance)
Simon Peyton Jones [Thu, 13 Sep 2018 08:18:25 +0000 (09:18 +0100)] 
Comments only (on IfDataInstance)

10 months agoDelete duplicated comment line
Simon Peyton Jones [Wed, 12 Sep 2018 12:21:19 +0000 (13:21 +0100)] 
Delete duplicated comment line

10 months agoComments about join-point return types
Simon Peyton Jones [Wed, 12 Sep 2018 12:21:02 +0000 (13:21 +0100)] 
Comments about join-point return types

10 months agoTypo in user guide wrongly claims DeriveLift was added in 7.2
Merijn Verstraaten [Mon, 10 Sep 2018 14:38:16 +0000 (16:38 +0200)] 
Typo in user guide wrongly claims DeriveLift was added in 7.2

10 months agoHonor INLINE on 0-arity bindings (#15578)
Tobias Dammers [Thu, 13 Sep 2018 08:21:49 +0000 (10:21 +0200)] 
Honor INLINE on 0-arity bindings (#15578)

Summary:
Fix test for #15578

By allowing 0-arity values to be inlined, we end up changing boringness
annotations, and this gets reflected in the Core output for this
particular test.

Add Notes for #15578

Test Plan: ./validate

Reviewers: simonpj, bgamari

Reviewed By: simonpj

Subscribers: rwbarton, carter

GHC Trac Issues: #15578

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

10 months agorts/Printer.c: always define the findPtr symbol
Alp Mestanogullari [Wed, 12 Sep 2018 22:06:02 +0000 (18:06 -0400)] 
rts/Printer.c: always define the findPtr symbol

It was previously only defined (and therefore shipped) when DEBUG is
defined.  This patch defines it regardless of DEBUG. This will help fix
hadrian on OS X [1].

[1]: https://github.com/snowleopard/hadrian/issues/614

Test Plan: The error from hadrian#614 is gone

Reviewers: bgamari, erikd, simonmar

Reviewed By: simonmar

Subscribers: rwbarton, carter

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

10 months agotemplate-haskell: Fix typo in changelog
Ben Gamari [Mon, 10 Sep 2018 02:23:16 +0000 (22:23 -0400)] 
template-haskell: Fix typo in changelog

10 months agoRevert "ghc: Remove warning of StaticPointers not being supported by GHCi"
Ben Gamari [Fri, 7 Sep 2018 14:48:43 +0000 (10:48 -0400)] 
Revert "ghc: Remove warning of StaticPointers not being supported by GHCi"

While we now support use of StaticPointers in modules loaded via the
REPL (e.g. via `:load`), we currently do not support use of
StaticPointers on the REPL itself.

This reverts commit 9400a5c6b308fbb5b3a73690610736ca3b5eb0b3.

10 months agoBe a bit more aggressive about let-to-case
Simon Peyton Jones [Wed, 12 Sep 2018 12:06:53 +0000 (13:06 +0100)] 
Be a bit more aggressive about let-to-case

This patch takes up the missed opportunity described in
Trac #15631, by convering a case into a let slightly
more agressively. See Simplify.hs
Note [Case-to-let for strictly-used binders]

There is no measurable perf impact for good or ill. But
the code is simpler and easier to explain.

10 months agoRefactor info table entry error messages
Ömer Sinan Ağacan [Wed, 12 Sep 2018 06:11:18 +0000 (09:11 +0300)] 
Refactor info table entry error messages

We now show address of the entered object in error messages. Example:

    foo: internal error: Evaluated a CAF (0xe4c518) that was GC'd!
        (GHC version 8.6.0.20180907 for x86_64_unknown_linux)
        Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug

Helpful when debugging.

Test Plan: This validates

Reviewers: simonmar, bgamari, erikd

Reviewed By: simonmar

Subscribers: rwbarton, carter

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

10 months agoMake CoreMonad independent of TcEnv (#14391)
Krzysztof Gogolewski [Tue, 11 Sep 2018 18:46:04 +0000 (20:46 +0200)] 
Make CoreMonad independent of TcEnv (#14391)

Summary:
This removes the last direct import from simplCore/
to typechecker/.

Test Plan: validate

Reviewers: nomeata, simonpj, bgamari

Reviewed By: simonpj

Subscribers: rwbarton, carter

GHC Trac Issues: #14391

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

10 months agorts.cabal.in: advertise new default profiling ways for hadrian
Alp Mestanogullari [Tue, 11 Sep 2018 18:45:43 +0000 (20:45 +0200)] 
rts.cabal.in: advertise new default profiling ways for hadrian

Summary:
D5140 makes us build some new profiling ways by default, but since it
is not advertised in rts.cabal, hadrian doesn't know about that. This patch
fixes this and successfully lets hadrian build those flavours of libHSrts.

Test Plan: hadrian/build.sh --flavour=perf

Reviewers: bgamari, erikd, simonmar

Reviewed By: simonmar

Subscribers: rwbarton, carter

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

10 months agoRevert incorrect STM wakeup optimisation
Ömer Sinan Ağacan [Tue, 11 Sep 2018 18:43:50 +0000 (20:43 +0200)] 
Revert incorrect STM wakeup optimisation

Summary: (see the comments)

Reviewers: simonmar, bgamari, erikd

Reviewed By: simonmar

Subscribers: rwbarton, carter

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