ghc.git
3 years agoDeriving Functor-like classes should unify kind variables ghc-8.0.1-rc3
RyanGlScott [Mon, 11 Apr 2016 00:53:23 +0000 (02:53 +0200)] 
Deriving Functor-like classes should unify kind variables

While the deriving machinery always unifies the kind of the typeclass
argument with the kind of the datatype, this proves not to be sufficient
to produce well kinded instances for some poly-kinded datatypes. For
example:

```
newtype Compose (f :: k2 -> *) (g :: k1 -> k2) (a :: k1)
  = Compose (f (g a)) deriving Functor
```

would fail because only `k1` would get unified with `*`, causing the
following
ill kinded instance to be generated:

```
instance (Functor (f :: k2 -> *), Functor (g :: * -> k2)) =>
  Functor (Compose f g) where ...
```

To prevent this, we need to take the subtypes and unify their kinds with
`* -> *`.

Fixes #10524 for good.

Test Plan: ./validate

Reviewers: simonpj, hvr, austin, bgamari

Subscribers: thomie

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

GHC Trac Issues: #10524, #10561

(cherry picked from commit aadde2b90817c577336da0d4a10ea47551d60c7e)

3 years agoAdded (more) missing instances for Identity and Const
Shane O'Brien [Mon, 11 Apr 2016 00:53:00 +0000 (02:53 +0200)] 
Added (more) missing instances for Identity and Const

  * `Identity` and `Const` now have `Num`, `Real`, `Integral`,
    `Fractional`, `Floating`, `RealFrac` and `RealFloat` instances

  * `Identity` and `Const` now have `Bits` and `FiniteBits` instances

  * `Identity` and `Const` now have `IsString` instances

Reviewers: RyanGlScott, austin, hvr, bgamari, ekmett

Reviewed By: ekmett

Subscribers: nomeata, ekmett, RyanGlScott, thomie

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

GHC Trac Issues: #11790

(cherry picked from commit 8b57cac5974c9fffccbcae3104b5b5d18760749e)

3 years agoFilter out invisible kind arguments during TH reification
RyanGlScott [Mon, 11 Apr 2016 00:34:55 +0000 (02:34 +0200)] 
Filter out invisible kind arguments during TH reification

Previously, all kind arguments were being reified, which would cause
something like this:

```
type Id a = a
data Proxy (a :: Id k) = Proxy
```

to output

```
data Proxy (a :: Id * k) = Proxy
```

when `Proxy`'s `Info` is reified. The fix is simple: simply call
`filterOutInvisibleTypes` on the kind arguments of a kind synonym
application.

Fixes #11463.

Test Plan: ./validate

Reviewers: austin, bgamari, goldfire

Reviewed By: goldfire

Subscribers: thomie

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

GHC Trac Issues: #11463

(cherry picked from commit 02a5c580b6078630842f4c3db5d92631fada21e9)

3 years agoFix a closed type family error message
Rik Steenkamp [Mon, 11 Apr 2016 00:26:06 +0000 (02:26 +0200)] 
Fix a closed type family error message

Now we check whether a closed type family's equation is headed with
the correct type before we kind-check the equation.

Also, instead of "expected only no parameters" we now generate the
message "expected no parameters".

Fixes #11623.

Reviewers: simonpj, austin, bgamari

Reviewed By: simonpj, bgamari

Subscribers: simonpj, goldfire, thomie

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

GHC Trac Issues: #11623

(cherry picked from commit 46e8f199e4d3baffa306a40082fbc2fce67f779f)

3 years agoOmit TEST=T10697_decided_3 WAY=ghci
Thomas Miedema [Fri, 1 Jan 2016 11:46:37 +0000 (12:46 +0100)] 
Omit TEST=T10697_decided_3 WAY=ghci

(cherry picked from commit d935d20988af7f3109b73d7c51a0e4a6b12b926c)

3 years agoChange runtime linker to perform lazy loading of symbols/sections
Tamar Christina [Sun, 10 Apr 2016 22:38:42 +0000 (00:38 +0200)] 
Change runtime linker to perform lazy loading of symbols/sections

The Runtime Linker is currently eagerly loading all object files on all
platforms which do not use the system linker for `GHCi`.

The problem with this approach is that it requires all symbols to be
found.  Even those of functions never used/called. This makes the number
of libraries required to link things like `mingwex` quite high.

To work around this the `rts` was relying on a trick. It itself was
compiled with `MingW64-w`'s `GCC`. So it was already linked against
`mingwex`.  As such, it re-exported the symbols from itself.

While this worked it made it impossible to link against `mingwex` in
user libraries. And with this means no `C99` code could ever run in
`GHCi` on Windows without having the required symbols re-exported from
the rts.

Consequently this rules out a large number of packages on Windows.
SDL2, HMatrix etc.

After talking with @rwbarton I have taken the approach of loading entire
object files when a symbol is needed instead of doing the dependency
tracking on a per symbol basis. This is a lot less fragile and a lot
less complicated to implement.

The changes come down to the following steps:

1) modify the linker to and introduce a new state for ObjectCode:
   `Needed`.  A Needed object is one that is required for the linking to
   succeed.  The initial set consists of all Object files passed as
   arguments to the link.

2) Change `ObjectCode`'s to be indexed but not initialized or resolved.
   This means we know where we would load the symbols,
   but haven't actually done so.

3) Mark any `ObjectCode` belonging to `.o` passed as argument
   as required: ObjectState `NEEDED`.

4) During `Resolve` object calls, mark all `ObjectCode`
   containing the required symbols as `NEEDED`

5) During `lookupSymbol` lookups, (which is called from `linkExpr`
   and `linkDecl` in `GHCI.hs`) is the symbol is in a not-yet-loaded
   `ObjectCode` then load the `ObjectCode` on demand and return the
   address of the symbol. Otherwise produce an unresolved symbols error
   as expected.

6) On `unloadObj` we then change the state of the object and remove
   it's symbols from the `reqSymHash` table so it can be reloaded.

This change affects all platforms and OSes which use the runtime linker.
It seems there are no real perf tests for `GHCi`, but performance
shouldn't be impacted much. We gain a lot of time not loading all `obj`
files, and we lose some time in `lookupSymbol` when we're finding
sections that have to be loaded. The actual finding itself is O(1)
(Assuming the hashtnl is perfect)

It also consumes slighly more memory as instead of storing just the
address of a symbol I also store some other information, like if the
symbol is weak or not.

This change will break any packages relying on renamed POSIX functions
that were re-named and re-exported by the rts. Any packages following
the proper naming for functions as found on MSDN will work fine.

Test Plan: ./validate on all platforms which use the Runtime linker.

Reviewers: thomie, rwbarton, simonmar, erikd, bgamari, austin, hvr

Reviewed By: erikd

Subscribers: kgardas, gridaphobe, RyanGlScott, simonmar,
             rwbarton, #ghc_windows_task_force

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

GHC Trac Issues: #11223

(cherry picked from commit 90538d86af579595987826cd893828d6f379f35a)

3 years agoReduce fragmentation from m32_allocator
Bartosz Nitka [Sun, 6 Mar 2016 21:18:12 +0000 (13:18 -0800)] 
Reduce fragmentation from m32_allocator

This patch brings in two improvements:
a) m32_allocator will now reuse the pages that are no longer
used by anyone else.
b) m32_allocator will preallocate the "filling" area,
so that the pages it allocates end up as a big chunk
instead of being allocated on demand in random places,
fragmenting the precious lower 2G address space.

Test Plan: testsuite - 3 tests failing with substTy asserts

Reviewers: ezyang, austin, bgamari, erikd, hsyl20, simonmar

Reviewed By: hsyl20, simonmar

Subscribers: hvr, thomie

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

