7 months agoDon't lint erroneous programs. ghc-8.6.2-release
Richard Eisenberg [Thu, 1 Nov 2018 22:03:21 +0000 (18:03 -0400)] 
Don't lint erroneous programs.

newFamInst lints its types. This is good. But it's not so good
when there have been errors and thus recovery tycons are about.
So we now don't.

Fixes #15796.

Test case: typecheck/should_fail/T15796

(cherry picked from commit 1f72a1c81368e34387aac38c0b1c59521cec58ec)

7 months agoFix #15787 by squashing a coercion hole.
Richard Eisenberg [Sun, 28 Oct 2018 20:06:17 +0000 (16:06 -0400)] 
Fix #15787 by squashing a coercion hole.

In type-incorrect code, we can sometimes let a coercion
hole make it through the zonker. If this coercion hole then
ends up in the environment (e.g., in the type of a data
constructor), then it causes trouble later.

This patch avoids trouble by substituting the coercion hole
for its representative CoVar. Really, any coercion would do,
but the CoVar was very handy.

test case: polykinds/T15787

(cherry picked from commit 4427315a65b25db22e1754d41b43dd4b782b022f)

7 months agousers-guide: Fix version number
Ben Gamari [Wed, 31 Oct 2018 16:23:39 +0000 (12:23 -0400)] 
users-guide: Fix version number

7 months agousers-guide: Note existence of #14251
Ben Gamari [Tue, 30 Oct 2018 18:13:22 +0000 (14:13 -0400)] 
users-guide: Note existence of #14251

7 months agoFix #15815 by parenthesizing the arguments to infix ~
Ryan Scott [Sun, 28 Oct 2018 20:08:11 +0000 (16:08 -0400)] 
Fix #15815 by parenthesizing the arguments to infix ~

An unfortunate consequence of commit
b9483981d128f55d8dae3f434f49fa6b5b30c779 (`Remove HsEqTy and XEqTy`)
is infix uses of `~` in TH quotes now desugar differently than
before. In particular, we have that:

a ~ (Int -> Int)

Now desugars to:

HsOpTy a (~) (HsOpTy Int (->) Int)

Which GHC interprets as being:

a ~ Int -> Int

Or, equivalently:

(a ~ Int) -> Int

Which is different than what was intended! This is the cause
of #15815.

All of this has revealed that we likely need to renovate the way we
desugar infix type operators to be more consistent with the treatment
for infix expressions (see for more on
this.) Doing so would constitute a breaking change, however, so we
will likely want to wait until another major GHC release to do this.

In the meantime, this patch offers a non-invasive change to the way
that infix uses of `~` are desugared. This makes the program
in #15815 compile again by inserting extra `HsParTy`s around the
arguments to `~` if they are lacking them.

Test Plan: make test TEST=T15815

Reviewers: int-index, goldfire, bgamari

Reviewed By: int-index

Subscribers: int-e, rwbarton, carter

GHC Trac Issues: #15815

Differential Revision:

(cherry picked from commit b8a797ecc34a309bd78f5a290e3554642a3a478a)

7 months agoRevert "Multiple fixes / improvements for LLVM backend"
Ben Gamari [Tue, 30 Oct 2018 15:12:46 +0000 (11:12 -0400)] 
Revert "Multiple fixes / improvements for LLVM backend"

This reverts commit 73273be476a8cc6c13368660b042b3b0614fd928.

Unfortunately we were unable to come to a fix that didn't sacrifice the
ability to bootstrap GHC using the LLVM backend. Reverting for 8.6.2.

7 months agoRevert "Fix for T14251 on ARM"
Ben Gamari [Tue, 30 Oct 2018 15:12:12 +0000 (11:12 -0400)] 
Revert "Fix for T14251 on ARM"

This reverts commit 2e23e1c7de01c92b038e55ce53d11bf9db993dd4.

7 months agousers-guide: Fix typo
Ben Gamari [Mon, 29 Oct 2018 17:56:40 +0000 (13:56 -0400)] 
users-guide: Fix typo

7 months agoReport a Wanted error even if there are Given ones
Simon Peyton Jones [Thu, 18 Oct 2018 14:41:44 +0000 (15:41 +0100)] 
Report a Wanted error even if there are Given ones

We suppress some Given errors; see Note [Given errors]
in TcErrors.  But we must be careful not to suppress
Wanted errors because of the presence of these Given
errors -- else we might allow compilation to bogusly

The rubber hits the road in TcRnTypes.insolubleCt,
where we don't want to treat Givens as insoluble,
nor (and this is the new bit) Deriveds that arise
from Givens.  See Note [Given insolubles] in TcRnTypes.

This fixes #15767.

(cherry picked from commit 6b1102e2cfcffb265fd33cf8a99ab5e6b3f14906)

Ben notes:

  I have folded some test output changes in `TEST="T12529 T12921 mc13
  mc14"` into this patch that were not in the original.

7 months agoFix TcType.anyRewritableTyVar
Ningning Xie [Sun, 28 Oct 2018 16:29:55 +0000 (12:29 -0400)] 
Fix TcType.anyRewritableTyVar

This patch fixes #15805, where we found that
`TcType.anyRewritableTyVar` has one wrong case.

Besides the fix, it also:
- removed some unnecessary `ASSERT2(tcIsTcTyVar...)` in `TcType`, as now we have
     `tcIsTcTyVar = isTyVar`.
- fixed some comments

Test Plan: ./validate

Reviewers: goldfire, simonpj, bgamari

Reviewed By: simonpj

Subscribers: rwbarton, carter

GHC Trac Issues: #15805

Differential Revision:

(cherry picked from commit a7f64c6cbfc5562adff207945576d1c9db2a58d9)

7 months agousers-guide: Add release notes for 8.6.2
Ben Gamari [Sun, 28 Oct 2018 20:02:51 +0000 (16:02 -0400)] 
users-guide: Add release notes for 8.6.2

7 months agoplugins: search for .a files if necessary
sheaf [Sun, 28 Oct 2018 16:30:13 +0000 (12:30 -0400)] 
plugins: search for .a files if necessary

on windows, plugins are loaded via .a files,
but those paths were not being searched when loading plugins

Test Plan: ./validate

Reviewers: Phyx, bgamari

Reviewed By: Phyx

Subscribers: RyanGlScott, rwbarton, carter

GHC Trac Issues: #15700

Differential Revision:

(cherry picked from commit 70298db16c3f0ea4adb603ccb2b5e93eb9c7a556)

