ghc.git
2 years agoRevert "Make raiseIO# produce topRes" ghc-8.2.1-rc1
David Feuer [Tue, 4 Apr 2017 02:25:55 +0000 (22:25 -0400)] 
Revert "Make raiseIO# produce topRes"

This reverts commit da4687f63ffe5a6162e3d7856aa53de048dd0f42.

It's not entirely trivial to clean up the dead code this patch
introduced. In particular, when we see

```
case raiseIO# m s of
  s' -> e
```

we want to know that `e` is dead. For scrutinees that are properly
bottom (which we don't want to consider `raiseIO# m s` to be, this
is handled by rewriting `bot` to `case bot of {}`. But if we do
that for `raiseIO#`, we end up with

```
case raiseIO# m s of {}
```

which looks a lot like bottom and could confuse demand analysis.
I think we need to wait with this change until we have a more
complete story.

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

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

(cherry picked from commit e83af07e3d0b65fe6f37806e86d07f3e8dc1b01e)

2 years agocompact: Clarify mutability restriction
Ben Gamari [Mon, 3 Apr 2017 23:27:59 +0000 (19:27 -0400)] 
compact: Clarify mutability restriction

Fixes #13508.

[skip ci]

Test Plan: Read it

Reviewers: austin

Subscribers: rwbarton, thomie

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

(cherry picked from commit 38f9eadd8e4746c2fabf83045073134f5a554a06)

2 years agoBump Win32 submodule
Ben Gamari [Mon, 3 Apr 2017 23:00:33 +0000 (19:00 -0400)] 
Bump Win32 submodule

Fixes #13514.

(cherry picked from commit e815901d8f1d0e8c6916fcf0e87c68998475407e)

2 years agohp2ps: install shell wrapper
Sergei Trofimovich [Mon, 3 Apr 2017 07:55:04 +0000 (08:55 +0100)] 
hp2ps: install shell wrapper

Before this change we installed hp2ps both
to inplace/bin/ and ${prefix}/bin/

In both cases we added $(CrossCompilePrefix) as
a binary prefix. It's incorrect for inplace install
as none of inplace binaries are prefixed.

The change it to track 'hp2ps' as unprefixed binary.
$(CrossCompilePrefix) prefix is only added to the
installed shell wrapper.

Now 'hp2ps' is handled in a similar way to 'hpc' and
'ghc-pkg'.

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
(cherry picked from commit 1e58efb16f76b52c059d5e5d6c4c5d91c2abaad2)

2 years agotestsuite: Classify missing expected perf numbers as merely warnings
Ben Gamari [Sun, 2 Apr 2017 21:20:34 +0000 (17:20 -0400)] 
testsuite: Classify missing expected perf numbers as merely warnings

Previously these were considered to be framework failures, meaning that validate
would fail. For better or worse, Windows lacks a good number of metrics and I
don't see this changing any time soon. Let's consider these to be non-fatal.

(cherry picked from commit 597ea1cdca4c127a0a9ad936645c416df80a907b)

2 years agoVarious testsuite fixes for 32-bit Windows
Ben Gamari [Sun, 2 Apr 2017 21:10:48 +0000 (17:10 -0400)] 
Various testsuite fixes for 32-bit Windows

(cherry picked from commit f8ecc5847285d68055c3340ee4b4bb4a3052b966)

2 years agorts: Make out-of-memory errors more consistent
Ben Gamari [Sun, 2 Apr 2017 23:15:45 +0000 (19:15 -0400)] 
rts: Make out-of-memory errors more consistent

This will make it a bit easier to maintain consistent output in the testsuite.

(cherry picked from commit 23011765244fe5a3c4583033e019a537278a45a9)

2 years agoarray: Clear up inconsistency in T9220 output
Ben Gamari [Sun, 2 Apr 2017 17:04:26 +0000 (13:04 -0400)] 
array: Clear up inconsistency in T9220 output

ghc-8.2 and master disagreed on the order of the instances. Normalise this
difference away.

Updates array submodule.

(cherry picked from commit 60307cb85abc8d53845598a430c0ee9264fb2d82)

2 years agoFix recompilation avoidance bug for implementor of hsig.
Edward Z. Yang [Sun, 26 Mar 2017 05:50:55 +0000 (22:50 -0700)] 
Fix recompilation avoidance bug for implementor of hsig.

Summary:
I observed a bug where if I modified the module which implemented
an hsig in another package, GHC would not recompile the signature
in this situation.

The root cause was that we were conflating modules from user
imports, and "system" module dependencies (from signature
merging and instantiation.) So this patch handles them separately.

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
Test Plan: validate

Reviewers: simonpj, bgamari, austin

Subscribers: rwbarton, thomie, snowleopard

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

(cherry picked from commit 5fb485a3e1e83a1f5c6acf989be292940229e1a4)

2 years agoCorrectly handle wired in unit IDs in -instantiated-with
Edward Z. Yang [Sun, 26 Mar 2017 21:06:12 +0000 (14:06 -0700)] 
Correctly handle wired in unit IDs in -instantiated-with

Summary:
To handle wired in packages, we must rewrite all occurrences
of unit ids like base-4.9.0.0 to base.  However, I forgot
to do this on unit ids that occurred in unit identifiers
passed via -instantiated-with.  This patch handles that case,
plus a test.

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
Test Plan: validate

Reviewers: bgamari, austin

Subscribers: rwbarton, thomie

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

(cherry picked from commit 852a43f360af09416d15777c8f10d704b5423a96)

2 years agoUpdate containers submodule to official 0.5.10.2
David Feuer [Sun, 2 Apr 2017 18:39:15 +0000 (14:39 -0400)] 
Update containers submodule to official 0.5.10.2

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

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

(cherry picked from commit 115e7ebfaad36327b7b38f112282f6e84d267c88)

2 years agoconfigure.ac: add aarch64 to list of registerised
Sergei Trofimovich [Sun, 2 Apr 2017 19:56:40 +0000 (20:56 +0100)] 
configure.ac: add aarch64 to list of registerised

Similar to 'arm' 'aarch64' has working llvm codegen,
no need to fallback to unregisterised buld by default.

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
(cherry picked from commit 911055689eca26c7c2713e251646fa35359acba3)

2 years agoconfigure.ac: fix NCG support in --target=
Sergei Trofimovich [Sun, 2 Apr 2017 18:38:23 +0000 (19:38 +0100)] 
configure.ac: fix NCG support in --target=

Before this change attempt to build a crosscompiler
on registerised platform (--host=x86_64-pc-linux-gnu)
targeting UNREG platform failed:
    $ ./configure --target=ia64-unknown-linux-gnu

  utils/genapply/../../includes/stg/MachRegs.h:608:2: error:
     #error Cannot find platform to give register info for

The change is to check --target= for NCG availability,
not --host=.

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
(cherry picked from commit cb18447c75e7673d5f57056fbdaa370d11e4c05e)

2 years agotestsuite: Fix GhciCurDir test
Ben Gamari [Sun, 2 Apr 2017 16:05:09 +0000 (12:05 -0400)] 
testsuite: Fix GhciCurDir test

This was horribly, horribly wrong.

(cherry picked from commit 4ed33975e85f567dc351a21e2f27f097db15b7c1)

2 years ago:cd affects the iserv process too
Simon Marlow [Sun, 2 Apr 2017 14:43:32 +0000 (10:43 -0400)] 
:cd affects the iserv process too

Test Plan: validate

Reviewers: angerman, austin, bgamari, erikd

Reviewed By: bgamari

Subscribers: rwbarton, thomie

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

(cherry picked from commit dfac365f69a9380e3c3640b3bfaf9b9157f8d3b9)

2 years agoReport heap overflow in the same way as stack overflow
Simon Marlow [Sat, 1 Apr 2017 23:52:40 +0000 (19:52 -0400)] 
Report heap overflow in the same way as stack overflow

Now that we throw an exception for heap overflow, we should only print
the heap overflow message in the main thread when the HeapOverflow
exception is caught, rather than as a side effect in the GC.

Stack overflows were already done this way, I just made heap overflow
consistent with stack overflow, and did some related cleanup.

Fixes broken T2592(profasm) which was reporting the heap overflow
message twice (you would only notice when building with profiling
libs enabled).

Test Plan: validate

Reviewers: bgamari, niteria, austin, DemiMarie, hvr, erikd

Reviewed By: bgamari

Subscribers: rwbarton, thomie

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

(cherry picked from commit 61ba4518a48727f8cd7b821bd41631da82d37425)

2 years agoFastMutInt: fix Int and Ptr sizes when crosscompiling
Sergei Trofimovich [Sun, 2 Apr 2017 15:12:18 +0000 (16:12 +0100)] 
FastMutInt: fix Int and Ptr sizes when crosscompiling

Similar to
  https://ghc.haskell.org/trac/ghc/ticket/13491
  https://phabricator.haskell.org/D3122

SIZEOF_HSINT and SIZEOF_VOID_P are sizes of
target platform. These values are usually
not correct when stage1 is built.

It means the code

```haskell
  newFastMutInt = IO $ \s ->
   case newByteArray# size s of { (# s, arr #) ->
   (# s, FastMutInt arr #) }
   where !(I# size) = SIZEOF_HSINT
```
would try to allocate only 4 bytes on 64-bit-host
targeting 32-bit system.

It does not matter in practice as newByteArray#
implementation rounds up passed value to host's
word size. But one day it might not.

To prevent this class of problems in compiler/
directory 'MachDeps.h' contents is hidden when
ghc-stage1 (-DSTAGE=1) is built.

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
Reviewers: austin, rwbarton, simonmar, bgamari

Reviewed By: bgamari

Subscribers: thomie

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

(cherry picked from commit d89b0471888b15844b8bbf68159fe50830be8b24)

2 years agocompiler/ghc.mk: fix GhcWithInterpreter=NO build failure
Sergei Trofimovich [Sun, 2 Apr 2017 13:01:19 +0000 (14:01 +0100)] 
compiler/ghc.mk: fix GhcWithInterpreter=NO build failure

When GhcWithInterpreter=NO is set in mk/build.mk build
fails as:

    $ inplace/bin/dll-split compiler/stage2/build/.depend-v-dyn.haskell "DynFlags" ...
    Reachable modules from DynFlags out of date
    Please fix compiler/ghc.mk, or building DLLs on Windows may break (#7780)
    Extra modules: ByteCodeTypes InteractiveEvalTypes

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
(cherry picked from commit 03e34256e2cba964adf6dcdb1682618f26400b3a)

2 years agoRevert "Fix #13458"
Ben Gamari [Sat, 1 Apr 2017 22:01:22 +0000 (18:01 -0400)] 
Revert "Fix #13458"

This reverts commit 662c64226e302009175abfa7ed196ac905990486.

2 years agotestsuite: Bump margin of T4029 to 15%
Ben Gamari [Wed, 15 Mar 2017 17:34:48 +0000 (13:34 -0400)] 
testsuite: Bump margin of T4029 to 15%

This test has been fluctuating wildly recently. Moreover, it's not even clear to
me that this is a particularly useful thing to be testing.

(cherry picked from commit 899fb8808da875ef191da367de4ff35d079124e1)

2 years agotestsuite: Bump allocations for T4029
Ben Gamari [Tue, 14 Mar 2017 14:04:40 +0000 (10:04 -0400)] 
testsuite: Bump allocations for T4029

Both the OS X build machine and my local builds have been failing.
Unfortunately, our x86_64 Linux machine has been succeeding.

(cherry picked from commit 34f9172fe456b4125ad527f9386aa23e2dfe98c6)

2 years agoStamp out space leaks from demand analysis
Reid Barton [Sat, 1 Apr 2017 15:51:59 +0000 (11:51 -0400)] 
Stamp out space leaks from demand analysis

This reduces peak memory usage by ~30% on my test case (DynFlags),
and (probably as a result of reduced GC work) decreases compilation
time by a few percent as well.

Also fix a bug in seqStrDmd so that demeand info is fully evaluated.

Reviewers: simonpj, austin, bgamari

Reviewed By: bgamari

Subscribers: dfeuer, thomie

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

(cherry picked from commit f2b10f35a053e595fd309f523c5e93f619d2ec3a)

2 years agoOptimise common cases of GHC.setProgramDynFlags
Simon Marlow [Sat, 1 Apr 2017 15:51:43 +0000 (11:51 -0400)] 
Optimise common cases of GHC.setProgramDynFlags

* If the package flags haven't changed, don't do initPackages (which
  might take multiple seconds in extreme cases)

* Provide a way to change the log_action without invalidating the
  summary cache.

Test Plan: validate

Reviewers: niteria, bgamari, austin, erikd, ezyang

Reviewed By: bgamari

Subscribers: mpickering, rwbarton, thomie

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

(cherry picked from commit f7cc1fdebd6aa8b5cb0498ae245a5e8cf3e38f6f)

2 years agoDocument the perplexing reversed nature of extraPkgConfs and friends.
Edward Z. Yang [Sun, 19 Mar 2017 23:06:55 +0000 (16:06 -0700)] 
Document the perplexing reversed nature of extraPkgConfs and friends.

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
(cherry picked from commit 40b65db4cd34c3566b9f6c53c086d53e97574217)

2 years agoIntroduce putLogMsg
Ben Gamari [Wed, 15 Mar 2017 13:29:24 +0000 (09:29 -0400)] 
Introduce putLogMsg

This factors out the repetition of (log_action dflags dflags) and will
hopefully allow us to someday better abstract log output.

Test Plan: Validate

Reviewers: austin, hvr, goldfire

Subscribers: rwbarton, thomie

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

(cherry picked from commit 086b514b199c122b638391f3aa2fbcf15cc10c06)

2 years agotestsuite: Add regression test for #13474
Ben Gamari [Sat, 1 Apr 2017 14:59:53 +0000 (10:59 -0400)] 
testsuite: Add regression test for #13474

(cherry picked from commit 6928d8019cd2cdd1c0b9d6e1fe1a0c8c07e57595)

2 years agoUNREG: ignore -fllvm (Trac #13495)
Sergei Trofimovich [Sat, 1 Apr 2017 09:35:52 +0000 (10:35 +0100)] 
UNREG: ignore -fllvm (Trac #13495)

Unregisterised GHC can only use C as a target backend
(option used to be called -fvia-C). -fasm option was
ignored with a warhing, but not -fllvm.

jms noticed the failure when tried to use quick-cross
build flavour. quick-cross enables -fllvm in makefile.

  "inplace/bin/ghc-stage1" ... -fllvm
  ghc-stage1: panic! (the 'impossible' happened)
    (GHC version 8.0.2 for powerpc-unknown-linux):
          LlvmCodeGen.Ppr: Cross compiling without valid target info.

This change ignores -fllvm as well.

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
(cherry picked from commit 74615f412ad3de2910a156ff494bfe5497fada7e)

2 years agoRemove Core Lint pass on occurrence analysis output (#13220)
Reid Barton [Sat, 1 Apr 2017 02:48:14 +0000 (22:48 -0400)] 
Remove Core Lint pass on occurrence analysis output (#13220)

It was expensive, as the simplifier runs for many iterations,
and probably not very useful.

Test Plan: harbormaster

Reviewers: austin, bgamari, dfeuer

Reviewed By: dfeuer

Subscribers: dfeuer, thomie

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

(cherry picked from commit 71916e1c018dded2e68d6769a2dbb8777da12664)

2 years agoaskCc should be using the linker, not the compiler
Simon Marlow [Sat, 1 Apr 2017 02:47:47 +0000 (22:47 -0400)] 
askCc should be using the linker, not the compiler

When GHCi tries to find a shared lib, it calls "gcc --print-file-name"
to ask gcc where to find it.  But since we're looking for libraries,
we're really using the linker here, not the C compiler, so we should be
respecting the values of -pgml and -optl rather than -pgmc and -optc.

Test Plan: validate

Reviewers: bgamari, niteria, austin, hvr, erikd

Reviewed By: bgamari

Subscribers: rwbarton, thomie

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

(cherry picked from commit 308287999fcc929891fbcf1221525dd7cbb77860)

2 years agotestsuite: Update Windows allocations for T12234
Ben Gamari [Sat, 1 Apr 2017 02:32:21 +0000 (22:32 -0400)] 
testsuite: Update Windows allocations for T12234

(cherry picked from commit 546c2a17ae3b21448f7fd467cc47807ae977e51f)

2 years agotestsuite: Fix use of wc in T13340
Ben Gamari [Mon, 13 Mar 2017 21:00:01 +0000 (17:00 -0400)] 
testsuite: Fix use of wc in T13340

As previously documented (88f5add0280788d424c9df5f751a73e73a1a4284) wc's output
is inconsistent between Linux and BSDs. Use grep -c instead.

(cherry picked from commit cf74b677e8a328785a95bd0a7b094daf25e6868a)

2 years agoKQueue: Eliminate redundant import
Ben Gamari [Sun, 12 Mar 2017 22:06:34 +0000 (18:06 -0400)] 
KQueue: Eliminate redundant import

At long last fixes OS X build.

(cherry picked from commit 2f2622c601136a62e465dcd3b3b02db8156734b6)

2 years agoBump array submodule
Ben Gamari [Fri, 31 Mar 2017 23:29:00 +0000 (19:29 -0400)] 
Bump array submodule

2 years agotestsuite: Bump haddock.compiler allocations
Ben Gamari [Fri, 31 Mar 2017 23:19:24 +0000 (19:19 -0400)] 
testsuite: Bump haddock.compiler allocations

2 years agotestsuite: More 32-bit performance changes
Ben Gamari [Mon, 27 Mar 2017 12:16:18 +0000 (08:16 -0400)] 
testsuite: More 32-bit performance changes

(cherry picked from commit fb7e5bd350407888d6638e15d16aad311d7d9006)

2 years agoFix space leaks in simplifier (#13426)
Reid Barton [Fri, 31 Mar 2017 15:37:38 +0000 (11:37 -0400)] 
Fix space leaks in simplifier (#13426)

The Join points commit (8d5cf8bf) introduced a space leak
somewhere in the simplifier. The extra strictness added in this commit
fixes the leak. Unfortunately I don't really understand the details.

Unfortunately, the extra strictness appears to result in more overall
allocations in some cases, even while the peak heap size decreases in others.

Test Plan: harbormaster

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: thomie

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

(cherry picked from commit e13419c5562ed0aa587516255d1dbb48a8165457)

2 years agoClean up coreView/tcView.
Ben Gamari [Mon, 27 Mar 2017 17:17:00 +0000 (13:17 -0400)] 
Clean up coreView/tcView.

In Core, Constraint should be considered fully equal to
TYPE LiftedRep, in all ways. Accordingly, coreView should
unwrap Constraint to become TYPE LiftedRep. Of course, this
would be a disaster in the type checker.

So, where previously we used coreView in both the type checker
and in Core, we now have coreView and tcView, which differ only
in their treatment of Constraint.

Historical note: once upon a past, we had tcView distinct from
coreView. Back then, it was because newtypes were unwrapped in
Core but not in the type checker. The distinction is back, but
for a different reason than before.

This had a few knock-on effects:

 * The Typeable solver must explicitly handle Constraint to ensure
   that we produce the correct evidence.

 * TypeMap now respects the Constraint/Type distinction

Finished by: bgamari

Test Plan: ./validate

Reviewers: simonpj, austin, bgamari

Reviewed By: simonpj

Subscribers: rwbarton, thomie

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

(cherry picked from commit 6575f4b635a393775295798ca86c7c3ba00819be)

2 years agoRefactor simplExpr (Type ty)
Simon Peyton Jones [Fri, 31 Mar 2017 16:48:10 +0000 (17:48 +0100)] 
Refactor simplExpr (Type ty)

This small refactoring, provoked by comment:18 on Trac #13426,
makes it so that simplExprF never gets a (Type ty) expression to
simplify, which in turn means that calls to exprType on its argument
will always succeed.

No change in behaviour.

(cherry picked from commit 29645274a3c97a904759aa245dc8f8c03a58c601)

2 years agoDisable bogus lint checks about levity polimorphic coerions
Joachim Breitner [Fri, 31 Mar 2017 13:47:06 +0000 (09:47 -0400)] 
Disable bogus lint checks about levity polimorphic coerions

These checks, introduced in cea7141851ce653cb20207da3591d09e73fa396d
hugely inflated build logs, which incapitated perf.haskell.org.

According to Richard, the checks are useless and wrong, and that Ben
plans to investigate.
(https://phabricator.haskell.org/rGHCcea7141851ce653cb20207da3591d09e73fa396d#64647)

Until that happens, I remove them from the code.

(cherry picked from commit 03c7dd0941fb4974be54026ef3e4bb97451c3b1f)

2 years agoFix #13458
Richard Eisenberg [Thu, 23 Mar 2017 02:32:04 +0000 (22:32 -0400)] 
Fix #13458

Core Lint shouldn't check representations of types that don't
have representations.

test case: typecheck/should_compile/T13458

(cherry picked from commit cea7141851ce653cb20207da3591d09e73fa396d)

2 years agoFix ASSERT failure in TcErrors
Simon Peyton Jones [Wed, 29 Mar 2017 13:57:21 +0000 (14:57 +0100)] 
Fix ASSERT failure in TcErrors

This fixes Trac #13494, by improving

   commit e0ad55f894a8d85dcc099c33c63cfe3d4515d464
   Author: Simon Peyton Jones <simonpj@microsoft.com>
   Date:   Mon Mar 27 10:32:08 2017 +0100

   Fix error-message suppress on given equalities

which in turn was a fix to #13446

(cherry picked from commit f88ac374c5cb150d4f172fb40be338d2112a0600)

2 years agoAllow unbound Refl binders in a RULE
Simon Peyton Jones [Wed, 29 Mar 2017 08:00:02 +0000 (09:00 +0100)] 
Allow unbound Refl binders in a RULE

Trac #13410 was failing because we had a RULE with a binder
   (c :: t~t)
and the /occurrences/ of c on the LHS were being optimised to Refl,
leaving a binder that would not be filled in by matching the LHS
of the rule.

I flirted with trying to ensure that occurrences (c :: t~t) are
not optimised to Relf, but that turned out to be fragile; it was
being done, for good reasons, in multiple places, including
  - TyCoRep.substCoVarBndr
  - Simplify.simplCast
  - Corecion.mkCoVarCo

So I fixed it in one place by making Rules.matchN deal happily
with an unbound binder (c :: t~t).  Quite easy.  See "Coercion
variables" in Note [Unbound RULE binders] in Rules.

In addition, I needed to make CoreLint be happy with an bound
RULE binder that is a Relf coercion variable

In debugging this, I was perplexed that occurrences of a variable
(c :: t~t) mysteriously turned into Refl.  I found out how it
was happening, and decided to move it:

* In TyCoRep.substCoVarBndr, do not substitute Refl for a
  binder (c :: t~t).

* In mkCoVarCo do not optimise (c :: t~t) to Refl.

Instead, we do this optimisation in optCoercion (specifically
opt_co4) where, surprisingly, the optimisation was /not/
being done.  This has no effect on what programs compile;
it just moves a relatively-expensive optimisation to optCoercion,
where it seems more properly to belong.  It's actually not clear
to me which is really "better", but this way round is less
surprising.

One small simplifying refactoring

* Eliminate TyCoRep.substCoVarBndrCallback, which was only
  called locally.

(cherry picked from commit 8674883c137401873fd53a6963acd33af651c2af)

2 years agoComplete the fix for #13441 (pattern synonyms)
Simon Peyton Jones [Tue, 28 Mar 2017 07:23:44 +0000 (08:23 +0100)] 
Complete the fix for #13441 (pattern synonyms)

Do not attempt to typecheck both directions of an
implicitly-bidirectional pattern synonym simultanously,
as we were before.  Instead, the builder is typechecked
when we typecheck the code for the builder, which was
of course happening already, even in both bidirectional
cases.

See Note [Checking against a pattern signature], under
"Existential type variables".

(cherry picked from commit b5c81203d047293f54c4e89ac70d505197968cb3)

2 years agounique: fix UNIQUE_BITS crosscompilation (Trac #13491)
Sergei Trofimovich [Wed, 29 Mar 2017 21:30:50 +0000 (17:30 -0400)] 
unique: fix UNIQUE_BITS crosscompilation (Trac #13491)

The #13491 manifests best when we try to crosscompile
from 32-bit (i386-linux) to 64-bit (powerpc64-linux)
system:
    ./configure --target=powerpc64-unknown-linux-gnu

The build fails at assembly time:
  "inplace/bin/ghc-stage1" ...  -c rts/StgStartup.cmm
    /tmp/ghc19687_0/ghc_4.s: Assembler messages:

    /tmp/ghc19687_0/ghc_4.s:11:0: error:
         Error: unknown pseudo-op: `.l'
       |
    11 | .L<\x00>4:
       | ^

That happens because UNIQUE_BITS is defined in terms
of WORD_SIZE_IN_BITS macro:
    #define UNIQUE_BITS (WORD_SIZE_IN_BITS - 8)

WORD_SIZE_IN_BITS is 64 bits (equals to target value)
while ghc-stage1 is still running on i386-linux

The fix is to stop relying on target macros and use
host's 'sizeof (HsInt)' and 'finiteBitSize' way to
determine unique layout.

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
Test Plan: build i386-to-powerpc64 crosscompiler

Reviewers: rwbarton, austin, bgamari

Reviewed By: bgamari

Subscribers: RyanGlScott, thomie

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

(cherry picked from commit 01b062ec3fa138b92124ce7ca4deca0ddcb474ea)

2 years agoVarious patches to support android cross compilation
Moritz Angermann [Wed, 29 Mar 2017 21:29:58 +0000 (17:29 -0400)] 
Various patches to support android cross compilation

- Better test for SHT_INIT_ARRAY than openbsd_HOST_OS
  This is actually bens patch:
  https://gist.github.com/bgamari/c846e6a5f2cd988716cd5e36c68d5bef
- linux-android defines.
- No need for -lpthread on OSAndroid
  However, I’m confused why we do not use the AC NEED_PTHREAD_LIB
  value here?
- Use mmap on android
- Support `none` vendor.

Reviewers: austin, hvr, bgamari, erikd, simonmar

Reviewed By: bgamari

Subscribers: rwbarton, thomie, erikd

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

(cherry picked from commit 924a65fc27bb2a3e24489f7baea7ad5fb8a556ac)

2 years agoCheck TargetPlatform instead of HostPlatform for leading underscore
Moritz Angermann [Wed, 29 Mar 2017 21:28:16 +0000 (17:28 -0400)] 
Check TargetPlatform instead of HostPlatform for leading underscore

Reviewers: austin, hvr, rwbarton, bgamari

Reviewed By: rwbarton, bgamari

Subscribers: rwbarton, thomie, erikd

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

(cherry picked from commit 81f5b6ecbadec49af53189756dda5e0b199f9703)

2 years ago-fspec-constr-keen docs typos [skip ci]
Matthew Pickering [Mon, 27 Mar 2017 16:41:41 +0000 (17:41 +0100)] 
-fspec-constr-keen docs typos [skip ci]

(cherry picked from commit 5025fe2435d030f0c5ecdc2a933c7bfcb3efcb7c)

2 years agoRemove utterly bogus code
Simon Peyton Jones [Mon, 27 Mar 2017 13:33:55 +0000 (14:33 +0100)] 
Remove utterly bogus code

The commit 6746549772c5cc0ac66c0fce562f297f4d4b80a2
    Author: Richard Eisenberg <eir@cis.upenn.edu>
    Date:   Fri Dec 11 18:19:53 2015 -0500

    Add kind equalities to GHC.

added this entirely bogus code to Simplify.simplLam:

    env' | Coercion co <- arg
         = extendCvSubst env bndr co
         | otherwise
         = env

It's bogus because 'co' is an 'InCoercion', but a CvSubst should have
only OutCoercions in it.  Moreover, completeBind does the job nicely.

This led to an ASSERT failure in an experimental branch; but I have
not got a repro case that works on HEAD.  But still, the patch deletes
code and fixes a bug, so it must be good.

The only mystery is why Richard added it in the first place :-).
I hope I'm not missing anything.  But it validates fine.

(cherry picked from commit de4723fd6d97b285bb754d8b95531c86d34c4032)

2 years agoFix error-message suppress on given equalities
Simon Peyton Jones [Mon, 27 Mar 2017 09:32:08 +0000 (10:32 +0100)] 
Fix error-message suppress on given equalities

I'd got the logic slightly wrong when reporting type errors
for insoluble 'given' equalities.  We suppress insoluble givens
under some circumstances (see Note [Given errors]), but we then
suppressed subsequent 'wanted' errors because the (suppressed)
'given' error "won".  Result: no errors at all :-(.

This patch fixes it and
 - Renames TcType.isTyVarUnderDatatype to the more
   perspicuous TcType.isInsolubleOccursCheck

In doing this I realise that I don't understand why we need
to keep the insolubles partitioned out separately at all...
but that is for another day.

(cherry picked from commit e0ad55f894a8d85dcc099c33c63cfe3d4515d464)

2 years agoFix explicitly-bidirectional pattern synonyms
Simon Peyton Jones [Mon, 27 Mar 2017 09:22:22 +0000 (10:22 +0100)] 
Fix explicitly-bidirectional pattern synonyms

This partly fixes Trac #13441, at least for the explicitly
bidirectional case.

See Note [Checking against a pattern signature], the part about
"Existential type variables".

Alas, the implicitly-bidirectional case is still not quite right, but
at least there is a workaround by making it explicitly bidirectional.

(cherry picked from commit 7c7479d047113a0cbf237c864d403bb638ca0241)

2 years agoTypechecker comments and debug tracing only
Simon Peyton Jones [Mon, 27 Mar 2017 09:12:53 +0000 (10:12 +0100)] 
Typechecker comments and debug tracing only

(cherry picked from commit 7e1c492de158f8a8692526a44f6a9a1f203ddcf7)

2 years agoEliminate a user manual warning
Simon Peyton Jones [Mon, 27 Mar 2017 09:09:37 +0000 (10:09 +0100)] 
Eliminate a user manual warning

I was getting
  docs/users_guide/glasgow_exts.rst:12783:
     WARNING: Title underline too short.

  ``COLUMN`` pragma
  ---------------

So I lengthened the row of hyphens.

(cherry picked from commit af33073c77e409d594e61609b3fba7070766cb75)

2 years agoSimplify the logic for tc_hs_sig_type
Simon Peyton Jones [Mon, 27 Mar 2017 09:05:26 +0000 (10:05 +0100)] 
Simplify the logic for tc_hs_sig_type

In fixing Trac #13337, and introducing solveSomeEqualities,
Richard introduce the higher-order function tc_hs_sig_type_x,
with a solver as its argument.

It turned out that there was a much simpler way to do the
same thing, which this patch implements.  Less code, easier
to grok.  No change in behaviour though.

(cherry picked from commit 1e06d8b8f2aea0a06d40618c296a034f3e408ae2)

2 years agoMake the test fail if compiled without -threaded
Simon Marlow [Mon, 27 Mar 2017 15:09:23 +0000 (16:09 +0100)] 
Make the test fail if compiled without -threaded

Test Plan: validate

Reviewers: bgamari, austin, erikd

Subscribers: rwbarton, thomie

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

(cherry picked from commit c77551abd42a346d03826d23df710ebf9eacb19f)

2 years agoFix #13433
Simon Marlow [Mon, 27 Mar 2017 12:15:04 +0000 (13:15 +0100)] 
Fix #13433

Summary: See comments for details.

Test Plan: validate

Reviewers: mpickering, bgamari, austin, erikd

Subscribers: rwbarton, thomie

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

(cherry picked from commit 074d13eb3b6489e8b2f555f61496761614a3e207)

2 years agobase: Check for path separators chars in openTempFile' template string
Ben Gamari [Mon, 27 Mar 2017 16:40:42 +0000 (12:40 -0400)] 
base: Check for path separators chars in openTempFile' template string

This fixes #13489.

(cherry picked from commit b04ded8fca8ee8b0cd9c7c055bc5dc61ef2be1fe)

2 years agoMore fixes for #5654
Simon Marlow [Tue, 20 Dec 2016 14:32:11 +0000 (14:32 +0000)] 
More fixes for #5654

* In stg_ap_0_fast, if we're evaluating a thunk, the thunk might
  evaluate to a function in which case we may have to adjust its CCS.

* The interpreter has its own implementation of stg_ap_0_fast, so we
  have to do the same shenanigans with creating empty PAPs and copying
  PAPs there.

* GHCi creates Cost Centres as children of CCS_MAIN, which enterFunCCS()
  wrongly assumed to imply that they were CAFs.  Now we use the is_caf
  flag for this, which we have to correctly initialise when we create a
  Cost Centre in GHCi.

(cherry picked from commit 3a18baff06abc193569b1b76358da26375b3c8d6)

2 years agoFix bug in previous fix for #5654
Simon Marlow [Sat, 17 Dec 2016 23:08:48 +0000 (18:08 -0500)] 
Fix bug in previous fix for #5654

I forgot to account for BCOs, which have a different layout from
functions.  This caused crashes when using profiling with GHCi (via
-fexternal-interpreter -prof), which unfortunately is not tested at all
by validate, even when profiling is enabled.  I'm going to add some
testing that would have caught this in a separate patch.

Test Plan:
```
cd nofib/spectral/puzzle && make NoFibWithGHCi=YES
EXTRA_RUNTEST_OPTS='-fexternal-interpreter -prof'
```
New testsuite tests coming in a separate diff.

Reviewers: niteria, austin, erikd, bgamari

Reviewed By: bgamari

Subscribers: thomie

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

GHC Trac Issues: #5654

(cherry picked from commit 2a02040b2e23daa4f791afc290c33c9bbe3c620c)

2 years agoFix cost-centre-stacks bug (#5654)
Simon Marlow [Thu, 15 Dec 2016 16:17:19 +0000 (11:17 -0500)] 
Fix cost-centre-stacks bug (#5654)

This fixes some cases of wrong stacks being generated by the profiler.
For background and details on the fix see
`Note [Evaluating functions with profiling]` in `rts/Apply.cmm`.

This does have an impact on allocations for some programs when
profiling.  nofib results:

```
   k-nucleotide          +0.0%     +8.8%    +11.0%    +11.0%      0.0%
         puzzle          +0.0%    +12.5%     0.244     0.246      0.0%
      typecheck           0.0%     +8.7%    +16.1%    +16.2%      0.0%
------------------------------------------------------------------------
--------
            Min          -0.0%     -0.0%    -34.4%    -35.5%    -25.0%
            Max          +0.0%    +12.5%    +48.9%    +49.4%    +10.6%
 Geometric Mean          +0.0%     +0.6%     +2.0%     +1.8%     -0.3%

```

But runtimes don't seem to be affected much, and the examples I looked
at were completely legitimate.  For example, in puzzle we have this:

```
position :: ItemType -> StateType ->  BankType
position Bono = bonoPos
position Edge = edgePos
position Larry = larryPos
position Adam = adamPos
```

where the identifiers on the rhs are all record selectors.  Previously
the profiler gave a stack that looked like

```
  position
  bonoPos
  ...
```

i.e. `bonoPos` was at the same level of the call stack as `position`,
but now it looks like

```
  position
   bonoPos
   ...
```

I used the normaliser from the testsuite to diff the profiling output
from other nofib programs and they all looked better.

Test Plan:
* the broken test passes
* validate
* compiled and ran all of nofib, measured perf, diff'd several .prof
files

Reviewers: niteria, erikd, austin, scpmw, bgamari

Reviewed By: bgamari

Subscribers: thomie

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

GHC Trac Issues: #5654, #10007

(cherry picked from commit 394231b301efb6b56654b0a480ab794fe3b7e4db)

2 years agoZap Call Arity info in the simplifier
Joachim Breitner [Tue, 28 Mar 2017 20:19:16 +0000 (16:19 -0400)] 
Zap Call Arity info in the simplifier

As #13479 shows, there are corner cases where the simplifier decides to
not eta-expand a function as much as its call arity would suggest, but
instead transforms the code that the call arity annotation becomes a
lie.

As the call arity information is only meant to be used by the
immediatelly following simplifier run, it makes sense to simply zap the
information there.

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

(cherry picked from commit e07211f752b9b98e2bd6957f126bd537d178041a)

2 years agoFix 'unsolved constraints' in GHCi
Simon Peyton Jones [Mon, 27 Mar 2017 13:32:43 +0000 (14:32 +0100)] 
Fix 'unsolved constraints' in GHCi

In initTc, if the computation fails with an exception, we
should not complain about unsolved constraints.

Fixes Trac #13466.

(cherry picked from commit feca929b8f7a7dfe96d06c27d405ce331cdcdb41)

2 years agotestsuite: Add 32-bit output for compact_share test
Ben Gamari [Fri, 24 Mar 2017 18:27:23 +0000 (14:27 -0400)] 
testsuite: Add 32-bit output for compact_share test

(cherry picked from commit d5847cfeee824867af1259cccab048f331a9a204)

2 years agotestsuite: Mark T12622 as broken in ghci way
Ben Gamari [Sat, 25 Mar 2017 16:28:59 +0000 (12:28 -0400)] 
testsuite: Mark T12622 as broken in ghci way

See #13481.

(cherry picked from commit 140a2d1c463bd314c9afbeb8d60e739163ce576a)

2 years agotestsuite: Only run T13143 in optasm way
Ben Gamari [Sat, 25 Mar 2017 16:07:32 +0000 (12:07 -0400)] 
testsuite: Only run T13143 in optasm way

Otherwise we run it in the hpc way, which outputs different Core.

(cherry picked from commit 23da02b1584a5f1b083185d479807ba0ec6eccfe)

2 years agoRecompile if -fhpc is added or removed (#11798)
Reid Barton [Sat, 25 Mar 2017 14:53:29 +0000 (10:53 -0400)] 
Recompile if -fhpc is added or removed (#11798)

Test Plan: validate

Reviewers: austin, bgamari, dfeuer

Reviewed By: dfeuer

Subscribers: dfeuer, thomie

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

(cherry picked from commit 14b46a556dde8a2795ff5ede46ba8ee63368ae93)

2 years agotestsuite: Note x87 terribleness in num009
Ben Gamari [Fri, 24 Mar 2017 17:22:08 +0000 (13:22 -0400)] 
testsuite: Note x87 terribleness in num009

(cherry picked from commit a1b7e866378e848d50b940595aa43fa63672cf37)

2 years agotestsuite: Update performance numbers for 32-bit platforms
Ben Gamari [Fri, 24 Mar 2017 16:26:03 +0000 (12:26 -0400)] 
testsuite: Update performance numbers for 32-bit platforms

(cherry picked from commit 6d774ff2fde787d2032bbcefcb3afd2262b3916e)

2 years agotestsuite: Allow join007 to pass on 32-bit machines
Ben Gamari [Fri, 24 Mar 2017 16:27:35 +0000 (12:27 -0400)] 
testsuite: Allow join007 to pass on 32-bit machines

The output of the test overflows. Given that the result is stable
regardless of whether it overflows, I just made the expected output
word-size dependent.

(cherry picked from commit aecbfb908a11991eb23b790a440efe4697ffb86a)

2 years agorts: Fix stat output on 32-bit platforms
Ben Gamari [Fri, 24 Mar 2017 18:59:14 +0000 (14:59 -0400)] 
rts: Fix stat output on 32-bit platforms

The formatting strings fell out of sync with the arguments.

(cherry picked from commit 94ec48f8a25d5a381a5d42016baa0333c186a442)

2 years agoEliminate word-size dependence in HsDumpAst output
Ben Gamari [Fri, 24 Mar 2017 16:05:23 +0000 (12:05 -0400)] 
Eliminate word-size dependence in HsDumpAst output

Fixes DumpTypecheckedAst output on 32-bit platforms.

(cherry picked from commit bc9f280acf82d34fea72199a34b00c414c3ef59e)

2 years agotestsuite: Make T10245 pass on 32-bit platforms
Ben Gamari [Fri, 24 Mar 2017 15:36:31 +0000 (11:36 -0400)] 
testsuite: Make T10245 pass on 32-bit platforms

(cherry picked from commit ff6ee998e06c74bf41841a9ccf2e55a722268e91)

2 years agotestsuite: Add testcase for #13429
Ben Gamari [Fri, 24 Mar 2017 03:03:54 +0000 (23:03 -0400)] 
testsuite: Add testcase for #13429

(cherry picked from commit be8122ab72aeec509b5ce4b4f05fbc5cdb77bf5a)

2 years agotestsuite: Add failing testcase for #13233
Ben Gamari [Fri, 24 Mar 2017 02:53:29 +0000 (22:53 -0400)] 
testsuite: Add failing testcase for #13233

Thanks to Ryan Scott for the example.

(cherry picked from commit 27c9a7d095d2383a7822d317dc7acfe579a4815b)

2 years agoDocument hithertoo undocumented HPCTIXFILE option.
Edward Z. Yang [Fri, 24 Mar 2017 01:03:40 +0000 (21:03 -0400)] 
Document hithertoo undocumented HPCTIXFILE option.

Test Plan: none

Reviewers: bgamari, austin, dfeuer

Reviewed By: bgamari, dfeuer

Subscribers: dfeuer, rwbarton, thomie

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

(cherry picked from commit ee7241cfde455ab6731b9ce81b36247f082a1342)

2 years agolinker: fix OpenBSD build failure, EM_PPC64 is not defined there
Sergei Trofimovich [Sun, 26 Mar 2017 14:40:40 +0000 (15:40 +0100)] 
linker: fix OpenBSD build failure, EM_PPC64 is not defined there

Adam Steen reported build failure on OpenBSD:
  rts/linker/Elf.c:402:0: error:
    error: 'EM_PPC64' undeclared (first use in this function)
      case EM_PPC64: IF_DEBUG(linker,debugBelch( "powerpc64" ));

OpenBSD-6.0 does not define EM_PPC64:
  /usr/include/sys/exec_elf.h:#define EM_PPC 20 /* PowerPC */

Reported-by: Adam Steen <adam@adamsteen.com.au>
Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
(cherry picked from commit 6c73504ac5f4e951062d5e868fa2b69b028b6e79)

2 years agox86 nativeGen: Fix test with mask in range [128,255] (#13425)
Reid Barton [Fri, 24 Mar 2017 01:02:29 +0000 (21:02 -0400)] 
x86 nativeGen: Fix test with mask in range [128,255] (#13425)

My commit bdb0c43c7 optimized the encoding of instructions to test
tag bits, but it did not always set exactly the same condition codes
since the testb instruction does a single-byte comparison, rather
than a full-word comparison.

It would be correct to optimize the expression `x .&. 128 > 0` to
the sequence

    testb $128, %al
    seta %al         ; note: 'a' for unsigned comparison,
                     ; not 'g' for signed comparison

but the pretty-printer is not the right place to make this kind of
context-sensitive optimization.

Test Plan: harbormaster

Reviewers: trofi, austin, bgamari, dfeuer

Reviewed By: trofi, dfeuer

Subscribers: thomie

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

(cherry picked from commit caf94b062a0e37ffa7048e51447fc9486b658917)

2 years agoconfig.mk.in: Add bzip, gzip, and xz executable names to be overridden
Ben Gamari [Fri, 24 Mar 2017 00:59:21 +0000 (20:59 -0400)] 
config.mk.in: Add bzip, gzip, and xz executable names to be overridden

Reviewers: austin, hvr, erikd

Reviewed By: erikd

Subscribers: rwbarton, thomie, erikd, snowleopard

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

(cherry picked from commit 1b374402a7a078e53c3e00eb0460e8b22930c453)

2 years agoAllow colors to be customized
Phil Ruffwind [Fri, 24 Mar 2017 00:59:01 +0000 (20:59 -0400)] 
Allow colors to be customized

Allow customization of diagnostic colors through the GHC_COLORS
environment variable.  Some color-related code have been refactored to
PprColour to reduce the circular dependence between DynFlags,
Outputable, ErrUtils.  Some color functions that were part of Outputable
but were never used have been deleted.

Test Plan: validate

Reviewers: austin, hvr, bgamari, dfeuer

Reviewed By: bgamari, dfeuer

Subscribers: dfeuer, rwbarton, thomie, snowleopard

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

(cherry picked from commit adf27d614f8a48d8dcf2d4e2e7872f7b3f818364)

2 years agoBump haddock submodule
Ben Gamari [Thu, 23 Mar 2017 19:31:37 +0000 (15:31 -0400)] 
Bump haddock submodule

2 years agoCorrectly account for -package-db ordering when picking packages.
Edward Z. Yang [Sun, 19 Mar 2017 23:07:49 +0000 (16:07 -0700)] 
Correctly account for -package-db ordering when picking packages.

Summary:
When I originally implemented ABI-based shadowing as per
ee4e1654c31b9c6f6ad9b19ece25f040bbbcbd72, I switched our strategy
from pasting together lists to creating a map of all units first,
and then selecting packages from this.  However, what I did
not realize when doing this was that we actually depended
on the *ordering* of these lists later, when we selected
a preferred package to use.

The crux is if I have -package-db db1 -package-db db2 -package p-0.1,
and p-0.1 is provided by both db1 and db2, which one does the
-package flag select?  Previously, this was undetermined; now
we always select the instance from the LATEST package database.
(If p-0.1 shows up multiple times in the same database, once again
the chosen package is undefined.)

The reason why cabal08 intermittently failed was that, in practice,
we were sorting on the UnitId, so when we bumped version numbers,
that often wibbled the UnitIds so that they compared oppositely.
I've extended the test so that we check that the relation is
antisymmetric.

Fixes #13313

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
Test Plan: validate

Reviewers: bgamari, austin

Subscribers: rwbarton, thomie

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

(cherry picked from commit e0eaea918c32b3aa445708656876d1e2aef94a13)

2 years agoMake unsafeInterleaveST less unsafe
David Feuer [Wed, 22 Mar 2017 21:25:03 +0000 (17:25 -0400)] 
Make unsafeInterleaveST less unsafe

* Make `unsafeInterleaveST` use `noDuplicate#` like
`unsafeInterleaveIO` does to prevent the suspended action from
being run in two threads.

* In order to accomplish this without `unsafeCoerce#`, generalize
the type of `noDuplicate#`.

* Add `unsafeDupableInterleaveST` to get the old behavior.

* Document unsafe `ST` functions and clean up some related
documentation.

Fixes #13457

Reviewers: austin, hvr, bgamari, ekmett

Reviewed By: bgamari

Subscribers: rwbarton, thomie

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

(cherry picked from commit 30d68d630c1685bb81ec4afdaf6d483ba8aafd38)

2 years agoFix Windows x86 build
Tamar Christina [Sat, 18 Mar 2017 15:19:01 +0000 (15:19 +0000)] 
Fix Windows x86 build

Summary:
Fix some `-Werror` failures and work around a
bug in the `x86` version of `mingw-w64-crt`'s libraries.

The bump in the `win32` submodule is required for this.

Test Plan: ./validate

Reviewers: austin, bgamari, erikd, simonmar

Reviewed By: simonmar

Subscribers: rwbarton, thomie

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

(cherry picked from commit 713ff9207e0f2493bd498ff725012c9895f728c8)

2 years agousers-guide: Document TemplateHaskell availability
Ben Gamari [Sun, 19 Mar 2017 15:26:08 +0000 (11:26 -0400)] 
users-guide: Document TemplateHaskell availability

(cherry picked from commit 9c041294e5ac7e61e5d7f4858f22bd661dad25ae)

2 years agoNo join-point from an INLINE function with wrong arity
Simon Peyton Jones [Fri, 17 Mar 2017 16:25:41 +0000 (16:25 +0000)] 
No join-point from an INLINE function with wrong arity

The main payload of this patch is NOT to make a join-point
from a function with an INLINE pragma and the wrong arity;
see Note [Join points and INLINE pragmas] in CoreOpt.
This is what caused Trac #13413.

But we must do the exact same thing in simpleOptExpr,
which drove me to the following refactoring:

* Move simpleOptExpr and simpleOptPgm from CoreSubst to a new
  module CoreOpt along with a few others (exprIsConApp_maybe,
  pushCoArg, etc)

  This eliminates a module loop altogether (delete
  CoreArity.hs-boot), and stops CoreSubst getting too huge.

* Rename Simplify.matchOrConvertToJoinPoint
     to joinPointBinding_maybe
  Move it to the new CoreOpt
  Use it in simpleOptExpr as well as in Simplify

* Define CoreArity.joinRhsArity and use it

(cherry picked from commit a7dbafe9292212f3cbc21be42eb326ab0701db7e)

2 years agoImprove Lint a little
Simon Peyton Jones [Fri, 17 Mar 2017 08:54:39 +0000 (08:54 +0000)] 
Improve Lint a little

Better location info if the error is in an unfolding

(cherry picked from commit 567bc6bd194836233ce1576acd7a62b1867f6607)

2 years agoTest #13435 in typecheck/should_run/T13435
Richard Eisenberg [Fri, 17 Mar 2017 15:22:19 +0000 (11:22 -0400)] 
Test #13435 in typecheck/should_run/T13435

(cherry picked from commit 66d174a9650c3099e2e694f71b43c2dac89b21b1)

2 years agoRemove solveSomeEqualities
Richard Eisenberg [Thu, 16 Mar 2017 19:56:37 +0000 (15:56 -0400)] 
Remove solveSomeEqualities

I had thought that it was necessary to solve kind-level equalities
before validity-checking a type, but I was wrong. This patch simply
deletes code. Hooray!

(cherry picked from commit 3cfee57abf00f794e7962e2a60efd9d7d8baf06f)

2 years agoFix #13343 by not defaulting SigTvs
Richard Eisenberg [Thu, 16 Mar 2017 15:59:45 +0000 (11:59 -0400)] 
Fix #13343 by not defaulting SigTvs

test case: typecheck/should_compile/T13343

(cherry picked from commit 02cc8f0c423e85033bdfd26f1492301b724930d8)

2 years agoFix #13202 by failing more eagerly in tcRnStmt
Richard Eisenberg [Thu, 16 Mar 2017 15:38:05 +0000 (11:38 -0400)] 
Fix #13202 by failing more eagerly in tcRnStmt

test cases: ghci/scripts/T13202{,a}

(cherry picked from commit fa13c136e6e666b9a1393c1c0041020ad842c069)

2 years agoFix #12709 by not building bad applications
Richard Eisenberg [Thu, 16 Mar 2017 14:34:29 +0000 (10:34 -0400)] 
Fix #12709 by not building bad applications

In an effort to report multiple levity polymorphism errors all at
once, the desugarer does not fail when encountering bad levity
polymorphism. But we must be careful not to build the bad applications,
lest they try to satisfy the let/app invariant and call
isUnliftedType on a levity polymorphic type. This protects calls
to mkCoreAppDs appropriately.

test case: typecheck/should_fail/T12709

(cherry picked from commit dca44adb9e14992e0aed49cdfd4b2baa2182073b)

2 years agoComment coercion flattening [skip ci]
Richard Eisenberg [Fri, 3 Mar 2017 19:23:24 +0000 (14:23 -0500)] 
Comment coercion flattening [skip ci]

(cherry picked from commit 4dc993008a66d6a54909da462363a25e8449f000)

2 years agoNever tick primitive string literals
Ben Gamari [Sun, 19 Mar 2017 15:53:01 +0000 (11:53 -0400)] 
Never tick primitive string literals

This is a more aggressive approach to the problem initially solved in
f5b275a239d2554c4da0b7621211642bf3b10650, where top-level primitive string
literals were being wrapped by ticks. This breaks the Core invariant descirbed
in Note [CoreSyn top-level string literals]. However, the previous approach was
incomplete and left several places where inappropriate ticks could sneak in.

This commit kills the problem at the source: we simply never tick any primitive
string literal expression. The assumption here is that these expressions are
destined for the top-level, where they cannot be ticked, anyways. So even if
they haven't been floated out yet there is no reason to tick them.

This partially reverts commit f5b275a239d2554c4da0b7621211642bf3b10650.

Test Plan: Validate with `-g`

Reviewers: austin, scpmw, simonpj, simonmar, dfeuer

Subscribers: dfeuer, simonmar, thomie

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

2 years agogenSym: Fix DEBUG build
Ben Gamari [Sat, 18 Mar 2017 18:45:35 +0000 (14:45 -0400)] 
genSym: Fix DEBUG build

It looks like this was likely a cut-and-paste error.

2 years agoRevert "Fix cost-centre-stacks bug (#5654)"
Ben Gamari [Sat, 18 Mar 2017 16:09:17 +0000 (12:09 -0400)] 
Revert "Fix cost-centre-stacks bug (#5654)"

This reverts commit 394231b301efb6b56654b0a480ab794fe3b7e4db.

2 years agoRevert "Fix bug in previous fix for #5654"
Ben Gamari [Sat, 18 Mar 2017 16:09:06 +0000 (12:09 -0400)] 
Revert "Fix bug in previous fix for #5654"

This reverts commit 2a02040b2e23daa4f791afc290c33c9bbe3c620c.

2 years agoRevert "More fixes for #5654"
Ben Gamari [Sat, 18 Mar 2017 16:08:53 +0000 (12:08 -0400)] 
Revert "More fixes for #5654"

This reverts commit 3a18baff06abc193569b1b76358da26375b3c8d6.

2 years agoBump hsc2hs submodule
Ben Gamari [Wed, 15 Mar 2017 21:52:47 +0000 (17:52 -0400)] 
Bump hsc2hs submodule

(cherry picked from commit ba4310510dde80301590f24c3f408aaabc256a7a)

2 years agoDecrease locked region size on Windows to fix ERROR_LOCK_INVALID_RANGE
Andrzej Rybczak [Wed, 15 Mar 2017 18:30:48 +0000 (14:30 -0400)] 
Decrease locked region size on Windows to fix ERROR_LOCK_INVALID_RANGE

Reviewers: austin, hvr, bgamari

Subscribers: rwbarton, thomie

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

(cherry picked from commit 7e273ea28fe3630a8fede75ed28f471b7be21b5f)

2 years agoBump hsc2hs submodule
Ben Gamari [Wed, 15 Mar 2017 15:55:09 +0000 (11:55 -0400)] 
Bump hsc2hs submodule

Fixes #13388. Also updates the expected output for T12504, which
previously contained a redundant LINE pragma.

2 years agoFurther document :type +v's role in analyzing -XTypeApplications in GHCi
Ryan Scott [Tue, 14 Mar 2017 14:58:41 +0000 (10:58 -0400)] 
Further document :type +v's role in analyzing -XTypeApplications in GHCi

Summary:
The section on `-XTypeApplications` in the users' guide isn't terribly
clear on how to view the visibility of a function type signature's type
variables in GHCi properly (i.e., using the `:type +v` GHCi command). This
adds some more exposition that demonstrates how to use `:type +v` (and why you
don't want to use `:type`).

Fixes #13401.

Test Plan: Eyeball it

Reviewers: bgamari, austin, goldfire, crockeea

Reviewed By: goldfire, crockeea

Subscribers: rwbarton, thomie, crockeea

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

(cherry picked from commit b335f506f1d3a766de849e015f6732ae130247a4)