(cherry picked from commit 82e36edcbd831e9b7c05e1c2cb918ad5de56cd3a)

3 years agoFix Windows build after D1874
Tamar Christina [Tue, 2 Feb 2016 11:36:52 +0000 (12:36 +0100)] 
Fix Windows build after D1874

Windows uses wchar_t* for paths. The code committed won't compile for
Windows as the types are incorrect and the types in the branches of the
ternary operator aren't consistent.

Test Plan: ./validate --fast

Reviewers: austin, rwbarton, erikd, bgamari

Subscribers: thomie

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

(cherry picked from commit 01c587c03764de52cd01a3464c1a4a5c5bce7c00)

3 years agoFix runtime linker error message when old symbol had no owner
Reid Barton [Mon, 1 Feb 2016 14:43:48 +0000 (09:43 -0500)] 
Fix runtime linker error message when old symbol had no owner

Test Plan: Actually run validate. This fixes test linker_error3.

Reviewers: austin, erikd, bgamari

Reviewed By: erikd, bgamari

Subscribers: thomie

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

(cherry picked from commit 73293109645efe42bf3fdf3335f4ab7cef39001b)

3 years agoWhen encountering a duplicate symbol, show source of the first symbol
Reid Barton [Mon, 1 Feb 2016 00:10:29 +0000 (19:10 -0500)] 
When encountering a duplicate symbol, show source of the first symbol

Test Plan: Used this to track down an issue I was having.

Reviewers: simonmar, austin, erikd, bgamari

Reviewed By: erikd, bgamari

Subscribers: thomie

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

(cherry picked from commit 34519f0811c58cb1fd073fae3f83b6543c69a634)

3 years agoBump haddock submodule
Ben Gamari [Sun, 10 Apr 2016 21:47:42 +0000 (23:47 +0200)] 
Bump haddock submodule

Fixes #11818, where haddock's documentation broke `make install` when
Sphinx is not available.

3 years agoRtsFlags: Un-constify temporary buffer
Ben Gamari [Sun, 10 Apr 2016 21:28:46 +0000 (23:28 +0200)] 
RtsFlags: Un-constify temporary buffer

Otherwise we get a const-ness mismatch when we free the buffer, which
for some reason gcc 5.3 didn't notice.

(cherry picked from commit 378091c9ef6d25a076125f0b82dce1a155c0e8f0)

3 years agoRemove the instantiation check when deriving Generic(1)
RyanGlScott [Sun, 10 Apr 2016 20:59:37 +0000 (22:59 +0200)] 
Remove the instantiation check when deriving Generic(1)