7 months agoComment out CONSTANT_FOLDED in GHC.Natural
Christiaan Baaij [Sun, 28 Oct 2018 16:29:23 +0000 (12:29 -0400)] 
Comment out CONSTANT_FOLDED in GHC.Natural

Although these functions were marked as CONSTANT_FOLDED, they did
not have a corresponding builtinRule in PrelRules. The idea was
probably to add them eventually, but this hasn't manifested so

The plan is to eventually add builtin rules for these functions
over Natural, so as a reminder we simply comment out the
CONSTANT_FOLDED  annotation instead of removing it completely.

Reviewers: hvr, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, carter

Differential Revision:

(cherry picked from commit 3ec6fe8827956cc36b58cdf0bb1f5752eaa2a8ea)

7 months agoFix integer overflow when encoding doubles (Trac #15271)
Fangyi Zhou [Sun, 28 Oct 2018 16:28:53 +0000 (12:28 -0400)] 
Fix integer overflow when encoding doubles (Trac #15271)

Ticket #15271 reports a case where 1e1000000000 is incorrectly
converted to 0.0. After some investigation, I discovered the number is
converted to rational correctly, but converting the ratio into a double
introduced an error.

Tracking down to how the conversion is done, I found the rts float
implementation uses `ldexp`, whose signature is
`double ldexp (double x, int exp);`
The callsite passes an `I_` to the second argument, which is
platform-dependent. On machines where `I_` is 64 bits and `int` is 32 bits, we
observe integer overflow behaviour.

Here is a mapping from rational to exponent with observations
1e646457008  -> 2147483645 (result = infinity, positive in int32)
1e646457009  -> 2147483648 (result = 0.0, overflow to negative in int32)
1e1000000000 -> 3321928042 (result = infinity, overflow to positive in int32)
1e1555550000 -> 5167425196 (result = 0.0, overflow to negative in int32)

We fix this issue by comparing STG_INT_MIN/MAX and INT_MIN/MAX and bound the
value appropriately.

Test Plan: New test cases

Reviewers: bgamari, erikd, simonmar

Reviewed By: bgamari

Subscribers: rwbarton, carter

GHC Trac Issues: #15271

Differential Revision:

(cherry picked from commit 311a63979cfa2c1e81be54b82205e681f6ec4f14)

7 months agoFix `:k` command: add validity checking
Ningning Xie [Sun, 28 Oct 2018 16:26:12 +0000 (12:26 -0400)] 
Fix `:k` command: add validity checking

This patch fixes #15806, where we found that the `:k` command in GHCi
misses a validity checking for the type.

Missing validity checking causes `:k` to accept types that are not validated.
For example, `:k (Maybe (forall a. a -> a))` (incorrectly) returns `*`, while
impredictivity of type instantiation shouldn't be allowed.

Test Plan: ./validate

Reviewers: simonpj, goldfire, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, carter

GHC Trac Issues: #15806

Differential Revision:

(cherry picked from commit 12cb5cf50b8b35394e2e2d57e1ac693c76f90833)

7 months agoincludes: Allow headers to be built with C++11 compilers
Ben Gamari [Sun, 28 Oct 2018 16:24:06 +0000 (12:24 -0400)] 
includes: Allow headers to be built with C++11 compilers

Fixes #14784. Note that C++11 is quite conservative; we could likely accept
C++03 as well.

Test Plan:
$ cat >hi.c <<EOF
#include <Rts.h>
$ g++ -std=c++11 hi.c

Reviewers: simonmar, hvr

Subscribers: rwbarton, carter

GHC Trac Issues: #14784

Differential Revision:

(cherry picked from commit d3a1022fabb0ad337003fac774c6929f402ecb8b)

7 months agoFix rare undefined asm temp end label error in x86
Zejun Wu [Sun, 28 Oct 2018 16:22:25 +0000 (12:22 -0400)] 
Fix rare undefined asm temp end label error in x86

Encountered assembly error due to undefined label `.LcaDcU_info_end` for
following code generated by `pprFrameProc`:

  .long .Lblock{v caDcU}_info_fde_end-.Lblock{v caDcU}_info_fde
.Lblock{v caDcU}_info_fde:
  .long _nbHlD-.Lsection_frame
  .quad block{v caDcU}_info-1
  .quad .Lblock{v caDcU}_info_end-block{v caDcU}_info+1
  .byte 1

This diff fixed the error.

Test Plan:

Also the case where we used to have assembly error is now fixed.
Unfortunately, I have limited insight here and cannot get a small enough repro
or test case for this.

Ben says:

> I think I see: Previously we only produced end symbols for the info
> tables of top-level procedures. However, blocks within a procedure may
> also have info tables, we will dutifully generate debug information for
> and consequently we get undefined symbols.

Reviewers: simonmar, scpmw, last_g, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, carter

Differential Revision:

(cherry picked from commit cf961dcf5ebc26cbd960196ba387736334088303)

7 months agoFix for T14251 on ARM
Kavon Farvardin [Sun, 28 Oct 2018 16:11:49 +0000 (12:11 -0400)] 
Fix for T14251 on ARM

We now calculate the SSE register padding needed to fix the calling
convention in LLVM in a robust way: grouping them by whether
registers in that class overlap (with the same class overlapping

My prior patch assumed that no matter the platform, physical
register Fx aliases with Dx, etc, for our calling convention.

This is unfortunately not the case for any platform except x86-64.

Test Plan:
Only know how to test on x86-64, but it should be tested on ARM with:

`make test WAYS=llvm && make test WAYS=optllvm`

Reviewers: bgamari, angerman

Reviewed By: bgamari

Subscribers: rwbarton, carter

GHC Trac Issues: #15780, #14251, #15747

Differential Revision:

(cherry picked from commit c36a2b596a6ba9d7a0a80df01b3c041720c727ca)

7 months agoBump hsc2hs submodule
Ben Gamari [Thu, 18 Oct 2018 13:17:53 +0000 (09:17 -0400)] 
Bump hsc2hs submodule

8 months agoBump version to 8.6.2
Ben Gamari [Wed, 17 Oct 2018 22:39:25 +0000 (18:39 -0400)] 
Bump version to 8.6.2

8 months agocircleci: Build with in-tree GMP on Darwin
Ben Gamari [Wed, 17 Oct 2018 19:31:36 +0000 (15:31 -0400)] 
circleci: Build with in-tree GMP on Darwin

Fixes #15404.

8 months agoFix #15761 by adding parens
Richard Eisenberg [Wed, 17 Oct 2018 14:46:21 +0000 (10:46 -0400)] 
Fix #15761 by adding parens

This was just a pretty-printer infelicity. Fixed now.

Test case: printer/T15761

(cherry picked from commit 38c28c1a8bb129141e533866700e7318314f32c1)

8 months agoBump haddock submodule
Ben Gamari [Wed, 17 Oct 2018 15:19:53 +0000 (11:19 -0400)] 
Bump haddock submodule

8 months agoFail fast on pattern synonyms
Simon Peyton Jones [Wed, 3 Oct 2018 14:53:59 +0000 (15:53 +0100)] 
Fail fast on pattern synonyms

We were recovering too eagerly from errors in pattern-synonym
type inference, leading to a cascade of confusing follow up errors
(Trac #15685, #15692).

The underlying issue is that a pattern synonym should have a closed,
fixed type, with no unification variables in it.  But it wasn't!

Fixing this made me change the interface to simplifyInfer slightly.
Instead of /emitting/ a residual implication constraint, it
now /returns/ it, so that the caller can decide what to do.

(cherry picked from commit 9ebfa03d9e9cbf79f698b5d4bd39e799e4e9a02c)

8 months agobase: Fill in TBAs in changelog
Ben Gamari [Mon, 15 Oct 2018 17:59:20 +0000 (13:59 -0400)] 
base: Fill in TBAs in changelog

I've added a check in my release script to ensure that this doesn't happen in
the future.

(cherry picked from commit 2605458930f2d79738fab4437f10793448d4232c)

8 months agoFix dataToTag# argument evaluation
Ömer Sinan Ağacan [Wed, 10 Oct 2018 07:07:05 +0000 (10:07 +0300)] 
Fix dataToTag# argument evaluation

See #15696 for more details. We now always enter dataToTag# argument (done in
generated Cmm, in StgCmmExpr). Any high-level optimisations on dataToTag#
applications are done by the simplifier. Looking at tag bits (instead of
reading the info table) for small types is left to another diff.

Incorrect test T14626 is removed. We no longer do this optimisation (see
comment:44, comment:45, comment:60).

Comments and notes about special cases around dataToTag# are removed. We no
longer have any special cases around it in Core.

Other changes related to evaluating primops (seq# and dataToTag#) will be
pursued in follow-up diffs.

Test Plan: Validates with three regression tests

Reviewers: simonpj, simonmar, hvr, bgamari, dfeuer

Reviewed By: simonmar

Subscribers: rwbarton, carter

GHC Trac Issues: #15696

Differential Revision:

(cherry picked from commit ac977688523e5d77eb6f041f043552410b0c21da)

8 months agoDo not mark CoVars as dead in the occur-anal
Simon Peyton Jones [Wed, 3 Oct 2018 14:41:43 +0000 (15:41 +0100)] 
Do not mark CoVars as dead in the occur-anal

For years we have been marking CoVars as dead, becuase we
don't gather occurrence info from types.  This is obviously
wrong and caused Trac #15695.

See Note [Do not mark CoVars as dead] in OccurAnal.

(cherry picked from commit 02b303eed0170983921877801e57f55d012db301)

8 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)

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:

(cherry picked from commit d00c308633fe7d216d31a1087e00e63532d87d6d)

8 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:

(cherry picked from commit 21efbc7599e39ec93b8b13b7d7b84811226e6f6f)

8 months agoAdd -Wstar-is-type to the User's Guide
Vladislav Zavialov [Thu, 4 Oct 2018 17:43:47 +0000 (13:43 -0400)] 
Add -Wstar-is-type to the User's Guide

The -Wstar-is-type flag was added without documentation.
Now it has documentation.

Test Plan: Validate

Reviewers: bgamari

Reviewed By: bgamari

Subscribers: rwbarton, carter

Differential Revision:

(cherry picked from commit 07083fc44ebf3f0510ae1d71ae5c9c88c87ae1d8)

8 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:

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:

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:

(cherry picked from commit 66c17293648fd03a04aabfd807b3c8336e8f843a)

8 months agoCompiler panic on invalid syntax (unterminated pragma)
roland [Tue, 4 Sep 2018 12:09:20 +0000 (14:09 +0200)] 
Compiler panic on invalid syntax (unterminated pragma)

Summary: After a parse error in OPTIONS_GHC issue an error message instead of a compiler panic.

Test Plan: make test TEST=T15053

Reviewers: Phyx, thomie, bgamari, monoidal, osa1

Reviewed By: Phyx, monoidal, osa1

Subscribers: tdammers, osa1, rwbarton, carter

GHC Trac Issues: #15053

Differential Revision:

(cherry picked from commit df363a646b66f4dd13d63ec70f18e427cabc8878)

8 months agotestsuite: Add test for #15053
Ben Gamari [Fri, 6 Jul 2018 15:01:38 +0000 (11:01 -0400)] 
testsuite: Add test for #15053

Reviewers: Phyx

Reviewed By: Phyx

Subscribers: Phyx, rwbarton, thomie, carter

GHC Trac Issues: #15053

Differential Revision:

(cherry picked from commit f03f0d61bebe287e0df0254c175eb2f183d697aa)

8 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)

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:

(cherry picked from commit 9bfbc4e16d511678cffa9f7f76b369c8cfca7a66)

8 months agousers guide: Drop old release notes
Ben Gamari [Sun, 7 Oct 2018 15:53:52 +0000 (11:53 -0400)] 
users guide: Drop old release notes

8 months agoBe mindful of GADT tyvar order when desugaring record updates
Ryan Scott [Fri, 17 Aug 2018 14:31:27 +0000 (16:31 +0200)] 
Be mindful of GADT tyvar order when desugaring record updates

After commit ef26182e2014b0a2a029ae466a4b121bf235e4e4,
the type variable binders in GADT constructor type signatures
are now quantified in toposorted order, instead of always having
all the universals before all the existentials. Unfortunately, that
commit forgot to update some code (which was assuming the latter
scenario) in `DsExpr` which desugars record updates. This wound
up being the cause of #15499.

This patch makes up for lost time by desugaring record updates in
a way such that the desugared expression applies type arguments to
the right-hand side constructor in the correct order—that is, the
order in which they were quantified by the user.

Test Plan: make test TEST=T15499

Reviewers: simonpj, bgamari

Reviewed By: simonpj

Subscribers: rwbarton, carter

GHC Trac Issues: #15499

Differential Revision:

(cherry picked from commit 63b6a1d44849c479d2a7cb59211f5c64d133bc62)

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

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:

(cherry picked from commit deceb21b7ec64ae60377addc2679692ca500b6ae)

8 months agoBump array submodule
Ben Gamari [Fri, 5 Oct 2018 21:43:59 +0000 (17:43 -0400)] 
Bump array submodule

8 months agoMultiple fixes / improvements for LLVM backend
Kavon Farvardin [Thu, 4 Oct 2018 17:44:55 +0000 (13:44 -0400)] 
Multiple fixes / improvements for LLVM backend

- Fix for #13904 -- stop "trashing" callee-saved registers, since it is
  not actually doing anything useful.

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

- Fixed a typo in 'readnone' attribute

- Added 'lower-expect' pass to level 0 LLVM optimization passes to
  improve block layout in LLVM for stack checks, etc.

Test Plan: `make test WAYS=optllvm` and `make test WAYS=llvm`

Reviewers: bgamari, simonmar, angerman

Reviewed By: angerman

Subscribers: rwbarton, carter

GHC Trac Issues: #13904, #14251

Differential Revision:

(cherry picked from commit adcb5fb47c0942671d409b940d8884daa9359ca4)

8 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.

(cherry picked from commit d0d74842868ceb6716b7334eb6310f61f90023bf)

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

(cherry picked from commit ba086ca72ee6c77abba685f3100ad513e38a1a87)

8 months agocircleci: Run cabal update with -v
Ben Gamari [Fri, 21 Sep 2018 20:05:30 +0000 (16:05 -0400)] 
circleci: Run cabal update with -v

The cabal update command appears to be timing out with no output after 10 minutes.

8 months agoSet RELEASE=YES ghc-8.6.1-release
Ben Gamari [Fri, 21 Sep 2018 16:39:51 +0000 (12:39 -0400)] 

8 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

(cherry picked from commit a257782f56e5e330349d4cc7db71e297d8396c67)

8 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:

(cherry picked from commit 8c7d33a8ff6d3ea55b5dc8108d9441521af68ab8)

8 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.

(cherry picked from commit 4eebc8016f68719e1ccdf460754a97d1f4d6ef05)

8 months agousers-guide: Fill out release highlights
Ben Gamari [Wed, 19 Sep 2018 19:28:47 +0000 (15:28 -0400)] 
users-guide: Fill out release highlights

8 months agoBump stm submodule
Ben Gamari [Wed, 19 Sep 2018 18:56:41 +0000 (14:56 -0400)] 
Bump stm submodule

8 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

Fix code-block layout for QuantifiedConstraints.

[ci skip]

Test Plan: build

Reviewers: bgamari, monoidal

Reviewed By: monoidal

Subscribers: rwbarton, carter

Differential Revision:

(cherry picked from commit 43967c0c7d2d0110cfc5f9d64a7dab3a3dda8953)

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:

(cherry picked from commit a324dfdf3b505ea30d134dc8183d7b4bb441ced4)

9 months agoRevert "Revert "Disable the SRT offset optimisation on MachO platforms""
Ben Gamari [Tue, 18 Sep 2018 15:45:27 +0000 (11:45 -0400)] 
Revert "Revert "Disable the SRT offset optimisation on MachO platforms""

This reverts commit c15d44f8b3f00bfe152c2f9d3c6f60efd204fb23.

9 months agoRevert "Revert "Fix a bug in SRT generation""
Ben Gamari [Tue, 18 Sep 2018 15:45:26 +0000 (11:45 -0400)] 
Revert "Revert "Fix a bug in SRT generation""

This reverts commit d82e8af82d4be11252294290564044ef956ec2a4.

9 months agoRevert "Revert "Fix retainer profiling after SRT overhaul""
Ben Gamari [Tue, 18 Sep 2018 15:45:25 +0000 (11:45 -0400)] 
Revert "Revert "Fix retainer profiling after SRT overhaul""

This reverts commit 25765469b312aa21422c635aa5852a69e29f24f1.

9 months agoRevert "Revert "Comments and refactoring only""
Ben Gamari [Tue, 18 Sep 2018 15:45:25 +0000 (11:45 -0400)] 
Revert "Revert "Comments and refactoring only""

This reverts commit b0f06f53761820167e8b2cda61bc8c3137a83f92.

9 months agoRevert "Revert "Merge FUN_STATIC closure with its SRT""
Ben Gamari [Tue, 18 Sep 2018 15:45:23 +0000 (11:45 -0400)] 
Revert "Revert "Merge FUN_STATIC closure with its SRT""

This reverts commit 6f2596b432a9915d648286195b48c48ccdd14a2c.

9 months agoRevert "Revert "Save a word in the info table on x86_64""
Ben Gamari [Tue, 18 Sep 2018 15:45:22 +0000 (11:45 -0400)] 
Revert "Revert "Save a word in the info table on x86_64""

This reverts commit dee229487fccc6a994d4bb9c4ceda0903bec707b.

9 months agoRevert "Revert "An overhaul of the SRT representation""
Ben Gamari [Tue, 18 Sep 2018 15:45:21 +0000 (11:45 -0400)] 
Revert "Revert "An overhaul of the SRT representation""

This reverts commit ceffd7fe3f310cb30fec870f768e8047af309d99.

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

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:

(cherry picked from commit ecbe26b6966a3a64f4e22e862370536b1dd4440f)

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

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

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

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

9 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:

(cherry picked from commit ce240b3f998b68853c47ab131126eb9a245256c5)

9 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:

(cherry picked from commit e71e341f87c055ecc01f85ddd8d7a2094dfa8e9a)

9 months agoFix #10859 by using foldr1 while deriving Eq instances
Chaitanya Koparkar [Mon, 27 Aug 2018 12:07:08 +0000 (14:07 +0200)] 
Fix #10859 by using foldr1 while deriving Eq instances

Previously, we were using foldl1 instead, which led to the derived
code to be wrongly associated.

Test Plan: ./validate

Reviewers: RyanGlScott, nomeata, simonpj, bgamari

Reviewed By: RyanGlScott, nomeata

Subscribers: rwbarton, carter

GHC Trac Issues: #10859

Differential Revision:

(cherry picked from commit 2d953a60489ba30433e5f2fe27c50aa9da75f802)

9 months agoFix #15572 by checking for promoted names in ConT
Ryan Scott [Tue, 28 Aug 2018 18:54:28 +0000 (20:54 +0200)] 
Fix #15572 by checking for promoted names in ConT

When converting `ConT`s to `HsTyVar`s in `Convert`, we were
failing to account for the possibility of promoted data constructor
names appearing in a `ConT`, which could result in improper
pretty-printing results (as observed in #15572). The fix is
straightforward: use `Promoted` instead of `NotPromoted` when the
name of a `ConT` is a data constructor name.

Test Plan: make test TEST=T15572

Reviewers: goldfire, bgamari, simonpj, monoidal

Reviewed By: goldfire, simonpj

Subscribers: monoidal, rwbarton, carter

GHC Trac Issues: #15572

Differential Revision:

(cherry picked from commit c46a5f2002f6694ea58f79f505d57f3b7bd450e7)

9 months agoFix #15550 by quoting RULE names during TH conversion
Ryan Scott [Mon, 27 Aug 2018 12:02:42 +0000 (14:02 +0200)] 
Fix #15550 by quoting RULE names during TH conversion

When converting a `RuleP` to a GHC source `RuleD` during TH
conversion, we were stupidly not double-quoting the name of the rule.
Easily fixed.

Test Plan: make test TEST=T15550

Reviewers: goldfire, bgamari, simonpj

Reviewed By: simonpj

Subscribers: simonpj, rwbarton, carter

GHC Trac Issues: #15550

Differential Revision:

(cherry picked from commit 5e6cf2a9301a5473ff9c5319b96de941b1ad72dd)

9 months agocanCFunEqCan: use isTcReflexiveCo (not isTcReflCo)
Simon Peyton Jones [Mon, 3 Sep 2018 08:00:49 +0000 (09:00 +0100)] 
canCFunEqCan: use isTcReflexiveCo (not isTcReflCo)

As Trac #15577 showed, it was possible for a /homo-kinded/
constraint to trigger the /hetero-kinded/ branch of canCFunEqCan,
and that triggered an infinite loop.

The fix is easier, but there remains a deeper questions: why is
the flattener producing giant refexive coercions?

(cherry picked from commit 2e226a46c422c12f78dc3d3f62fe5a15e22bd986)

9 months agoFix #15502 by not casting to Int during TH conversion
Ryan Scott [Mon, 27 Aug 2018 12:02:49 +0000 (14:02 +0200)] 
Fix #15502 by not casting to Int during TH conversion

When turning an `IntegerL` to an `IntegralLit` during TH
conversion, we were stupidly casting an `Integer` to an `Int` in
order to determine how it should be pretty-printed. Unsurprisingly,
this causes problems when the `Integer` doesn't lie within the bounds
of an `Int`, as demonstrated in #15502.

The fix is simple: don't cast to an `Int`.

Test Plan: make test TEST=T15502

Reviewers: bgamari, simonpj

Reviewed By: simonpj

Subscribers: simonpj, rwbarton, carter

GHC Trac Issues: #15502

Differential Revision:

(cherry picked from commit 7a3cda534d1447c813aa37cdd86e20b8d782cb02)

9 months agoRevert "An overhaul of the SRT representation"
Ben Gamari [Wed, 12 Sep 2018 19:17:15 +0000 (15:17 -0400)] 
Revert "An overhaul of the SRT representation"

This reverts commit eb8e692cab7970c495681e14721d05ecadd21581.

9 months agoRevert "Save a word in the info table on x86_64"
Ben Gamari [Wed, 12 Sep 2018 19:14:08 +0000 (15:14 -0400)] 
Revert "Save a word in the info table on x86_64"

This reverts commit 2b0918c9834be1873728176e4944bec26271234a.

9 months agoRevert "Merge FUN_STATIC closure with its SRT"
Ben Gamari [Wed, 12 Sep 2018 19:09:20 +0000 (15:09 -0400)] 
Revert "Merge FUN_STATIC closure with its SRT"

This reverts commit 838b69032566ce6ab3918d70e8d5e098d0bcee02.

9 months agoRevert "Comments and refactoring only"
Ben Gamari [Wed, 12 Sep 2018 19:07:44 +0000 (15:07 -0400)] 
Revert "Comments and refactoring only"

This reverts commit f2d27c1ad69321872a87a37144fe41e815301f5b.

9 months agoRevert "Fix retainer profiling after SRT overhaul"
Ben Gamari [Wed, 12 Sep 2018 19:06:29 +0000 (15:06 -0400)] 
Revert "Fix retainer profiling after SRT overhaul"

This reverts commit d78dde9ff685830bc9d6bb24a158eb31bb8a7028.

9 months agoRevert "Fix a bug in SRT generation"
Ben Gamari [Wed, 12 Sep 2018 19:06:18 +0000 (15:06 -0400)] 
Revert "Fix a bug in SRT generation"

This reverts commit d424d4a46a729f8530e9273282d22b6b8f34daaa.

9 months agoRevert "Disable the SRT offset optimisation on MachO platforms"
Simon Marlow [Thu, 26 Jul 2018 21:19:54 +0000 (17:19 -0400)] 
Revert "Disable the SRT offset optimisation on MachO platforms"

This reverts commit bf10456edaa03dc010821cd4c3d9f49cb11d89da.

9 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:

(cherry picked from commit 36740b4c346c619e31d24d6672caa6f4f7fea123)

9 months agoFix gcCAFs()
Simon Marlow [Thu, 26 Jul 2018 21:19:54 +0000 (17:19 -0400)] 
Fix gcCAFs()

The test here should have been changed after D1106.  It was harmless
but we caught fewer GC'd CAFs than we should have.

Test Plan:
Using `nofib/imaginary/primes` compiled with `-debug`.

> ./primes 100 +RTS -G1 -A32k -DG
CAF gc'd at 0x0x7b0960
CAF gc'd at 0x0x788728
CAF gc'd at 0x0x790db0
CAF gc'd at 0x0x790de0
12 CAFs live
CAF gc'd at 0x0x788880
12 CAFs live
12 CAFs live
12 CAFs live
12 CAFs live
12 CAFs live
12 CAFs live
12 CAFs live
12 CAFs live
12 CAFs live
12 CAFs live
12 CAFs live
CAF gc'd at 0x0x7995c8
13 CAFs live


> ./primes 100 +RTS -G1 -A32k -DG
CAF gc'd at 0x0x7b0960
CAF gc'd at 0x0x788728
CAF gc'd at 0x0x790db0
CAF gc'd at 0x0x790de0
12 CAFs live
CAF gc'd at 0x0x788880
12 CAFs live
12 CAFs live
12 CAFs live
12 CAFs live
12 CAFs live
12 CAFs live
12 CAFs live
12 CAFs live
12 CAFs live
12 CAFs live
12 CAFs live
CAF gc'd at 0x0x7995c8
CAF gc'd at 0x0x790ea0
12 CAFs live

Reviewers: bgamari, osa1, erikd, noamz

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

Differential Revision:

(cherry picked from commit e431d75f8350f25159f9aaa49fe9a504e94bc0a4)

9 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

9 months agorts: Handle SMALL_MUT_ARR_PTRS in retainer profilter
Ben Gamari [Mon, 27 Aug 2018 22:59:17 +0000 (00:59 +0200)] 
rts: Handle SMALL_MUT_ARR_PTRS in retainer profilter

Summary: These can be treated similarly to MUT_ARRY_PTRS. Fixes #15529.

Reviewers: erikd, simonmar

Reviewed By: simonmar

Subscribers: RyanGlScott, rwbarton, carter

GHC Trac Issues: #15529

Differential Revision:

(cherry picked from commit 2cf98e2207421200fc73c25a08f6435859cdff92)

9 months agoFixed typo in exponent example
chris-bacon [Mon, 27 Aug 2018 12:45:47 +0000 (13:45 +0100)] 
Fixed typo in exponent example

(cherry picked from commit 36c1431d9d2d06049190cc0888dbfaee8e2179d6)

9 months agoFix a constant folding rule
Andrey Mokhov [Wed, 29 Aug 2018 13:16:51 +0000 (15:16 +0200)] 
Fix a constant folding rule

One of the constant folding rules introduced in D2858 is:

(L y :-:   v) :-: (L x :-: w) -> return $ mkL (y-x)   `add` (w `add` v)

Or, after removing syntactic noise: `(y - v) - (x - w) ==> (y - x) + (w + v)`.
This is incorrect, since the sign of `v` is changed from negative to positive.
As a consequence, the following program prints `3` when compiled with `-O`:

-- This is just subtraction in disguise
minus :: Int -> Int -> Int
minus x y = (8 - y) - (8 - x)
{-# NOINLINE minus #-}

main :: IO ()
main = print (2 `minus` 1)

The correct rule is: `(y - v) - (x - w) ==> (y - x) + (w - v)`.

This commit does the fix. I haven't found any other issues with the constant
folding code, but it's difficult to be certain without some automated checking.

Reviewers: bgamari, tdammers

Subscribers: hsyl20, tdammers, rwbarton, carter

GHC Trac Issues: #15569

Differential Revision:

(cherry picked from commit 65eec9cfd4410c0e30b0ed06116c15f8ce3de49d)

9 months agoFix typo in 8.6.1 notes
Krzysztof Gogolewski [Tue, 28 Aug 2018 20:31:22 +0000 (22:31 +0200)] 
Fix typo in 8.6.1 notes

(cherry picked from commit 34b8e613606653187f1ffae36a83e33f0c673720)

9 months agoSkip eventlog tests in GHCi way
Ömer Sinan Ağacan [Wed, 5 Sep 2018 11:11:30 +0000 (13:11 +0200)] 
Skip eventlog tests in GHCi way

Summary: (GHCi doesn't generate event logs)

Test Plan:
These tests were failing in GHCi way, they're now skipped in GHCi way as GHCi
doesn't generate eventlogs

Reviewers: bgamari, simonmar, maoe, alpmestan

Reviewed By: alpmestan

Subscribers: rwbarton, carter

GHC Trac Issues: #15587

Differential Revision:

(cherry picked from commit c0e5087d01e2912f00feede6c259a2ee87685c90)

9 months agoFix a race between GC threads in concurrent scavenging
Ömer Sinan Ağacan [Thu, 6 Sep 2018 12:52:53 +0000 (15:52 +0300)] 
Fix a race between GC threads in concurrent scavenging

While debugging #15285 I realized that free block lists (free_list in
BlockAlloc.c) get corrupted when multiple scavenge threads allocate and
release blocks concurrently. Here's a picture of one such race:

    Thread 2 (Thread 32573.32601):
    #0  check_tail
        (bd=0x940d40 <stg_TSO_info>) at rts/sm/BlockAlloc.c:860
    #1  0x0000000000928ef7 in checkFreeListSanity
        () at rts/sm/BlockAlloc.c:896
    #2  0x0000000000928979 in freeGroup
        (p=0x7e998ce02880) at rts/sm/BlockAlloc.c:721
    #3  0x0000000000928a17 in freeChain
        (bd=0x7e998ce02880) at rts/sm/BlockAlloc.c:738
    #4  0x0000000000926911 in freeChain_sync
        (bd=0x7e998ce02880) at rts/sm/GCUtils.c:80
    #5  0x0000000000934720 in scavenge_capability_mut_lists
        (cap=0x1acae80) at rts/sm/Scav.c:1665
    #6  0x000000000092b411 in gcWorkerThread
        (cap=0x1acae80) at rts/sm/GC.c:1157
    #7  0x000000000090be9a in yieldCapability
        (pCap=0x7f9994e69e20, task=0x7e9984000b70, gcAllowed=true) at rts/Capability.c:861
    #8  0x0000000000906120 in scheduleYield
        (pcap=0x7f9994e69e50, task=0x7e9984000b70) at rts/Schedule.c:673
    #9  0x0000000000905500 in schedule
        (initialCapability=0x1acae80, task=0x7e9984000b70) at rts/Schedule.c:293
    #10 0x0000000000908d4f in scheduleWorker
        (cap=0x1acae80, task=0x7e9984000b70) at rts/Schedule.c:2554
    #11 0x000000000091a30a in workerStart
        (task=0x7e9984000b70) at rts/Task.c:444
    #12 0x00007f99937fa6db in start_thread
        (arg=0x7f9994e6a700) at pthread_create.c:463
    #13 0x000061654d59f88f in clone
        () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

    Thread 1 (Thread 32573.32573):
    #0  checkFreeListSanity
        () at rts/sm/BlockAlloc.c:887
    #1  0x0000000000928979 in freeGroup
        (p=0x7e998d303540) at rts/sm/BlockAlloc.c:721
    #2  0x0000000000926f23 in todo_block_full
        (size=513, ws=0x1aa8ce0) at rts/sm/GCUtils.c:264
    #3  0x00000000009583b9 in alloc_for_copy
        (size=513, gen_no=0) at rts/sm/Evac.c:80
    #4  0x000000000095850d in copy_tag_nolock
        (p=0x7e998c675f28, info=0x421d98 <Main_Large_con_info>, src=0x7e998d075d80, size=513,
        gen_no=0, tag=1) at rts/sm/Evac.c:153
    #5  0x0000000000959177 in evacuate
        (p=0x7e998c675f28) at rts/sm/Evac.c:715
    #6  0x0000000000932388 in scavenge_small_bitmap
        (p=0x7e998c675f28, size=1, bitmap=0) at rts/sm/Scav.c:271
    #7  0x0000000000934aaf in scavenge_stack
        (p=0x7e998c675f28, stack_end=0x7e998c676000) at rts/sm/Scav.c:1908
    #8  0x0000000000934295 in scavenge_one
        (p=0x7e998c66e000) at rts/sm/Scav.c:1466
    #9  0x0000000000934662 in scavenge_mutable_list
        (bd=0x7e998d300440, gen=0x1b1d880) at rts/sm/Scav.c:1643
    #10 0x0000000000934700 in scavenge_capability_mut_lists
        (cap=0x1aaa340) at rts/sm/Scav.c:1664
    #11 0x00000000009299b6 in GarbageCollect
        (collect_gen=0, do_heap_census=false, gc_type=2, cap=0x1aaa340, idle_cap=0x1b38aa0)
        at rts/sm/GC.c:378
    #12 0x0000000000907a4a in scheduleDoGC
        (pcap=0x7ffdec5b5310, task=0x1b36650, force_major=false) at rts/Schedule.c:1798
    #13 0x0000000000905de7 in schedule
        (initialCapability=0x1aaa340, task=0x1b36650) at rts/Schedule.c:546
    #14 0x0000000000908bc4 in scheduleWaitThread
        (tso=0x7e998c0067c8, ret=0x0, pcap=0x7ffdec5b5430) at rts/Schedule.c:2537
    #15 0x000000000091b5a0 in rts_evalLazyIO
        (cap=0x7ffdec5b5430, p=0x9c11f0, ret=0x0) at rts/RtsAPI.c:530
    #16 0x000000000091ca56 in hs_main
        (argc=1, argv=0x7ffdec5b5628, main_closure=0x9c11f0, rts_config=...) at rts/RtsMain.c:72
    #17 0x0000000000421ea0 in main

In particular, dbl_link_onto() which is used to add a freed block to a
doubly-linked free list is not thread safe and corrupts the list when
called concurrently.

Note that thread 1 is to blame here as thread 2 is properly taking the
spinlock. With this patch we now take the spinlock when freeing a todo
block in GC, avoiding this race.

Test Plan:
- Tried slow validate locally: this patch does not introduce new failures.
- circleci: The test got killed
  because it took 5 hours but T7919 (which was previously failing on circleci)

Reviewers: simonmar, bgamari, erikd

Reviewed By: simonmar

Subscribers: rwbarton, carter

GHC Trac Issues: #15285

Differential Revision:

(cherry picked from commit c6fbac6a6a69a2f4be89701b2c386ae53214f9a3)

9 months agoBump Cabal submodule to
Ben Gamari [Fri, 7 Sep 2018 11:14:43 +0000 (07:14 -0400)] 
Bump Cabal submodule to

9 months agoDo a final pass over the changelogs
Ben Gamari [Tue, 28 Aug 2018 13:42:39 +0000 (09:42 -0400)] 
Do a final pass over the changelogs

9 months agoExpose the StableName constructor
David Feuer [Tue, 21 Aug 2018 00:08:14 +0000 (20:08 -0400)] 
Expose the StableName constructor

* Move the definition of `StableName` from `System.Mem.StableName`
  to a new `GHC.StableName` module.

* Expose the `StableName` data constructor from `GHC.StableName`.
  Once we have `UnliftedArray#`, this will enable `StableName`s to
  be stored in `UnliftedArray`s (from `primitive`) without unsafe

Reviewers: hvr, bgamari, andrewthad, osa1

Reviewed By: osa1

Subscribers: osa1, rwbarton, carter

GHC Trac Issues: #15535

Differential Revision:

(cherry picked from commit 9c4e6c6b1affd410604f8f76ecf56abfcc5cccb6)

9 months agoProperly designate LambdaCase alts as CaseAlt in TH
Ryan Scott [Tue, 14 Aug 2018 20:35:23 +0000 (22:35 +0200)] 
Properly designate LambdaCase alts as CaseAlt in TH

When `\case` expressions are parsed normally, their
alternatives are marked as `CaseAlt` (which means that they are
pretty-printed without a `\` character in front of them, unlike for
lambda expressions). However, `\case` expressions created by way of
Template Haskell (in `Convert`) inconsistently designated the case
alternatives as `LambdaExpr`, causing them to be pretty-printed
poorly (as shown in #15518). The fix is simple: use `CaseAlt`

Test Plan: make test TEST=T15518

Reviewers: goldfire, bgamari

Subscribers: rwbarton, carter

GHC Trac Issues: #15518

Differential Revision:

(cherry picked from commit 32008a9d0e09f0cc8899aa871d9a6b63fcc28a1a)

9 months agoSuppress redundant givens during error reporting
Ryan Scott [Sun, 12 Aug 2018 15:27:27 +0000 (17:27 +0200)] 
Suppress redundant givens during error reporting

When GHC reports that it cannot solve a constraint in error
messages, it often reports what given constraints it has in scope.
Unfortunately, sometimes redundant constraints (like `* ~ *`,
from  #15361) can sneak in. The fix is simple: blast away these
redundant constraints using `mkMinimalBySCs`.

Test Plan: make test TEST=T15361

Reviewers: simonpj, bgamari

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #15361

Differential Revision:

(cherry picked from commit c552feea127d8ed8cbf4994a157c4bbe254b96c3)

9 months ago--show-iface: Qualify all non-local names
Simon Jakobi [Sun, 12 Aug 2018 09:10:39 +0000 (11:10 +0200)] 
--show-iface: Qualify all non-local names

In order to disambiguate names from different modules, qualify all names
that don't originate in the current module.

Also update docs for QueryQualifyName

Test Plan: validate

Reviewers: simonpj, bgamari

Reviewed By: simonpj

Subscribers: rwbarton, thomie, carter, tdammers

GHC Trac Issues: #15269

Differential Revision:

(cherry picked from commit d42eef344a71990d12f27e88cdf10ba0b2a2f34b)

9 months agoAccommodate API change in transSuperClasses
Simon Peyton Jones [Thu, 23 Aug 2018 08:22:42 +0000 (09:22 +0100)] 
Accommodate API change in transSuperClasses

In this patch

    commit 6eabb6ddb7c53784792ee26b1e0657bde7eee7fb
    Author: Simon Peyton Jones <>
    Date:   Tue Dec 15 14:26:13 2015 +0000

    Allow recursive (undecidable) superclasses

I changed (transSuperClasses p) to return only the
superclasses of p, but not p itself. (Previously it always
returned p as well.)

The use of transSuperClasses in TcErrors.warnRedundantConstraints
really needs 'p' in the result -- but I faild to fix this
call site, and instead crippled the test for Trac #10100.

This patch sets things right

* Accomodates the API change
* Re-enables T10100
* And thereby fixes Trac #11474

(cherry picked from commit 4293a80a3ea835412737911bcb2a6703e9af378b)

9 months agoFix a typo in TcValidity.checkFamInstRhs
Simon Peyton Jones [Wed, 22 Aug 2018 09:00:20 +0000 (10:00 +0100)] 
Fix a typo in TcValidity.checkFamInstRhs

In error message generation we were using the wrong
type constructor in inst_head.  Result: the type became
ill-kinded, and that sent the compiler into a loop.

A separate patch fixes the loop. This patch fixes the
actual bug -- Trac #15473.

I also improved the "occurs more often" error message
a bit.  But it's still pretty terrible:

    * Variable ‘a’ occurs more often
      in the type family application ‘Undefined’
      than in the instance head ‘LetInterleave xs t ts is y z’

It looks like nonsense, but all becomes clear if you use
-fprint-explicit-kinds.  Really we should fix this by spotting
when invisible arguments are involved and at least suggesting

(cherry picked from commit 8c7f90abcc1e8f9f29b751f23174e8db89ba6983)

9 months agoTurn infinite loop into a panic
Simon Peyton Jones [Wed, 22 Aug 2018 08:51:26 +0000 (09:51 +0100)] 
Turn infinite loop into a panic

In these two functions
  * TcIface.toIfaceAppTyArgsX
  * Type.piResultTys
we take a type application (f t1 .. tn) and try to find
its kind. It turned out that, if (f t1 .. tn) was ill-kinded
the function would go into an infinite loop.

That's not good: it caused the loop in Trac #15473.

This patch doesn't fix the bug in #15473, but it does turn the
loop into a decent panic, which is a step forward.

(cherry picked from commit db6f1d9cfc74690798645a7cc5b25040c36bb35d)

9 months agotestsuite: Add (broken) test for #15473
Ben Gamari [Tue, 7 Aug 2018 17:59:31 +0000 (13:59 -0400)] 
testsuite: Add (broken) test for #15473

(cherry picked from commit 5487f305d9dea298f0822082389d8a0225956c55)

9 months agoExplicitly tell 'getNameToInstances' mods to load
Alec Theriault [Tue, 21 Aug 2018 20:03:40 +0000 (16:03 -0400)] 
Explicitly tell 'getNameToInstances' mods to load

Calculating which modules to load based on the InteractiveContext means
maintaining a potentially very large GblRdrEnv.

In Haddock's case, it is much cheaper (from a memory perspective) to
just keep track of which modules interfaces we want loaded then hand
these off explicitly to 'getNameToInstancesIndex'.

Bumps haddock submodule.

Reviewers: alexbiehl, bgamari

Reviewed By: alexbiehl

Subscribers: rwbarton, thomie, carter

Differential Revision:

(cherry picked from commit c971e1193fa44bb507d1806d5bb61768670dc912)

9 months agoCorrect limb length and assertion for gcdExtInteger
DavidEichamnn [Tue, 21 Aug 2018 20:06:45 +0000 (16:06 -0400)] 
Correct limb length and assertion for gcdExtInteger

Reviewers: hvr, bgamari, monoidal

Reviewed By: monoidal

Subscribers: monoidal, rwbarton, thomie, carter

GHC Trac Issues: #15350

Differential Revision:

(cherry picked from commit c331592130ef592b92084e7417581a4039bfa7d2)

9 months agoFix gcdExtInteger (trac#15350)
Bodigrim [Fri, 6 Jul 2018 23:20:10 +0000 (00:20 +0100)] 
Fix gcdExtInteger (trac#15350)

(cherry picked from commit 7c207c86ab0de955ebec70eeeb366ba0d94acc4a)

9 months agorts: Align the_gc_thread to 64 bytes
Ben Gamari [Tue, 21 Aug 2018 20:06:12 +0000 (16:06 -0400)] 
rts: Align the_gc_thread to 64 bytes

In a previous attempt (c6cc93bca69abc258513af8cf2370b14e70fd8fb) I had
tried aligning to 8 bytes under the assumption that the problem was that
the_gc_thread, a StgWord8[], wasn't being aligned to 8-bytes as the
gc_thread struct would expect. However, we actually need even stronger
alignment due to the alignment attribute attached to gen_workspace,
which claims it should be aligned to a 64-byte boundary.

This fixes #15482.

Reviewers: erikd, simonmar

Reviewed By: simonmar

Subscribers: rwbarton, carter

GHC Trac Issues: #15482

Differential Revision:

(cherry picked from commit 68a1fc29b4bb3eae54e4d96c9aec20e700040f34)

9 months agoSet strictness correctly for JoinIds
Simon Peyton Jones [Tue, 21 Aug 2018 08:56:39 +0000 (09:56 +0100)] 
Set strictness correctly for JoinIds

We were failing to keep correct strictness info when eta-expanding
join points; Trac #15517.   The situation was something like

  \q v eta ->
     let j x = error "blah
         -- STR Lx   bottoming!
     in case y of
           A -> j x eta
           B -> blah
           C -> j x eta

So we spot j as a join point and eta-expand it.  But we must
also adjust the stricness info, else it vlaimes to bottom after
one arg is applied but now it has become two.

I fixed this in two places:

 - In CoreOpt.joinPointBinding_maybe, adjust strictness info

 - In SimplUtils.tryEtaExpandRhs, return consistent values
   for arity and bottom-ness

(cherry picked from commit ce6ce788251b6102f5c1b878ffec53ba7ad678b5)