Previously, deriving `Generic(1)` bailed out when attempting to
instantiate visible type parameters (#5939), but this instantiation
check was quite fragile and doesn't interact well with `-XTypeInType`.
It has been decided that `Generic(1)` shouldn't be subjected to this
check anyway, so it has been removed, and `gen_Generic_binds`'s
machinery has been updated to substitute the type variables in a
generated `Rep`/`Rep1` instance with the user-supplied type arguments.

In addition, this also refactors `Condition` in `TcDeriv` a bit. Namely,
since we no longer need `tc_args` to check any conditions, the `[Type]`
component of `Condition` has been removed.

Fixes #11732.

Test Plan: ./validate

Reviewers: goldfire, kosmikus, simonpj, bgamari, austin

Reviewed By: simonpj, bgamari

Subscribers: thomie

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

GHC Trac Issues: #5939, #11732

(cherry picked from commit 7443e5c8dae24b83f5f4975c7accce02b819029c)

3 years agobase: Fix "since" annotation on GHC.ExecutionStack
Ben Gamari [Sun, 10 Apr 2016 18:00:48 +0000 (20:00 +0200)] 
base: Fix "since" annotation on GHC.ExecutionStack

I have no idea where "4.11" came from.

(cherry picked from commit ad532ded871a9a5180388a2b7cdbdc26e053284c)

3 years agoFix suggestions for unbound variables (#11680)
Jason Eisenberg [Sun, 10 Apr 2016 17:17:46 +0000 (19:17 +0200)] 
Fix suggestions for unbound variables (#11680)

When the typechecker generates the error message for an out-of-scope
variable, it now uses the GlobalRdrEnv with respect to which the
variable is unbound, not the GlobalRdrEnv which is available at the time
the error is reported.  Doing so ensures we do not provide suggestions
which themselves are out-of-scope (because they are bound in a later
inter-splice group).

Nonetheless, we do note in the error message if an unambiguous, exact
match to the out-of-scope variable is found in a later inter-splice
group, and we specify where that match is not in scope.

Test Plan: ./validate

Reviewers: goldfire, austin, bgamari

Reviewed By: goldfire

Subscribers: thomie

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

GHC Trac Issues: #11680

(cherry picked from commit 470d4d5b8e7cbcc176b1f3ac26ce0d95acd35a78)

3 years agoExport zonkEvBinds from TcHsSyn.
Conal Elliott [Sun, 10 Apr 2016 17:13:44 +0000 (19:13 +0200)] 
Export zonkEvBinds from TcHsSyn.

Needed for constructing correct constraint-satisfying code
(particularly type class instances) in a Core-to-Core transformation.

Reviewers: simonpj, austin, bgamari

Reviewed By: austin, bgamari

Subscribers: thomie

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

GHC Trac Issues: #11804

(cherry picked from commit 5a1add134fdb2ab4d91b0f66de1dc89f0cd69354)

3 years agoReduce default for -fmax-pmcheck-iterations from 1e7 to 2e6
Herbert Valerio Riedel [Sun, 10 Apr 2016 17:13:16 +0000 (19:13 +0200)] 
Reduce default for -fmax-pmcheck-iterations from 1e7 to 2e6

The commit 28f951edfe50ea5182065144340061ec326781f5 introduced the
`-fmax-pmcheck-iterations` flag and set the default limit to 1e7
iterations.

However, this value is still high enough that it can result GHC to
exhibit memory spikes beyond 1 GiB of RAM usage (heap profile showed
several `(:)`s, as well as `THUNK_2_0`, and `PmCon` during the memory
spikes)

A value of 2e6 seems to be a safer upper bound which still manages to
let the checker not run into the limit in most cases.

Test Plan: Validate, try building a few Hackage packages

Reviewers: austin, gkaracha, bgamari

Reviewed By: bgamari

Subscribers: thomie

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

(cherry picked from commit d2e05c6bd0834421b0c48b3c4287fbe6ee889966)

3 years agoFix Template Haskell bug reported in #11809.
Dominik Bollmann [Sun, 10 Apr 2016 16:57:38 +0000 (18:57 +0200)] 
Fix Template Haskell bug reported in #11809.

Record selectors of data types spliced in with Template Haskell are not
renamer-resolved correctly in GHC HEAD. The culprit is
`newRecordSelector` which violates notes `Note [Binders in Template
Haskell] in Convert.hs` and `Note [Looking up Exact RdrNames] in
RnEnv.hs`. This commit fixes `newRecordSelector` accordingly.

Test Plan: ./validate

Reviewers: thomie, mpickering, bgamari, austin, simonpj, goldfire

Reviewed By: goldfire

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

GHC Trac Issues: #11809

(cherry picked from commit 2f82da761defba2cfdc55ca08d774ca7e1240463)

3 years agoAdd doc to (<=<) comparing its type to (.)
Chris Martin [Sun, 10 Apr 2016 16:55:45 +0000 (18:55 +0200)] 
Add doc to (<=<) comparing its type to (.)

This is another documentation addition similar to D1989, this time
comparing the type of the Kleisli composition operator (<=<) to that
of plain function composition (.).

Reviewers: hvr, austin, bgamari

Reviewed By: bgamari

Subscribers: thomie

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

(cherry picked from commit 90d66dedc3a2d9b03dfd3dc3314d380e2adcf2ea)

3 years agoProvide an optimized replicateM_ implementation #11795
Michael Snoyman [Sun, 10 Apr 2016 16:52:47 +0000 (18:52 +0200)] 
Provide an optimized replicateM_ implementation #11795

In my testing, the worker/wrapper transformation applied here
significantly decreases the number of allocations performed when using
replicateM_. Additionally, this version of the function behaves
correctly for negative numbers (namely, it will behave the same as
replicateM_ 0, which is what previous versions of base have done).

Reviewers: bgamari, simonpj, hvr, austin

Reviewed By: bgamari, simonpj, austin

Subscribers: nomeata, simonpj, mpickering, thomie

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

GHC Trac Issues: #11795

(cherry picked from commit c4a7520ef3a0b5e0e33d66ae1d628af93e0d7590)

3 years agorts: Fix parsing of profiler selectors
Ben Gamari [Thu, 7 Apr 2016 13:26:11 +0000 (15:26 +0200)] 
rts: Fix parsing of profiler selectors

69822f0c5b67161b4d7558081bc94f6f3a7c5dbb broke this as it held on to a
reference into the `arg` string, which is later freed. Humbug.

Test Plan: Try using filtering

Reviewers: austin

Subscribers: thomie

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

GHC Trac Issues: #11810

(cherry picked from commit 535896e58f7fc8d89a5ff34629a3471eac529d93)

3 years agoFix installation of static sphinx assets
Ben Gamari [Wed, 6 Apr 2016 21:40:44 +0000 (23:40 +0200)] 
Fix installation of static sphinx assets

Previously the `_static` and `_sources` directories were installed in
the wrong parents. See #11803

(cherry picked from commit 6b6bebaf2349c51343bec2b8fa0e80b7e42593a6)

3 years agoElaborate test for #11376
Simon Peyton Jones [Mon, 4 Apr 2016 09:34:35 +0000 (10:34 +0100)] 
Elaborate test for #11376

This just adds the Prox stuff from the Description in Trac #11376
to the test case,

The class stuff seems weird becuase the type is ambiguous

(cherry picked from commit b3ecd047c432405b57b429fdeaad43f5dcd1ee24)

3 years agoUpdate pretty submodule
Ben Gamari [Wed, 6 Apr 2016 19:57:23 +0000 (21:57 +0200)] 
Update pretty submodule

3 years agoBump Cabal submodule
Ben Gamari [Wed, 6 Apr 2016 19:49:47 +0000 (21:49 +0200)] 
Bump Cabal submodule

3 years agoBump parallel submodule
Ben Gamari [Wed, 6 Apr 2016 19:40:57 +0000 (21:40 +0200)] 
Bump parallel submodule

3 years agotestsuite: One more 32-bit performance slip
Ben Gamari [Wed, 6 Apr 2016 19:36:52 +0000 (21:36 +0200)] 
testsuite: One more 32-bit performance slip

3 years agotestsuite: Update 32-bit performance numbers
Ben Gamari [Wed, 6 Apr 2016 16:27:52 +0000 (18:27 +0200)] 
testsuite: Update 32-bit performance numbers

It's been quite a while since this has happened for some of our tests.

3 years agoT10870: Skip on 32-bit architectures
Ben Gamari [Wed, 6 Apr 2016 15:12:45 +0000 (17:12 +0200)] 
T10870: Skip on 32-bit architectures

Shifts by amounts greater-than-or-equal-to the word size are undefined.

3 years agoT10272, T4340: Add 32-bit output
Ben Gamari [Wed, 6 Apr 2016 14:51:56 +0000 (16:51 +0200)] 
T10272, T4340: Add 32-bit output

3 years agoSkip TEST=TcCoercibleFail when compiler_debugged
Thomas Miedema [Mon, 29 Feb 2016 12:59:48 +0000 (13:59 +0100)] 
Skip TEST=TcCoercibleFail when compiler_debugged

(cherry picked from commit 49c55e68aae9841c166430ae566b0d9bdc03c99d)

3 years agoDeeply instantiate in :type
Simon Peyton Jones [Mon, 4 Apr 2016 09:18:43 +0000 (10:18 +0100)] 
Deeply instantiate in :type

See Trac #11376 and
 Note [Deeply instantiate in :type] in TcRnDriver

Sadly this showed up one new problem (Trac #11786) and one opportunity
(Trac #11787), so test T11549 is now marked expect-broken on these two.

(cherry picked from commit f2a2b79fa8d1c702b17e195a70734b06625e0153)

3 years agoFix misattribution of `-Wunused-local-binds` warnings
Herbert Valerio Riedel [Tue, 5 Apr 2016 13:15:47 +0000 (15:15 +0200)] 
Fix misattribution of `-Wunused-local-binds` warnings

This fixes a bug where warnings actually controlled by

- `Opt_WarnUnusedMatches`
- `Opt_WarnUnusedTypePatterns`
- `Opt_WarnUnusedTopBinds`

were incorrectly reported as being controlled by
`Opt_WarnUnusedLocalBinds` as well

This bug was introduced in bb5afd3c274011c5ea302210b4c290ec1f83209c
while implementing #10752

Test Plan: ./validate still running -- testsuite output wiggles expected

Reviewers: barrucadu, quchen, austin, bgamari

Reviewed By: bgamari

Subscribers: thomie

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

(cherry picked from commit 003e0802fdc2b38b2c3e96cdd387619d33c44967)

3 years agorts: Make StablePtr derefs thread-safe (#10296)
Jason Eisenberg [Mon, 4 Apr 2016 08:57:39 +0000 (10:57 +0200)] 
rts: Make StablePtr derefs thread-safe (#10296)

Stable pointers can now be safely dereferenced while the stable pointer
table is simultaneously being enlarged.

Test Plan: ./validate

Reviewers: ezyang, austin, bgamari, simonmar

Subscribers: carter, thomie

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

GHC Trac Issues: #10296

(cherry picked from commit 90d7d6086ed6f271a352e784c3bc1d5ecac6052c)

3 years agoDon't infer CallStacks
Eric Seidel [Mon, 4 Apr 2016 10:05:01 +0000 (12:05 +0200)] 
Don't infer CallStacks

We originally wanted CallStacks to be opt-in, but dealing with let
binders complicated things, forcing us to infer CallStacks. It turns
out that the inference is actually unnecessary though, we can let the
wanted CallStacks bubble up to the outer context by refusing to
quantify over them. Eventually they'll be solved from a given CallStack
or defaulted to the empty CallStack if they reach the top.

So this patch prevents GHC from quantifying over CallStacks, getting us
back to the original plan. There's a small ugliness to do with
PartialTypeSignatures, if the partial theta contains a CallStack
constraint, we *do* want to quantify over the CallStack; the user asked
us to!

Note that this means that

  foo :: _ => CallStack
  foo = getCallStack callStack

will be an *empty* CallStack, since we won't infer a CallStack for the
hole in the theta. I think this is the right move though, since we want
CallStacks to be opt-in. One can always write

  foo :: (HasCallStack, _) => CallStack
  foo = getCallStack callStack

to get the CallStack and still have GHC infer the rest of the theta.

Test Plan: ./validate

Reviewers: goldfire, simonpj, austin, hvr, bgamari

Reviewed By: simonpj, bgamari

Subscribers: bitemyapp, thomie

Projects: #ghc

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

GHC Trac Issues: #11573

(cherry picked from commit 7407a66d5bd29aa011f5a4228c6e2b2f7f8ad3f8)

3 years agoBump binary submodule
Ben Gamari [Mon, 4 Apr 2016 09:52:43 +0000 (11:52 +0200)] 
Bump binary submodule

(cherry picked from commit 9b6820cdd6bac8b8346be48224627e3feefa9036)

3 years agoImprove printing of pattern synonym types
Rik Steenkamp [Sat, 2 Apr 2016 19:39:10 +0000 (20:39 +0100)] 
Improve printing of pattern synonym types

Add the function `pprPatSynType :: PatSyn -> SDoc` for printing pattern
synonym types, and remove the ambiguous `patSynType` function. Also,
the types in a `PatSyn` are now tidy.

Haddock submodule updated to reflect the removal of `patSynType` by
mpickering.

Fixes: #11213.

Reviewers: goldfire, simonpj, austin, mpickering, bgamari

Reviewed By: simonpj, mpickering

Subscribers: bollmann, simonpj, thomie

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

GHC Trac Issues: #11213

(cherry picked from commit 72bd7f7be7809076f321a6fca90024e3e1bde3cc)

3 years agoMake the example for -M work
Bartosz Nitka [Fri, 1 Apr 2016 20:03:17 +0000 (13:03 -0700)] 
Make the example for -M work

`ghc` fails without `-dep-suffix ''`.

Test Plan: visual inspection

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: thomie, simonmar

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

(cherry picked from commit 38068913c13fa64bd776fab6cf0e971c1a18b54d)

3 years agoRevert accidental change to collectTyAndValBinders
Simon Peyton Jones [Thu, 31 Mar 2016 09:47:47 +0000 (10:47 +0100)] 
Revert accidental change to collectTyAndValBinders

Richard accidetally introduced this change in his big kind-equality
patch.  The code is wrong, and potentially could cause binders to
be re-ordered.

Worth merging to 8.0.

(cherry picked from commit da260a5bddf990959f639a3551b335ee26c766f6)

3 years agoAlways do eta-reduction
Simon Peyton Jones [Thu, 11 Feb 2016 10:38:33 +0000 (10:38 +0000)] 
Always do eta-reduction

See Note [Eta-reduction in -O0] in DynFlags.

Bottom line: doing eta reduction unconditionally is benign, and
removes an ASSERT failure (Trac #11562).

(cherry picked from commit 850085555a1103810d57f0d9835f4d525fd8ec00)

3 years agoAdd -f(no-)version-macro to explicitly control macros.
Edward Z. Yang [Wed, 30 Mar 2016 19:44:09 +0000 (21:44 +0200)] 
Add -f(no-)version-macro to explicitly control macros.

Test Plan: validate

Reviewers: thomie, austin, bgamari

Reviewed By: bgamari

Subscribers: hvr

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

GHC Trac Issues: #11763

(cherry picked from commit bc953fcdbc76ffbb4f06a2b74be271268f73328f)

3 years agoDon't require -hide-all-packages for MIN_VERSION_* macros
Thomas Miedema [Wed, 30 Mar 2016 19:43:51 +0000 (21:43 +0200)] 
Don't require -hide-all-packages for MIN_VERSION_* macros

Define MIN_VERSION_pkgname and VERSION_pkgname macros for all exposed
packages, without requiring -hide-all-packages.

See #10970 comment 7-10 for discussion.

Reviewers: duncan, ezyang, bgamari, austin

Reviewed By: ezyang

Subscribers: hvr, rwbarton

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

GHC Trac Issues: #10970

(cherry picked from commit e9c2555ac666912f7dff56448ced4bfa06d14e76)

3 years agorts/posix/Itimer.c: Handle EINTR when reading timerfd
Erik de Castro Lopo [Mon, 28 Mar 2016 03:29:37 +0000 (14:29 +1100)] 
rts/posix/Itimer.c: Handle EINTR when reading timerfd

Commit 8626d76a72 added checking of the return value when reading from
the `timer_fd` and calling `sysErrorBelch` to print a warning message.
However some error causes (like EINTR) are benign and should just be
ignored.

Test Plan: validate

Reviewers: hvr, austin, bgamari

Subscribers: thomie

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

(cherry picked from commit 7aa4c52f9df1705258f43f9c003c17af97401693)

3 years agoDon't recompute some free vars in lintCoercion
Bartosz Nitka [Wed, 30 Mar 2016 02:37:54 +0000 (19:37 -0700)] 
Don't recompute some free vars in lintCoercion

As pointed out by @simonpj on D2044 we don't need
to compute the free vars of the range of the substitution
as most of them are already carried by the monad.
This should be a tiny performance improvement over the version
from before D2044.

Also removes an extra function that is now unnecessary.

Test Plan: ./validate && ./validate --slow

Reviewers: goldfire, simonpj, austin, bgamari

Reviewed By: simonpj

Subscribers: thomie, simonmar, simonpj

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

GHC Trac Issues: #11371

(cherry picked from commit 1757dd8ebed0732018319e43e6468b868a6aceeb)

3 years agoDo not claim that -O2 does not do better than -O
Joachim Breitner [Wed, 30 Mar 2016 14:09:36 +0000 (16:09 +0200)] 
Do not claim that -O2 does not do better than -O

when in fact it does. This was pointed out by Johannes Bechberger and
supported with seemingly statistically sound evidence in his Bachelor
thesis: Of the benchmark shootout programs, 80% benefit significantly by
switchtng from -O to -O2.

See https://uqudy.serpens.uberspace.de/blog/2016/02/08/ghc-performance-over-time/
for a few raw numbers.

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

(cherry picked from commit 3d245bf5255ebfb72813596fa93b9051f7518321)

3 years agoDrop Xcode 4.1 hack and fix ignored CC var issue
Herbert Valerio Riedel [Mon, 28 Mar 2016 10:55:21 +0000 (12:55 +0200)] 
Drop Xcode 4.1 hack and fix ignored CC var issue

Xcode 4.1 was released back in 2011 for Mac OSX 10.6/10.7.
However, OSX 10.7 reached EOL sometime around the end of 2014.
So this `--with-gcc-4.2` hack shouldn't be needed anymore.

Moreover, this patch changes ./configure to honor the CC env-var
again (and thus fix #11231) while giving `--with-gcc=...` a higher
priority over `CC=...`.

So the following 3 invocations are equivalent now:

  CC=... ./configure
  ./configure CC=...
  ./configure --with-gcc=...

Since `--with-{gcc,clang}=...` is a misnomer (as is made apparent by
`--with-gcc=clang` or `--with-clang=gcc`), this would give us a neutral
and idiomatic way to tell ./configure which C compiler to use.

Moreover, `./configure --help` says at the end of its output:

  Some influential environment variables:
    CC C compiler command
    CFLAGS C compiler flags
    LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a
nonstandard directory <lib dir>
    LIBS libraries to pass to the linker, e.g. -l<library>
    CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
you have headers in a nonstandard directory <include dir>
    CPP C preprocessor

  Use these variables to override the choices made by `configure' or to help
  it to find libraries and programs with nonstandard names/locations.

Consequently, by honoring CC=... (rather than ignoring it) we increase
consistency and reduce user confusion. Ideally, CC=... would become the
recommended way to set the C compiler, and `--with-{clang,gcc}=...`
would be demoted to legacy aliases.

Reviewed By: erikd, bgamari

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

(cherry picked from commit ffc802e8f617d11de9ece7bed438725bde0300b8)

3 years agoghc-prim: Mark unpackCStringUtf8# and unpackNBytes# as NOINLINE
Ben Gamari [Wed, 30 Mar 2016 08:29:02 +0000 (10:29 +0200)] 
ghc-prim: Mark unpackCStringUtf8# and unpackNBytes# as NOINLINE

There is no benefit to be had from inlining this function and it may
defeat rewrite rules if inlined early. See #11772..

Test Plan: Validate, nofib

Reviewers: simonpj, austin

Subscribers: thomie

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

GHC Trac Issues: #11772

(cherry picked from commit 58bbb40ba23860df2ede1275493ef32ba69a2083)

3 years agoDefer inlining of Ord methods
Ben Gamari [Wed, 30 Mar 2016 08:46:39 +0000 (10:46 +0200)] 
Defer inlining of Ord methods

This performs the same refactoring performed in D1980 for Eq on Ord,
rewriting the class operations in terms of monomorphic helpers than can
be reliably matched in rewrite rules.

(cherry picked from commit c0e3e63eca6b0f7a21ae51d992c88821195ad94d)

3 years agoghc-prim: Delay inlining of {gt,ge,lt,le}Int to phase 1
Ben Gamari [Wed, 30 Mar 2016 08:09:36 +0000 (10:09 +0200)] 
ghc-prim: Delay inlining of {gt,ge,lt,le}Int to phase 1

Otherwise rewrite rules may not get an opporunity to fire.

(cherry picked from commit d1179c4bff6d05cc9e86eee3e2d2cee707983c90)

3 years agoRTS: Fix & refactor "portable inline" macros
Herbert Valerio Riedel [Fri, 25 Mar 2016 23:59:31 +0000 (00:59 +0100)] 
RTS: Fix & refactor "portable inline" macros

Turns out the current macros for gnu90-style inline
semantics stopped working with GCC 5
(and possibly also with Apple's GCC) which switched on
`__GNUC_STDC_INLINE__` by default falling back to using the
suboptimal `static inline` mode.

However, C99 supports an equivalent (as far as our
use-case is concerned) `extern inline` mode.

See also
http://www.greenend.org.uk/rjk/tech/inline.html
for a write-up of gnu90 vs C99 semantics.

This patch also removes the MSVC case as VS2015 is supposed
to finally catch up to C99 (and C11), so we don't need any
special care for MSVC anymore.

Reviewed By: erikd, austin

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

(cherry picked from commit 882179de09f9bd466b0e7ca83522aee0d3d7144a)

3 years agobase: Fix haddock typo
Ben Gamari [Tue, 29 Mar 2016 16:59:57 +0000 (18:59 +0200)] 
base: Fix haddock typo

(cherry picked from commit eb6b7094c80fda5cc7c1d1ed3386486996f24bff)

3 years agousers-guide/rel-notes: Note broken-ness of ImpredicativeTypes
Ben Gamari [Tue, 29 Mar 2016 14:30:29 +0000 (16:30 +0200)] 
users-guide/rel-notes: Note broken-ness of ImpredicativeTypes

(cherry picked from commit ae6a56ee467d675776be75dc982f5efb2135d3d4)

3 years agorename: Disallow type signatures in patterns in plain Haskell
Ben Gamari [Tue, 29 Mar 2016 12:11:57 +0000 (14:11 +0200)] 
rename: Disallow type signatures in patterns in plain Haskell

This should require -XScopedTypeVariables. It seems this was previously
handled by RnTypes.rnHsBndrSig which called RnTypes.badKindSigErr but
this was broken in Simon's refactor of wildcards,
1e041b7382b6aa329e4ad9625439f811e0f27232. Here we re-introduce a check
in RnPat. See #11663.

Test Plan: Validate with `T11663`

Reviewers: austin, simonpj

Reviewed By: austin

Subscribers: thomie

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

GHC Trac Issues: #11663

(cherry picked from commit d5d6804d37960ece2652196f3661604a70c12ffc)

3 years agobase: Add comment noting import loop
Ben Gamari [Tue, 29 Mar 2016 11:34:45 +0000 (13:34 +0200)] 
base: Add comment noting import loop

(cherry picked from commit b0ab8db61568305f50947058fc5573e2382c84eb)

3 years agoAdd Data.Functor.Classes instances for Proxy (trac issue #11756)
Andrew Martin [Tue, 29 Mar 2016 08:57:47 +0000 (10:57 +0200)] 
Add Data.Functor.Classes instances for Proxy (trac issue #11756)

Test Plan: currently no test plan

Reviewers: hvr, RyanGlScott, bgamari, austin

Reviewed By: RyanGlScott, bgamari, austin

Subscribers: thomie, RyanGlScott, andrewthad

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

GHC Trac Issues: #11756

(cherry picked from commit 5097f3802124cfbe6810bff8110df91d4c52096b)

3 years agoUse the correct substitution in lintCoercion
Bartosz Nitka [Tue, 29 Mar 2016 10:42:32 +0000 (12:42 +0200)] 
Use the correct substitution in lintCoercion

We need the free vars of `t2` to satisfy the substitution
invariant. Luckily they are in the in-scope carried around.

Test Plan: ./validate

Reviewers: bgamari, austin, goldfire, simonpj

Reviewed By: simonpj

Subscribers: thomie, simonmar

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

GHC Trac Issues: #11371

(cherry picked from commit 4a93e4f9a86a62d1cdf2e666f977b8b58e61eaaf)

3 years agoBuild correct substitution in instDFunType
Bartosz Nitka [Tue, 29 Mar 2016 10:42:16 +0000 (12:42 +0200)] 
Build correct substitution in instDFunType

We will use `ty` in the range of the substitution, hence
the substitution needs `ty`'s free vars in-scope.
They don't seem easily available by other means, so we
just compute them.

Test Plan: ./validate

Reviewers: austin, goldfire, bgamari, simonpj

Reviewed By: simonpj

Subscribers: thomie, simonmar

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

GHC Trac Issues: #11371

(cherry picked from commit a49228e3b6e3737da750bce59ec721b3b2f18eed)

3 years agoUse a correct substitution in tcInstType
Bartosz Nitka [Tue, 29 Mar 2016 10:41:59 +0000 (12:41 +0200)] 
Use a correct substitution in tcInstType

`ty` doesn't have to be a closed type, so we need to add its
free vars to the in-scope set. They don't seem to be
available anywhere nearby, so we have to compute them.

Test Plan: ./validate

Reviewers: goldfire, austin, bgamari, simonpj

Reviewed By: simonpj

Subscribers: thomie, simonmar

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

GHC Trac Issues: #11371

(cherry picked from commit 73935326e0cf85ed077b9ab7dd8f197d39e2cd5b)

3 years agousers-guide: Add references to various issues in bugs section
Ben Gamari [Tue, 29 Mar 2016 08:58:04 +0000 (10:58 +0200)] 
users-guide: Add references to various issues in bugs section

Test Plan: Read it

Reviewers: austin

Reviewed By: austin

Subscribers: thomie

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

GHC Trac Issues: #7411, #11197, #11554, #11715

(cherry picked from commit aa611746aa860e1884c9ad623d6939791f2645ff)

3 years agousers-guide: Wibbles
Ben Gamari [Mon, 28 Mar 2016 13:40:34 +0000 (15:40 +0200)] 
users-guide: Wibbles

(cherry picked from commit eb8bc4dadb767729ae267db7ec7d3bee29f48463)

3 years agousers-guide: Provide more depth in table-of-contents
Ben Gamari [Mon, 28 Mar 2016 12:57:56 +0000 (14:57 +0200)] 
users-guide: Provide more depth in table-of-contents

Per Simon's request.

(cherry picked from commit 415b706ceb6fa3be55e7c96d8bafb0e98ce184b1)

3 years agobase: Document caveats about Control.Concurrent.Chan
Erik de Castro Lopo [Mon, 28 Mar 2016 12:52:35 +0000 (14:52 +0200)] 
base: Document caveats about Control.Concurrent.Chan

These are implemented using `MVars` which have known caveats. Suggest
the use of `TChan` from the stm library instead.

Test Plan: n/a

Reviewers: austin, hvr, bgamari

Reviewed By: bgamari

Subscribers: thomie

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

(cherry picked from commit 0f0c1387882be6a19af2cf3e6a005d70a3e84ae7)

3 years agoUpdate bytestring submodule to latest snapshot
Herbert Valerio Riedel [Mon, 28 Mar 2016 15:28:49 +0000 (17:28 +0200)] 
Update bytestring submodule to latest snapshot

Most notably, this pulls in the following changes

> Fix breakByte and spanByte rewrite rules
> Implement `stripPrefix`/`stripSuffix`

The first patch is related to #11688

(cherry picked from commit eb25381da2e4a95337ad9c2fabff60d699b41bc7)

3 years agoPanic: Try outputting SDocs
Ben Gamari [Fri, 25 Mar 2016 23:42:27 +0000 (00:42 +0100)] 
Panic: Try outputting SDocs

This works in conjunction with D2036 to allow useful debug output before
DynFlags has been initializated.

See #11755.

Reviewers: austin

Reviewed By: austin

Subscribers: thomie, gridaphobe

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

GHC Trac Issues: #11755

3 years agoDynFlags: Initialize unsafeGlobalDynFlags enough to be useful
Ben Gamari [Fri, 25 Mar 2016 23:42:11 +0000 (00:42 +0100)] 
DynFlags: Initialize unsafeGlobalDynFlags enough to be useful

Previously unsafeGlobalDynFlags would bottom if used prior to
initialization. This meant that any attempt to use the pretty-printer
early in the initialization process of the compiler would fail. This is
quite inconvenient.

Here we initialize unsafeGlobalDynFlags with defaultDynFlags, bottoming
only if settings is accessed.

See #11755.

Test Plan: Validate

Reviewers: austin

Reviewed By: austin

Subscribers: thomie, gridaphobe

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

GHC Trac Issues: #11755

3 years agoFix AIX/ppc codegen in `-prof` compilation mode
Herbert Valerio Riedel [Sun, 27 Mar 2016 21:41:12 +0000 (23:41 +0200)] 
Fix AIX/ppc codegen in `-prof` compilation mode

The implementation in df26b95559fd467abc0a3a4151127c95cb5011b9
wrongly assumed that all C-ABI subroutine calls would use a
'ForeignLabel' but it turns out that calls inserted via
'emitRtsCall' use 'CmmLabel's instead.

(cherry picked from commit 61df7f8fb4e76fc8987c0b4f02aa9ec795be7afb)

3 years agoDWARF: Add debugging information chapter to users guide
Ben Gamari [Fri, 25 Mar 2016 23:44:21 +0000 (00:44 +0100)] 
DWARF: Add debugging information chapter to users guide

Test Plan: Proof-read

Reviewers: scpmw, austin

Subscribers: simonmar, thomie

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

(cherry picked from commit 1b4d1201d6fe395db2b268ca111baa69d96ce211)

3 years agoClarify Note [Kind coercions in Unify]
Richard Eisenberg [Fri, 25 Mar 2016 21:25:25 +0000 (17:25 -0400)] 
Clarify Note [Kind coercions in Unify]

(cherry picked from commit 9f73e46c0f34b8b5e8318e6b488b7dade7db68e3)

3 years agoCheck for rep poly on wildcard binders.
Richard Eisenberg [Fri, 25 Mar 2016 20:18:09 +0000 (16:18 -0400)] 
Check for rep poly on wildcard binders.

I had just missed this case when adding my test.
This is relevant to ticket #11473.

Also adds lots of comments.

(cherry picked from commit 12a76bebe0864cdf1c9088ed16175d7b34369e24)

3 years agoFix #11754 by adding an additional check.
Richard Eisenberg [Fri, 25 Mar 2016 19:11:24 +0000 (15:11 -0400)] 
Fix #11754 by adding an additional check.

This was just plain wrong previously.

Test case: typecheck/should_compile/T11754

(cherry picked from commit 4da8e73d5235b0000ae27aa8ff8438a3687b6e9c)

3 years agoRemove now obsolete LD_STAGE0 hack
Herbert Valerio Riedel [Sun, 27 Mar 2016 18:03:33 +0000 (20:03 +0200)] 
Remove now obsolete LD_STAGE0 hack

This was introduced in 109a1e53287f50103e8a5b592275940b6e3dbb53
but isn't needed anymore because by now we're bootstrapping with
GHC versions which already provide "ld command" in `ghc --info`
(that field was added in GHC 7.8)

(cherry picked from commit 06cd26b92a4dfe1f5036440085c602da798d5146)

3 years agoMake it compile with ghc-7.8
Erik de Castro Lopo [Fri, 25 Mar 2016 04:45:17 +0000 (15:45 +1100)] 
Make it compile with ghc-7.8

* Fix `getAllocationCounter` workaround for ghc-7.8.
* Replace `pure` with `return`.

3 years agoMore clarification in docs for implicit quantification
Simon Peyton Jones [Fri, 25 Mar 2016 10:41:57 +0000 (10:41 +0000)] 
More clarification in docs for implicit quantification

This is a follow-up patch to the previous one for #11726.
It turns out that I'd missed the point of the ticket; this
patch addresses it.

(cherry picked from commit 454585c6802f0de4d23f9f16de591596533503b7)

3 years agoDocument implicit quantification better
Simon Peyton Jones [Fri, 25 Mar 2016 10:32:13 +0000 (10:32 +0000)] 
Document implicit quantification better

Addresses Trac #11726

(cherry picked from commit da4bc0cff142225ed7fda7101cb6e559f025ebc1)

3 years agoCorePrep: refactoring to reduce duplication
Simon Peyton Jones [Fri, 25 Mar 2016 09:25:34 +0000 (09:25 +0000)] 
CorePrep: refactoring to reduce duplication

There's no functional change here, just tidying up

(cherry picked from commit 12372baae6ff10c671ef50f3d681cffdf60e36ee)

3 years agoDo not eta-reduce across Ticks in CorePrep
Simon Peyton Jones [Fri, 25 Mar 2016 09:23:17 +0000 (09:23 +0000)] 
Do not eta-reduce across Ticks in CorePrep

The function tryEtaReducePrep was being over-ambitious.
When Breakpoint ticks were involved (i.e. in GHCi), eta
reduction left an out-of-scope variable in the Tick.

Easily fixed. Fixes the original report in Trac #111728.

(cherry picked from commit 356e5e03e63558019fd0571b6c462740aceb7810)

3 years agobase: Fix GHC.Word and GHC.Int on 32-bit platforms
Ben Gamari [Thu, 24 Mar 2016 23:48:22 +0000 (00:48 +0100)] 
base: Fix GHC.Word and GHC.Int on 32-bit platforms

Due to a cut-and-paste error D1980 (#11688) broke 32-bit platforms. This
should fix it.

See #11750.

(cherry picked from commit 26f86f3d397159f9c0db0b59766138f553ba5a86)

3 years agoAdd NCG support for AIX/ppc32
Herbert Valerio Riedel [Thu, 24 Mar 2016 20:00:17 +0000 (21:00 +0100)] 
Add NCG support for AIX/ppc32

This extends the previous work to revive the unregisterised GHC build
for AIX/ppc32. Strictly speaking, AIX runs on POWER4 (and later)
hardware, but the PPC32 instructions implemented in the PPC NCG
represent a compatible subset of the POWER4 ISA.

IBM AIX follows the PowerOpen ABI (and shares many similiarites with the
Linux PPC64 ELF V1 NCG backend) but uses the rather limited XCOFF
format (compared to ELF).

This doesn't support dynamic libraries yet.

A major limiting factor is that the AIX assembler does not support the
`@ha`/`@l` relocation types nor the ha16()/lo16() functions Darwin's
assembler supports. Therefore we need to avoid emitting those. In case
of numeric literals we simply compute the functions ourselves, while for
labels we have to use local TOCs and hope everything fits into a 16bit
offset (for ppc32 this gives us at most 16384 entries per TOC section,
which is enough to compile GHC).

Another issue is that XCOFF doesn't seem to have a relocation type for
label-differences, and therefore the label-differences placed into
tables-next-to-code can't be relocated, but the linker may rearrange
different sections, so we need to place all read-only sections into the
same `.text[PR]` section to workaround this.

Finally, the PowerOpen ABI distinguishes between function-descriptors
and actualy entry-point addresses. For AIX we need to be specific when
emitting assembler code whether we want the address of the function
descriptor `printf`) or for the entry-point (`.printf`). So we let the
asm pretty-printer prefix a dot to all emitted subroutine
calls (i.e. `BL`) on AIX only. For now, STG routines' entry-point labels
are not prefixed by a label and don't have any associated
function-descriptor.

Reviewers: austin, trommler, erikd, bgamari

Reviewed By: trommler, erikd, bgamari

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

(cherry picked from commit df26b95559fd467abc0a3a4151127c95cb5011b9)

3 years agoTidy up handling of coercion variables
Simon Peyton Jones [Thu, 24 Mar 2016 17:31:12 +0000 (17:31 +0000)] 
Tidy up handling of coercion variables

* Comments to explain that a CoVar, whose IdInfo is CoVarId,
  is always unlifted (but may be nominal or representational role)

  And TyCoRep.isCoercionType picks out only those unlifted
  types, NOT the lifted versions

* Introduce Var.NcId for non-co-var Ids
  with predicate isNonCoVarId

* Add assertions in CoreSubst that the Id env is only
  used for NcIds

* Fix lurking bug in CSE which extended the
  CoreSubst Id env with a CoVar

* Fix two bugs in Specialise.spec_call, which wrongly treated
  CoVars like NcIds
    - needed a varToCoreExpr in one place
    - needed extendSubst not extendIdSubst in another
  This was the root cause of Trac #11644

Minor refactoring

* Eliminate unused mkDerivedLocalCoVarM, mkUserLocalCoVar
* Small refactor in mkSysLocalOrCoVar

(cherry picked from commit cb08f8da37ff5fb99e1d02b8afdcb802d23e9a8d)

3 years agousers_guide: small improvements on pattern synonyms.
Dominik Bollmann [Thu, 24 Mar 2016 21:32:56 +0000 (22:32 +0100)] 
users_guide: small improvements on pattern synonyms.

Since the order of required and provided constraint contexts of pattern
synonyms has been switched recently, I updated a couple places in the
users guide's pattern synonym section to accommodate for this.

Test Plan: read it :-)

Reviewers: goldfire, thomie, mpickering, simonpj, austin, bgamari

Reviewed By: bgamari

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

(cherry picked from commit 173a5d8ee4d3d8b7ddd2e8b81c957d03441c4f2b)

3 years agousers-guide: Add -Wredundant-constraints to flags reference
Ben Gamari [Thu, 24 Mar 2016 21:32:20 +0000 (22:32 +0100)] 
users-guide: Add -Wredundant-constraints to flags reference

Test Plan: Validate and read

Reviewers: austin

Subscribers: thomie

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

GHC Trac Issues: #11741

(cherry picked from commit 8ff6518b5af1b357eb043ac46f9209bd0019a193)

3 years agousers_guide: Fix various issues
Ben Gamari [Thu, 24 Mar 2016 21:32:04 +0000 (22:32 +0100)] 
users_guide: Fix various issues

Sphinx apparently expects references to anchors that don't accompany a
header to have a caption.

Test Plan: validate

Reviewers: austin

Subscribers: thomie

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

(cherry picked from commit 2cebbe657afd6a3c31dd1d2b7d04978525c27a56)

3 years agoAdd test for incompatible flags (issue #11580)
Kai Harries [Sun, 20 Mar 2016 16:51:39 +0000 (17:51 +0100)] 
Add test for incompatible flags (issue #11580)

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: thomie

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

GHC Trac Issues: #11580

(cherry picked from commit 289d57a6894b5d3eb5daf696a75275a8146f0092)

3 years agoDefine tyConRolesRepresentational and use it
Simon Peyton Jones [Mon, 8 Feb 2016 17:41:58 +0000 (17:41 +0000)] 
Define tyConRolesRepresentational and use it

tyConRolesRepresentational is just a version of tyConRolesX, but
specialised for a Representational argument. Saves a bit of extra
argument passing and pattern matching, and tyConRolesX was often
called when we knew the argument role was Representational.

Rather to my surprise this made the compiler allocate 5% less
for tests T9872{b,c,d}.  At least I think it's this commit.
Good thing, regardless.

3 years agoDefer inlining of Eq for primitive types
Ben Gamari [Thu, 24 Mar 2016 10:24:32 +0000 (11:24 +0100)] 
Defer inlining of Eq for primitive types

Summary:
This is one solution to #11688, wherein (==) was inlined to soon
defeating a rewrite rule provided by bytestring. Since the RHSs of Eq's
methods are simple, there is little to be gained and much to be lost by
inlining them early.

For instance, the bytestring library provides,

```lang=haskell
break :: (Word8 -> Bool) -> ByteString -> (ByteString, ByteString)
breakByte :: Word8 -> ByteString -> (ByteString, ByteString)
```

and a rule

```
forall x. break ((==) x) = breakByte x
```

since `breakByte` implments an optimized version of `break (== x)` for
known `x :: Word8`. If we allow `(==)` to be inlined too early, we will
prevent this rule from firing. This was the cause of #11688.

This patch just defers the `Eq` methods, although it's likely worthwhile
giving `Ord` this same treatment. This regresses compiler allocations
for T9661 by about 8% due to the additional inlining that we now require
the simplifier to perform.

Updates the `bytestring` submodule to include updated rewrite rules
which match on `eqWord8` instead of `(==)`.

Test Plan:
 * Validate, examine performance impact

Reviewers: simonpj, hvr, austin

Subscribers: thomie

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

GHC Trac Issues: #11688

(cherry picked from commit 0bd0c31e833055eb3e86177f70c4b4d93d5a1c11)

3 years agoDefault RuntimeRep variables unless -fprint-explicit-runtime-reps
Ben Gamari [Thu, 24 Mar 2016 10:39:59 +0000 (11:39 +0100)] 
Default RuntimeRep variables unless -fprint-explicit-runtime-reps

Summary:
Addresses #11549 by defaulting `RuntimeRep` variables to `PtrRepLifted`
and adding a new compiler flag `-fprint-explicit-runtime-reps` to
disable this behavior.

This is just a guess at the right way to go about this. If it's
wrong-beyond-any-hope just say so.

Test Plan: Working on a testcase

Reviewers: goldfire, austin

Subscribers: simonpj, thomie

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

GHC Trac Issues: #11549

(cherry picked from commit 371608f1cdaf20c49eb6c5ec165b9eb08b745a89)

3 years agoShow: Restore redundant parentheses around records
Ben Gamari [Thu, 24 Mar 2016 09:54:11 +0000 (10:54 +0100)] 
Show: Restore redundant parentheses around records

As discussed in #2530 we are going to continue to produce parentheses
here in order to preserve compatibility with previous GHC releases. It
was found that dropped parentheses would break some testsuites which
compared against output from Show. This has been documented in the users
guide.

This reverts commit 5692643c9d17e746327588cd6157a923642b7975.

Test Plan: Validate

Reviewers: hvr, austin

Subscribers: thomie

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

GHC Trac Issues: #2350

(cherry picked from commit 1448f8ab2379452312f1f74f6d5ba4de8ad3d47e)

3 years agoErrUtils: Emulate getAllocationCounter on GHC 7.8
Ben Gamari [Thu, 24 Mar 2016 12:08:34 +0000 (13:08 +0100)] 
ErrUtils: Emulate getAllocationCounter on GHC 7.8

3 years agoCreate empty dump files (fixes #10320)
Kai Harries [Wed, 23 Mar 2016 15:21:52 +0000 (16:21 +0100)] 
Create empty dump files (fixes #10320)

Test Plan: ./validate

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: thomie

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

GHC Trac Issues: #10320

(cherry picked from commit 9f9345e5ad55e4a02e6de9afac814ac58c852ff2)

3 years agoDsExpr: Rip out static/dynamic check in list desugaring
Ben Gamari [Wed, 23 Mar 2016 16:24:45 +0000 (17:24 +0100)] 
DsExpr: Rip out static/dynamic check in list desugaring

Previously we would try to break explicit lists into a dynamic prefix
and static tail and desugar the former into a `build` expression.
Unfortunately, this heuristic resulted in surprising behavior
(see #11710) and wasn't pulling its weight. Here we drop it (along with
the `-fsimple-list-literals` flag), leaving only the list length
heuristic to determine whether `build` or cons list desugaring should be
used.

Test Plan: Validate

Reviewers: simonpj, austin

Reviewed By: simonpj

Subscribers: thomie

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

GHC Trac Issues: #11710

(cherry picked from commit 0db05941668814094c2b18b3d35e1deaed36c210)

3 years agoClose ticky profiling file stream after printing (#9405)
Flaviu Andrei Csernik [Wed, 23 Mar 2016 15:18:11 +0000 (16:18 +0100)] 
Close ticky profiling file stream after printing (#9405)

Test Plan: T9405

Reviewers: simonmar, austin, bgamari

Reviewed By: simonmar, bgamari

Subscribers: thomie

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

GHC Trac Issues: #9405

(cherry picked from commit 2708c22b8c8a415446d963575c0396a038b43a93)

3 years agoAdd `PatSynSigSkol` and modify `PatSynCtxt`
Rik Steenkamp [Wed, 23 Mar 2016 15:17:27 +0000 (16:17 +0100)] 
Add `PatSynSigSkol` and modify `PatSynCtxt`

As the type of a pattern synonym cannot in general be represented by a
value of type Type, we cannot use a value `SigSkol (PatSynCtxt n) (Check
ty)` to represent the signature of a pattern synonym (this causes
incorrect signatures to be printed in error messages). Therefore we now
represent it by a value `PatSynSigSkol n` (instead of incorrect
signatures we simply print no explicit signature).

Furthermore, we rename `PatSynCtxt` to `PatSynBuilderCtxt`, and use
`SigSkol (PatSynBuilderCtxt n) (Check ty)` to represent the type of a
bidirectional pattern synonym when used in an expression context.
Before, this type was represented by a value `SigSkol (PatSynCtxt n)
(Check ty)`, which caused incorrect error messages.

Also, in `mk_dict_err` of `typecheck\TcErrors.hs` we now distinguish
between all enclosing implications and "useful" enclosing implications,
for better error messages concerning pattern synonyms. See `Note [Useful
implications]`.

See the Phabricator page for examples.

Reviewers: mpickering, goldfire, simonpj, austin, bgamari

Reviewed By: bgamari

Subscribers: thomie

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

GHC Trac Issues: #11667

(cherry picked from commit 997312b04c56017197250096d61f3e8fab502319)

3 years agoErrUtils: Add timings to compiler phases
Ben Gamari [Wed, 23 Mar 2016 15:11:45 +0000 (16:11 +0100)] 
ErrUtils: Add timings to compiler phases

This adds timings and allocation figures to the compiler's output when
run with `-v2` in an effort to ease performance analysis.

Todo:
  * Documentation
  * Where else should we add these?
  * Perhaps we should remove some of the now-arguably-redundant
    `showPass` occurrences where they are
  * Must we force more?
  * Perhaps we should place this behind a `-ftimings` instead of `-v2`

Test Plan: `ghc -v2 Test.hs`, look at the output

Reviewers: hvr, goldfire, simonmar, austin

Reviewed By: simonmar

Subscribers: angerman, michalt, niteria, ezyang, thomie

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

(cherry picked from commit 8048d51be0676627b417c128af0b0c352b75c537)

3 years agoEnsure T9646 dump-simpl output is cleaned
Ben Gamari [Sun, 20 Mar 2016 23:49:24 +0000 (00:49 +0100)] 
Ensure T9646 dump-simpl output is cleaned

(cherry picked from commit da3b29bd1768d717753b7d1642e0e4e97750ae7b)

3 years agoFix regression test for #11145.
Dominik Bollmann [Thu, 24 Mar 2016 09:11:46 +0000 (10:11 +0100)] 
Fix regression test for #11145.

Test Plan: ./validate

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: thomie

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

GHC Trac Issues: #11145

(cherry picked from commit e57b9ffee858278bf1ef8ed0754346685334b9ba)

3 years agoadd regression test for #11145.
Dominik Bollmann [Fri, 11 Mar 2016 09:38:28 +0000 (10:38 +0100)] 
add regression test for #11145.

The original TH failure observed by the ticket, namely that Template
Haskell quotes of data instance GADTs are broken, is not observable
anymore in HEAD. I therefore just added the corresponding regression
test.

Test Plan: ./validate

Reviewers: goldfire, austin, thomie, jstolarek, bgamari

Reviewed By: bgamari

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

GHC Trac Issues: #11145

(cherry picked from commit f3def7643d390db54d18b8c3d385c490fba58a41)

3 years agoSimplify: Make generated names more useful
Ben Gamari [Fri, 11 Mar 2016 14:24:49 +0000 (15:24 +0100)] 
Simplify: Make generated names more useful

makeTrivial is responsible for concocting names during simplification.
Previously, however, it would make no attempt to generate a name that
might be useful to later readers of the resulting Core. Here we add a
bit of state to SimplEnv: a finite depth stack of binders within which
we are currently simplifying. We then derive generated binders from this
context.

See #11676.

Open questions:
  * Is there a better way to accomplish this?
  * Is `maxContextDepth` too large/small?

Test Plan: Validate, look at Core.

Reviewers: austin, simonpj

Reviewed By: simonpj

Subscribers: thomie, simonpj

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

GHC Trac Issues: #11676

(cherry picked from commit 4d791b4f77975422df38f6b43084008edd097f1b)

3 years agoMove getOccFS to Name
Ben Gamari [Fri, 11 Mar 2016 10:42:01 +0000 (11:42 +0100)] 
Move getOccFS to Name

(cherry picked from commit 3ea11eb1c367a15e5b7dac83d31937ac7d44b3b2)

3 years agoAvoid local label syntax for assembler on AIX
Herbert Valerio Riedel [Thu, 24 Mar 2016 19:35:42 +0000 (20:35 +0100)] 
Avoid local label syntax for assembler on AIX

Unfortunately (for inline `__asm__()` uses), IBM's `as` doesn't seem to support
local labels[1] like GNU `as` does so we need to workaround this when on AIX.

 [1]: https://sourceware.org/binutils/docs/as/Symbol-Names.html#Symbol-Names

Turns out this also addresses the long-standing bug #485

(cherry picked from commit 343349df1f19f21899818d647bf570e489d0cf8f)

3 years agoAvoid running afoul of the zipTvSubst check.
Richard Eisenberg [Tue, 22 Mar 2016 02:35:41 +0000 (22:35 -0400)] 
Avoid running afoul of the zipTvSubst check.

addDataConStupidTheta includes comments that the types list
might be longer than the tvs list. And the check in zipTvSubst
doesn't appear to be terribly recent. I am utterly flummoxed
as to why this worked before. It was clearly just broken.
And now it's fixed.

(cherry picked from commit 0beb82c171913508dc0de91851ab8e90821d8ba8)