ghc.git
2 years agoFaster checkFamInstConsistency wip/T13719
Bartosz Nitka [Fri, 19 May 2017 15:08:01 +0000 (08:08 -0700)] 
Faster checkFamInstConsistency

Summary:
This implements the idea from
https://ghc.haskell.org/trac/ghc/ticket/13092#comment:14.

It's explained in Note [Checking family instance optimization]
in more detail.

This improves the test case T13719 tenfold and
cuts down the compile time on `:load` in `ghci` on our
internal code base by half.

Test Plan: ./validate

Reviewers: simonpj, simonmar, rwbarton, austin, bgamari

Subscribers: thomie

GHC Trac Issues: #13719

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

2 years agoExtend ModuleSet with useful functions
Bartosz Nitka [Mon, 22 May 2017 17:16:26 +0000 (10:16 -0700)] 
Extend ModuleSet with useful functions

2 years agoTestcase for type family consistency checks
Bartosz Nitka [Mon, 22 May 2017 16:01:05 +0000 (12:01 -0400)] 
Testcase for type family consistency checks

Based on my quick search, we don't have a test
that verifies that we check the type family instances of
currently compiled module against direct or indirect
dependencies.

This adds two tests: for a direct dependency and
for an indirect dependency.

I also added a comment to make it clear what the 'Over'
test tests.

Other than completeness, it makes sense to have these
tests because if you look at
Note [The type family instance consistency story] in FamInsts
these cases are checked through different mechanisms.

Test Plan: new tests

Reviewers: simonmar, rwbarton, simonpj, austin, bgamari

Reviewed By: simonpj, bgamari

Subscribers: thomie

GHC Trac Issues: #13719

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

2 years agoTestcase for #13719
Bartosz Nitka [Mon, 22 May 2017 16:00:52 +0000 (12:00 -0400)] 
Testcase for #13719

I expect to improve this, a testcase will ensure
it doesn't regress.

Test Plan: ./validate

Reviewers: simonmar, austin, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #13719

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

2 years agoAdd "header" to GHC_COLORS
Phil Ruffwind [Mon, 22 May 2017 16:00:34 +0000 (12:00 -0400)] 
Add "header" to GHC_COLORS

Add "header" to GHC_COLORS and allow colors to be inherited from the
surroundings.

Test Plan: validate

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #13718

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

2 years agoHandle file targets in missing home modules warning
Herbert Valerio Riedel [Mon, 22 May 2017 15:59:56 +0000 (11:59 -0400)] 
Handle file targets in missing home modules warning

When main module is listed on command line as a file, we should not
issue a warning about it. See Trac #13727

Reviewers: austin, bgamari, Yuras

Reviewed By: bgamari, Yuras

Subscribers: 23Skidoo, rwbarton, thomie

GHC Trac Issues: #13727

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

2 years agofix a memory leak in osNumaMask
Kubo Kovac [Mon, 22 May 2017 15:51:55 +0000 (11:51 -0400)] 
fix a memory leak in osNumaMask

got an error when using asan:
```
==1866689==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 16 byte(s) in 1 object(s) allocated from:
    #0 0x10640568 in malloc ??:?
    #1 0x154d867e in numa_bitmask_alloc .../numactl-2.0.8/libnuma_nosymve r.c:204
    #2 0x154d867e in numa_allocate_nodemask .../numactl-2.0.8/libnuma_nosymve r.c:724
    #3 0x154d867e in numa_get_mems_allowed .../numactl-2.0.8/libnuma_nosymve r.c:1141
    #4 0x10b54a45 in osNumaMask ...ghc-8.0.2/rts/posix/OSMem.c:59 8
```

Test Plan: compile, validate

Reviewers: simonmar, niteria, austin, bgamari, erikd

Reviewed By: bgamari

Subscribers: rwbarton, thomie

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

2 years agoRewrite boot in Python
Ben Gamari [Mon, 22 May 2017 15:50:55 +0000 (11:50 -0400)] 
Rewrite boot in Python

Test Plan: Validate

Reviewers: hvr, austin

Subscribers: rwbarton, thomie, erikd

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

2 years agoEnsure package.cache is newer than registration files after make install
Ben Gamari [Sun, 21 May 2017 15:11:30 +0000 (11:11 -0400)] 
Ensure package.cache is newer than registration files after make install

Rebuild package.cache to ensure that it's newer than the package
database registration files, avoiding out-of-date cache warnings from
ghc-pkg. See #13375.

Test Plan: `make install`, run `ghc-pkg list`, look for out-of-date
cache warning

Reviewers: austin

Subscribers: rwbarton, thomie

GHC Trac Issues: #13375

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

2 years agoAdd missing "do" to example in arrow docs.
null-a [Mon, 22 May 2017 09:13:14 +0000 (10:13 +0100)] 
Add missing "do" to example in arrow docs.

2 years agoFix levity polymorphism docs
Alexey Vagarenko [Sun, 21 May 2017 10:08:41 +0000 (15:08 +0500)] 
Fix levity polymorphism docs

2 years agoBump to LLVM 4.0
Moritz Angermann [Sat, 20 May 2017 16:57:15 +0000 (12:57 -0400)] 
Bump to LLVM 4.0

The llvm textual ir seems to have stayed sufficiently similar from llvm
3.9 to llvm 4.0, such that a simple bump is possible.

Reviewers: austin, hvr, bgamari, erikd

Reviewed By: bgamari, erikd

Subscribers: rwbarton, thomie, erikd

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

2 years agoPretty-print strict record fields from ifaces correctly
Ryan Scott [Sat, 20 May 2017 16:56:50 +0000 (12:56 -0400)] 
Pretty-print strict record fields from ifaces correctly

We need to use parentheses more when pretty-printing types with bang
patterns within constructors that use record syntax. Fixes #13699.

Test Plan: make test TEST=T13699

Reviewers: austin, bgamari, dfeuer

Reviewed By: dfeuer

Subscribers: dfeuer, rwbarton, thomie

GHC Trac Issues: #13699

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

2 years agoA few documentation fixes
David Feuer [Sat, 20 May 2017 16:56:20 +0000 (12:56 -0400)] 
A few documentation fixes

`MIN_VERSION_pkg` was documented backwards. An important caveat
about initializing the Haskell runtime was buried in a footnote.
The documentation of `-dynamic` was (even more) confusing.

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

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

2 years agoCorrectly expand lines with multiple tabs
Phil Ruffwind [Sat, 20 May 2017 16:48:26 +0000 (12:48 -0400)] 
Correctly expand lines with multiple tabs

rwbarton pointed out that tab expansions can affect the column numbers
of subsequent characters, so a unstateful map + zip won't do.  This
commit hopefully fixes that.  It also adds a test for this particular
case.

Test Plan: validate

Reviewers: bgamari, rwbarton, austin

Reviewed By: bgamari

Subscribers: dfeuer, thomie

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

2 years agobase: Explicitly mark Data.Either.{left,right} as INLINABLE
Ben Gamari [Sat, 20 May 2017 16:48:03 +0000 (12:48 -0400)] 
base: Explicitly mark Data.Either.{left,right} as INLINABLE

Test Plan: read it

Reviewers: dfeuer, austin, hvr, nomeata

Reviewed By: dfeuer, nomeata

Subscribers: nomeata, rwbarton, thomie

GHC Trac Issues: #13689

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

2 years agoCompile modules that are needed by template haskell, even with -fno-code.
Douglas Wilson [Sat, 20 May 2017 16:47:41 +0000 (12:47 -0400)] 
Compile modules that are needed by template haskell, even with -fno-code.

This patch relates to Trac #8025

The goal here is to enable typechecking of packages that contain some
template haskell. Prior to this patch, compilation of a package with
-fno-code would fail if any functions in the package were called from
within a splice.

downsweep is changed to do an additional pass over the modules,
targetting any ModSummaries transitively depended on by a module that
has LangExt.TemplateHaskell enabled. Those targeted modules have
hscTarget changed from HscNothing to the default target of the platform.

There is a small change to the prevailing_target logic to enable this.

A simple test is added.

I have benchmarked with and without a patched haddock
(available:https://github.com/duog/haddock/tree/wip-no-explicit-th-compi
lation).  Running cabal haddock on the wreq package results in a 25%
speedup on my machine:

time output from patched cabal haddock:

real    0m5.780s
user    0m5.304s
sys     0m0.496s
time output from unpatched cabal haddock:

real    0m7.712s
user    0m6.888s
sys     0m0.736s

Reviewers: austin, bgamari, ezyang

Reviewed By: bgamari

Subscribers: bgamari, DanielG, rwbarton, thomie

GHC Trac Issues: #8025

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

2 years agoCNF: Silence pointer fix-up message unless gc debugging is enabled
Ben Gamari [Wed, 17 May 2017 14:22:55 +0000 (10:22 -0400)] 
CNF: Silence pointer fix-up message unless gc debugging is enabled

2 years agoFailing test case for #13734
Joachim Breitner [Sat, 20 May 2017 18:09:21 +0000 (14:09 -0400)] 
Failing test case for #13734

2 years agoImprove error msg for simplifier tick exhaustion
David Feuer [Fri, 19 May 2017 22:09:43 +0000 (18:09 -0400)] 
Improve error msg for simplifier tick exhaustion

Simplifier tick exhaustion is not necessarily "impossible", and
isn't even always a GHC bug, per se. Improve the error message.
Furthermore, the simplifier code has access to `IO`, so we can
throw a proper `IO` exception instead of panicking.

Reviewers: austin, bgamari, angerman

Reviewed By: angerman

Subscribers: angerman, rwbarton, thomie

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

2 years agoModern type signature style in Module
Bartosz Nitka [Fri, 19 May 2017 14:54:06 +0000 (07:54 -0700)] 
Modern type signature style in Module

2 years agoFix scoping of data cons during kind checking
Simon Peyton Jones [Fri, 19 May 2017 13:57:59 +0000 (14:57 +0100)] 
Fix scoping of data cons during kind checking

Trac #13625 pointed out that in

   data X :: Y where Y :: X

we need 'Y' to be in scope (as APromotionErr) when dealing with
X's kind signature.  Previously we got a crash.

This patch simplifies the code as well as making it work.

2 years agoAccount for IfUnpackCo in freeNamesIfDecl
Simon Peyton Jones [Fri, 19 May 2017 11:00:26 +0000 (12:00 +0100)] 
Account for IfUnpackCo in freeNamesIfDecl

We were simply failing to recognise all the free variables of an
IfaceDecl, notably the ones in the coercion of an IfUnpackCo.
Result: the dependency analysis got messed up, so that fingerprint
calculation went wrong.  Trac #13695 showed it up.

A test case is tricky but the fix is a solid one.

2 years agoRefactor freeNamesIfDecl
Simon Peyton Jones [Fri, 19 May 2017 10:57:21 +0000 (11:57 +0100)] 
Refactor freeNamesIfDecl

This just switches to using pattern matching rather than field
selectors, which I generally prefer.  No change in behaviour.

2 years agoComments and white space only
Simon Peyton Jones [Fri, 19 May 2017 10:55:38 +0000 (11:55 +0100)] 
Comments and white space only

2 years agoFix Haddock markup
Alexey Vagarenko [Thu, 18 May 2017 21:49:18 +0000 (02:49 +0500)] 
Fix Haddock markup

2 years agoEnsure that insolubles are fully rewritten
Simon Peyton Jones [Fri, 19 May 2017 09:50:35 +0000 (10:50 +0100)] 
Ensure that insolubles are fully rewritten

I was alerted to this by Trac #12468 and #11325.  We were treating
insolubles (and "hole" constraints are treated as insoluble)
inconsistently.  In some places we were carefully rewriting them
e.g. Note [Make sure that insolubles are fully rewritten] in
TcCanonical.  But in TcSimplify we weren't feeding them into
the solver.

As a result, "hole" constraints were not being rewritten, which
some users found confusing, and I think rightly so.

This patch also fixes a bug in TcSMonad.emitInsoluble, in which two
different "hole" constriants could be treated (bogusly) as duplicates,
thereby losing one.

2 years agoInsert missing newline
Frederik Hanghøj Iversen [Thu, 18 May 2017 12:26:10 +0000 (14:26 +0200)] 
Insert missing newline

2 years agoHandle type-lets better
Simon Peyton Jones [Wed, 17 May 2017 08:44:46 +0000 (09:44 +0100)] 
Handle type-lets better

Core allows non-recursive type-lets, thus

   let a = TYPE ty in ...

They are substituted away very quickly, but it's convenient for
some passes to produce them (rather than to have to substitute
immediately).

Trac #13708 tried the effect of not running the simplifer at all
(a rather bizarre thing to do, but still).  That showed that some
passes crashed because they always treated a let-bounder binder
as an Id.  This patch adds some easy fixes.

2 years agoFix #13703 by correctly using munged names in ghc-pkg.
Edward Z. Yang [Tue, 16 May 2017 04:17:45 +0000 (21:17 -0700)] 
Fix #13703 by correctly using munged names in ghc-pkg.

Summary:
Cabal internal libraries are implemented using a trick, where the 'name'
field in ghc-pkg registration file is munged into a new form to keep
each internal library looking like a distinct package to ghc-pkg and
other tools; e.g. the internal library q from package p is named
z-p-z-q.

Later, Cabal library got refactored so that we made a closer distinction
between these "munged" package names and the true package name of a
package.  Unfortunately, this is an example of a refactor for clarity in
the source code which ends up causing problems downstream, because the
point of "munging" the package name was to make it so that ghc-pkg and
similar tools transparently used MungedPackageName whereever they
previously used PackageName (in preparation for them learning proper
syntax for package name + component name).  Failing to do this meant
that internal libraries from the same package (but with different
names) clobber each other.

This commit search-replaces most occurrences of PackageName in
ghc-pkg and turns them into MungedPackageName. Otherwise there
shouldn't be any functional differenes.

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

Reviewers: bgamari, austin

Subscribers: rwbarton, thomie

GHC Trac Issues: #13703

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

2 years agoFix the pure unifier
Simon Peyton Jones [Tue, 16 May 2017 14:43:55 +0000 (15:43 +0100)] 
Fix the pure unifier

This patch fixes Trac #13705, by fixing a long-standing outright bug
in the pure unifier.  I'm surprised this hasn't caused more trouble
before now!

2 years agoTiny refactor
Simon Peyton Jones [Tue, 16 May 2017 14:42:34 +0000 (15:42 +0100)] 
Tiny refactor

2 years agoKill off unused IfaceType.eqIfaceType
Simon Peyton Jones [Tue, 16 May 2017 10:56:23 +0000 (11:56 +0100)] 
Kill off unused IfaceType.eqIfaceType

Edward implemented these functions, but they aren't
used any more.  Trac #13679

2 years agotestsuite: Add testcase for T13658
Ben Gamari [Tue, 16 May 2017 00:15:11 +0000 (20:15 -0400)] 
testsuite: Add testcase for T13658

2 years agoPrint warnings on parser failures (#12610).
Dave Laing [Mon, 15 May 2017 20:09:11 +0000 (16:09 -0400)] 
Print warnings on parser failures (#12610).

Test Plan: validate

Reviewers: austin, bgamari, simonmar, mpickering

Reviewed By: mpickering

Subscribers: mpickering, rwbarton, thomie

GHC Trac Issues: #12610

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

2 years agousers-guide: Document -g flag
Ben Gamari [Mon, 15 May 2017 18:21:38 +0000 (14:21 -0400)] 
users-guide: Document -g flag

2 years agoRevert "Use a deterministic map for imp_dep_mods"
Bartosz Nitka [Mon, 15 May 2017 11:44:35 +0000 (04:44 -0700)] 
Revert "Use a deterministic map for imp_dep_mods"

This reverts commit 7fea7121ce195e562a5443c0a8ef3861504ef1b3.
It turns out that on a newly added MultiLayerModules test
case it gets very expensive to union the transitive module
sets while preserving determinism.

Fortunately, we can just sort to restore determinism
when converting imp_dep_mods to a list.

Test Plan: ./validate

Reviewers: simonmar, austin, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

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

2 years agoStress test for nested module hierarchies
Bartosz Nitka [Fri, 12 May 2017 13:38:18 +0000 (06:38 -0700)] 
Stress test for nested module hierarchies

I'm optimizing a case that is well approximated by
multiple layers of modules where every module in a layer
imports all the modules in the layer below.

It turns out I regressed performance on such cases in 7fea7121.
I'm adding a test case to track improvements and prevent
future regressions.

Test Plan: ./validate

Reviewers: simonmar, austin, bgamari

Subscribers: rwbarton, thomie

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

2 years agoRevert "Stress test for nested module hierarchies"
Bartosz Nitka [Mon, 15 May 2017 11:21:52 +0000 (04:21 -0700)] 
Revert "Stress test for nested module hierarchies"

This reverts commit e527fc2e90958280a36645b6bd0223861cc50a55.

I merged more than I intended in e527fc2e, I will merge
D3575 and D3577 separately.

2 years agoStress test for nested module hierarchies
Bartosz Nitka [Mon, 15 May 2017 11:14:01 +0000 (04:14 -0700)] 
Stress test for nested module hierarchies

I'm optimizing a case that is well approximated by
multiple layers of modules where every module in a layer
imports all the modules in the layer below.

It turns out I regressed performance on such cases in 7fea7121.
I'm adding a test case to track improvements and prevent
future regressions.

Test Plan: ./validate

Reviewers: simonmar, austin, bgamari

Reviewed By: simonmar

Subscribers: rwbarton, thomie

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

2 years agorts/linker/ElfTypes.h: restore powerps (and others) support
Sergei Trofimovich [Sun, 14 May 2017 19:33:16 +0000 (20:33 +0100)] 
rts/linker/ElfTypes.h: restore powerps (and others) support

GHC build fails for powerpc-unknown-linux-gnu
and hppa-unknown-linux-gnu targets as:
  rts_dist_HC rts/dist/build/RtsStartup.o
    rts/linker/ElfTypes.h:23:4: error:
         error: #error "Unsupported arch!"

Before the change code tried to whitelist architectures
and classify them into ELF32/ELF64. It does not work
for UNREG arches like 'hppa', 'sparc64', 'm68k', 'mips'.

It is nuanced for things like mips64 and x86_64:
    'mips64-unknown-linux-gnu-gcc -mabi=64' is ELFCLASS64
    'mips64-unknown-linux-gnu-gcc'          is ELFCLASS32
    'x86_64-pc-linux-gnu-gcc'               is ELFCLASS64
    'x86_64-pc-linux-gnu-gcc -mx32'         is ELFCLASS32
Here it's not enough to know HOST_ARCH. We really need to
know ABI.

The change uses '__LP64__' as a proxy for ELFCLASS64.

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

Reviewed By: angerman, bgamari, erikd

Subscribers: rwbarton, thomie

GHC Trac Issues: #13696

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

2 years agorts: annotate switch/case with '/* fallthrough */'
Sergei Trofimovich [Sun, 14 May 2017 19:22:37 +0000 (20:22 +0100)] 
rts: annotate switch/case with '/* fallthrough */'

Fixes gcc-7.1.0 warnings of form:

  rts/sm/Scav.c:559:9: error:
     error: this statement may fall through [-Werror=implicit-fallthrough=]
             scavenge_fun_srt(info);
             ^~~~~~~~~~~~~~~~~~~~~~

Many of places are indeed unobvious and some are
already annotated by comments.

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
2 years agoProfilerReportJson.c: fix out-of-bounds access
Sergei Trofimovich [Sun, 14 May 2017 19:21:50 +0000 (20:21 +0100)] 
ProfilerReportJson.c: fix out-of-bounds access

Found by gcc-7.1 which reported build error as:

rts/ProfilerReportJson.c:23:16: error:
     error: comparison between pointer and zero
       character constant [-Werror=pointer-compare]
         for (; str != '\0' && len > 0; str++) {
                    ^~
   |
23 |     for (; str != '\0' && len > 0; str++) {
   |                ^

Unfixed code in context:

```c
  static void escapeString(char const* str, char *out, int len)
  {
     len--; // reserve character in output for terminating NUL
     for (; str != '\0' && len > 0; str++) {
         char c = *str;
```

The intent here is to process 'len' (if positive) or '\0'-terminator
in 'str' but dereference was missing.

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
2 years agoUpdate unix submodule
Ben Gamari [Sun, 14 May 2017 01:19:45 +0000 (21:19 -0400)] 
Update unix submodule

2 years agoincludes/Stg.h: '#if sparch_HOST_ARCH' -> '#if defined(sparch_HOST_ARCH)'
Sergei Trofimovich [Sun, 14 May 2017 08:17:37 +0000 (09:17 +0100)] 
includes/Stg.h: '#if sparch_HOST_ARCH' -> '#if defined(sparch_HOST_ARCH)'

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
2 years agoAdd a test for #12600
David Feuer [Sat, 13 May 2017 23:26:59 +0000 (19:26 -0400)] 
Add a test for #12600

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #12600

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

2 years agoAdd a test for #11272
David Feuer [Sat, 13 May 2017 20:09:31 +0000 (16:09 -0400)] 
Add a test for #11272

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #11272

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

2 years agoRevert "Treat banged bindings as FunBinds"
Ben Gamari [Fri, 12 May 2017 20:59:33 +0000 (16:59 -0400)] 
Revert "Treat banged bindings as FunBinds"

This partially reverts commit 372995364c52eef15066132d7d1ea8b6760034e6 as it
doesn't actually fix #13594. Namely it does not revert the mkPrefixFunRhs
refactoring since this is rather independent from the functional changes.

Going to try again with a whole working patch

2 years agoBump haddock submodule
Ben Gamari [Fri, 12 May 2017 18:48:03 +0000 (14:48 -0400)] 
Bump haddock submodule

Fixes lazy IO bug

2 years agoRender \t as 8 spaces in caret diagnostics
Phil Ruffwind [Thu, 11 May 2017 19:41:08 +0000 (15:41 -0400)] 
Render \t as 8 spaces in caret diagnostics

Test Plan: validate

Reviewers: austin, bgamari, rwbarton

Reviewed By: bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #13664

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

2 years agoFix crash in isModuleInterpreted for HsBoot (fixes #13591)
Lennart Spitzner [Wed, 10 May 2017 14:47:19 +0000 (16:47 +0200)] 
Fix crash in isModuleInterpreted for HsBoot (fixes #13591)

Rename isModuleInterpreted to moduleIsBootOrNotObjectLinkable
because a) there already is a moduleIsInterpreted function in
the same module b) I have no idea if the (new) semantic of
the bool returned matches some understanding of
"is interpreted".

2 years agoAutomatically add SCCs to INLINABLE bindings
David Feuer [Fri, 12 May 2017 18:37:36 +0000 (14:37 -0400)] 
Automatically add SCCs to INLINABLE bindings

Instead of excluding `isAnyInlinePragma`, just exclude
`isInlinePragma`. This makes GHC behave as documented;
the user's guide only indicates that GHC does not automatically
add SCCs to `INLINE` bindings.

Fixes #12962.

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: DemiMarie, osa1, Mikolaj, simonpj, rwbarton, thomie

GHC Trac Issues: #12962

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

2 years agoAdd regression test for #11964
Ryan Scott [Fri, 12 May 2017 13:06:24 +0000 (09:06 -0400)] 
Add regression test for #11964

This issue was only ever present in the GHC 8.0.1 release candidates, but
let's add a regression test for it just to be safe.

2 years agoAdd regression test for #11966
Ryan Scott [Fri, 12 May 2017 12:57:26 +0000 (08:57 -0400)] 
Add regression test for #11966

Commit a7ee2d4c4229b27af324ebac93081f692835365d fixed #11966. Here's a
regression test for it.

2 years agoAdd regression tests for #12083
Ryan Scott [Fri, 12 May 2017 12:54:30 +0000 (08:54 -0400)] 
Add regression tests for #12083

Summary:
Commit 0c9d9dec0a924a4f34f4cff26d004143c028861a (the fix for #13271) fixed the
programs in #12083. This adds regression tests for them.

Test Plan: make test TEST="T12083a T12083b"

Reviewers: austin, bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #12083

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

2 years agoTypos [ci skip]
Gabor Greif [Thu, 11 May 2017 13:13:02 +0000 (15:13 +0200)] 
Typos [ci skip]

2 years agoUpdate autoconf scripts from correct source
Ben Gamari [Fri, 12 May 2017 01:33:58 +0000 (21:33 -0400)] 
Update autoconf scripts from correct source

2 years agoRnEnv refactoring
Matthew Pickering [Thu, 11 May 2017 21:21:43 +0000 (22:21 +0100)] 
RnEnv refactoring

Summary: Lots of refactoring in RnEnv to reduce code duplication.

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #13545

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

2 years agotestsuite: Fix location of T13594 test
Ben Gamari [Thu, 11 May 2017 22:20:33 +0000 (18:20 -0400)] 
testsuite: Fix location of T13594 test

2 years agoFix up tests for #13594
Ben Gamari [Thu, 11 May 2017 21:30:31 +0000 (17:30 -0400)] 
Fix up tests for #13594

This adds the GHCi variant of the failing program in #13594. Also, I
inadvertently changed the T13594 test previously introduced in a way that made
it no longer faithfully test the ticket as written. Fix this.

2 years agoUpdate autoconf scripts
Ben Gamari [Thu, 11 May 2017 21:25:40 +0000 (17:25 -0400)] 
Update autoconf scripts

2 years agousers-guide: Document requirement of at least one -dep-suffix
Ben Gamari [Thu, 11 May 2017 20:49:54 +0000 (16:49 -0400)] 
users-guide: Document requirement of at least one -dep-suffix

This requirement was introduced around 7.8 but was never documented.

Resolves #9287.

2 years agoAllow spliced patterns in pattern synonyms
Ben Gamari [Thu, 11 May 2017 19:46:37 +0000 (15:46 -0400)] 
Allow spliced patterns in pattern synonyms

This ended up being quite simple.

Reviewers: austin, goldfire, mpickering

Subscribers: rwbarton, shlevy, thomie

GHC Trac Issues: #13688

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

2 years agoFix collect_lpat's treatment of HsSplicedPats
Ryan Scott [Thu, 11 May 2017 19:46:02 +0000 (15:46 -0400)] 
Fix collect_lpat's treatment of HsSplicedPats

`collect_lpat` was missing a case for `HsSplicedPat`, which caused
incorrect renaming of TH-spliced pattern variables.

Fixes #13473.

Test Plan: make test TEST=T13473

Reviewers: facundominguez, austin, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #13473

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

2 years agoParenthesize pretty-printed equalities when necessary
Ryan Scott [Thu, 11 May 2017 19:42:55 +0000 (15:42 -0400)] 
Parenthesize pretty-printed equalities when necessary

Fixes #13677 by parenthesizing equalities in a sufficiently high
pretty-printing context.

Test Plan: make test TEST=T13677

Reviewers: goldfire, austin, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #13677

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

2 years agoUse Proxy rather than undefined in MatchLit
Matthew Pickering [Thu, 11 May 2017 19:42:23 +0000 (15:42 -0400)] 
Use Proxy rather than undefined in MatchLit

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

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

2 years agoAdd Outputable instance for Node
Matthew Pickering [Thu, 11 May 2017 19:42:02 +0000 (15:42 -0400)] 
Add Outputable instance for Node

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

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

2 years agorts: Don't build StgCRunAsm.S if unregisterised
Ben Gamari [Thu, 11 May 2017 19:41:38 +0000 (15:41 -0400)] 
rts: Don't build StgCRunAsm.S if unregisterised

StgCRunAsm.S provides StgCRun on powerpc64le platforms when
registerised.  However, in the unregisterised setting we use the
mini-interpreter and consequently shouldn't build StgCRunAsm.S lest we
get duplicate symbols.

Test Plan: Build unregisterised compiler on AIX.

Reviewers: hvr, trommler, austin, simonmar

Reviewed By: trommler, simonmar

Subscribers: rwbarton, thomie

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

2 years agocompiler: Do not look up fail in RnExpr if bind pattern is irrefutible.
Aaron Friel [Thu, 11 May 2017 19:41:22 +0000 (15:41 -0400)] 
compiler: Do not look up fail in RnExpr if bind pattern is irrefutible.

Adds a check in `rnStmt`, in sub-expr `getFailFunction`, to determine if
the pattern of a bind statement is irrefutible. If so, skip looking up
the `fail` name.

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #13649

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

2 years agoFix incorrect ambiguity error on identically-named data constructors
Soham Chowdhury [Thu, 11 May 2017 19:40:18 +0000 (15:40 -0400)] 
Fix incorrect ambiguity error on identically-named data constructors

Given multiple in-scope constructors with the same name, say `A`, and a
function of type `A -> Int`, say, the compiler reports both a "type `A`
is not in scope" and (incorrectly) an ambiguity error. The latter
shouldn't be there if `DataKinds` isn't enabled.

This issue was recommended to me by @mpickering as a suitable first
task, and the fix was also outlined in the original Trac ticket. It
involved a simple reordering of the steps taken in `lookup_demoted` in
`RnEnv.hs`. The fix is to make the `DataKinds` check happen earlier,
ensuring that the ambiguity check doesn't happen at all if we know the
constructors couldn't have been promoted.

Signed-off-by: Soham Chowdhury <chow.soham@gmail.com>
Reviewers: mpickering, austin, bgamari

Reviewed By: mpickering, bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #13568

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

2 years agopmCheck: Don't generate PmId OccNames from Uniques
Ben Gamari [Thu, 11 May 2017 04:17:04 +0000 (00:17 -0400)] 
pmCheck: Don't generate PmId OccNames from Uniques

Doug Wilson astutely noticed that the pattern match checker was spending
a significant amount of time in mkPmId. It turns out that it was
producing Ids with OccNames that were generated from a Unique, which are
non-trivial to render. Since Var is strict in Name, Name in OccName, and
OccName in its FastString all of this encoding work was being done
despite the fact that it was (as far as I can tell) never actually
needed.

Test Plan: Validate, note allocations of `T11195`

Reviewers: austin, gkaracha

Subscribers: rwbarton, thomie

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

2 years agoAdd regression test for #12850
Ryan Scott [Thu, 11 May 2017 13:33:43 +0000 (09:33 -0400)] 
Add regression test for #12850

Commit e7985ed23ddc68b6a2e4af753578dc1d9e8ab4c9 happened to fix #12850, so
let's add a regression test for the program reported in #12850.

2 years agoRevert "libffi via submodule"
Moritz Angermann [Thu, 11 May 2017 13:12:34 +0000 (21:12 +0800)] 
Revert "libffi via submodule"

This reverts commit 8d4bce42de7929b0dec7e7d68e66bcfc4d266322.

2 years agoUse NEED_PTHREAD_LIB
Moritz Angermann [Thu, 11 May 2017 10:17:31 +0000 (18:17 +0800)] 
Use NEED_PTHREAD_LIB

we do the same for the rts already. And using the configure script should
be more robust than hand-picking the OSs here.

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

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

2 years agoPass LLVMTarget (identical to --target)
Moritz Angermann [Thu, 11 May 2017 10:17:02 +0000 (18:17 +0800)] 
Pass LLVMTarget (identical to --target)

Sometimes it might be of interest to
have access to the raw target value when calling
subcommands (e.g. llvm tools with --target), as
such we forward the specified (or inferred)
--target for later consumption.

Reviewers: austin, hvr, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie, erikd

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

2 years agobump config.{guess,sub}
Moritz Angermann [Thu, 11 May 2017 10:15:46 +0000 (18:15 +0800)] 
bump config.{guess,sub}

There is no new autoconf release, and it seems like there will unlikely be one
<http://lists.gnu.org/archive/html/autoconf/2016-07/msg00017.html>.

This will allow us to support <arch>-apple-ios properly.

These have been taken from
- http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess
- http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub

Reviewers: austin, hvr, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

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

2 years agoDrop custom apple handling
Moritz Angermann [Thu, 11 May 2017 10:15:22 +0000 (18:15 +0800)] 
Drop custom apple handling

We know that *-apple-* is leading_underscores, and .dylib.
It is also better to test for TargetVendor being apple, rather than
relying on targetOS, which could be macOS, iOS, tvOS, watchOS,
or any other glorious name apple could come up with.

Reviewers: austin, hvr, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie, erikd

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

2 years agoFix iossimulator
Moritz Angermann [Thu, 11 May 2017 10:14:47 +0000 (18:14 +0800)] 
Fix iossimulator

The introduction of the aarch64 linker for
iOS forgot that the ios simulator was still using
the x86_64/mach-o linker, which requires the use of
symbol extras.  Until this is overhauled (see #13678),
we should revert to the symbol extras logic for
x86_64-apple-ios

Reviewers: austin, bgamari, erikd, simonmar

Reviewed By: simonmar

Subscribers: rwbarton, thomie

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

2 years agoWe define the `<XXX>_HOST_ARCH` to `1`, but never to `0`in
Moritz Angermann [Thu, 11 May 2017 10:14:26 +0000 (18:14 +0800)] 
We define the `<XXX>_HOST_ARCH` to `1`, but never to `0`in

compiler/ghc.mk
@echo "#define $(HostArch_CPP)_HOST_ARCH 1"               >> $@
@echo "#define $(TargetArch_CPP)_HOST_ARCH 1"             >> $@

this leads to warnigns like:
> warning: 'x86_64_HOST_ARCH' is not defined, evaluates to 0 [-Wundef]

Reviewers: austin, bgamari, erikd, simonmar

Reviewed By: simonmar

Subscribers: rwbarton, thomie

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

2 years ago[iserv] fix loadDLL
Moritz Angermann [Thu, 11 May 2017 10:13:28 +0000 (18:13 +0800)] 
[iserv] fix loadDLL

When we load non absolute pathed .so's this usually implies that we expect the
system to have them in place already, and hence we should not need to ship them.
Without the absolute path to the library, we are also unable to open and send
said library.  Thus we'll do library shipping only for libraries with absolute
paths.

Reviewers: austin, bgamari, simonmar

Reviewed By: simonmar

Subscribers: simonmar, rwbarton, thomie

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

2 years agoDo not hardcode the specific linker to use
Moritz Angermann [Thu, 11 May 2017 10:12:33 +0000 (18:12 +0800)] 
Do not hardcode the specific linker to use

This should be handled appropriately by a wrapper script around the compiler,
if one wants to insist on the specific linker to be used.  Otherwise this
breaks if the used compiler fails to understand this directive.

I believe that using a specific linker should be part of the compilers
toolchain, we delegate to and not hardcoded here in ghc.

Reviewers: dfeuer, erikd, hvr, austin, rwbarton, bgamari

Reviewed By: bgamari

Subscribers: snowleopard, davean, dfeuer, thomie, erikd

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

2 years agolibffi via submodule
Moritz Angermann [Thu, 11 May 2017 10:11:12 +0000 (18:11 +0800)] 
libffi via submodule

This is rather annoying. I'd prefer to have a stable release to
use. However libffi-3.2.1 has been released November 12, 2014, and
libffi-4 is TBD. See also https://github.com/libffi/libffi/issues/296

The core reason for this change is that llvm changed the supported
assembly to unified syntax, which libffi-3.2.1 does not use, and hence
fails to compile for arm with llvm. For refence, see the following
issue: https://github.com/libffi/libffi/issues/191

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie, snowleopard

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

2 years agomailmap: Add Douglas Wilson
Ben Gamari [Thu, 11 May 2017 02:51:25 +0000 (22:51 -0400)] 
mailmap: Add Douglas Wilson

2 years agotestsuite: Update allocations for T4801 on Darwin
Ben Gamari [Wed, 10 May 2017 17:02:41 +0000 (13:02 -0400)] 
testsuite: Update allocations for T4801 on Darwin

2 years agoFix a performance bug in GhcMake.downsweep
Simon Marlow [Wed, 10 May 2017 12:05:38 +0000 (05:05 -0700)] 
Fix a performance bug in GhcMake.downsweep

Every time we encountered a non-home module during the downsweep, we
were removing it from the finder cache.  That meant we were searching
the filesystem for every import, rather than once per downsweep.  The
fix is just to flush the finder cache before the downsweep, and
repopulate it for home modules that haven't changed.

Speeds up downsweep by about 25% on a large example I have.

Test Plan: Harbourmaster

Reviewers: bgamari, niteria, austin, erikd

Reviewed By: bgamari, niteria

Subscribers: rwbarton, thomie

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

2 years agoEfficient membership for home modules
Bartosz Nitka [Wed, 10 May 2017 11:36:52 +0000 (04:36 -0700)] 
Efficient membership for home modules

This changes the linear lookup in a list to an efficient
lookup in an IntMap. The linear lookup effectively made
the algorithm quadratic, which for a test case that I have
(5000 modules) introduced significant slowdown.

I ran 3 experiments to estimate the impact of this:

"No-op", profiled, just `:load`: P146, `186s`
"before", profiled, `:load` followed by 10x `:r`: P147, `315s`
"after", profiled, `:load` followed by 10x `:r`: P148, `250s`

Going by the math of `(250-186)/(315-186) = 50%` this is a 2x improvement
on `:r`.

Test Plan: ./validate

Reviewers: simonmar, austin, bgamari

Reviewed By: simonmar

Subscribers: rwbarton, thomie

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

2 years agoTypos [ci skip]
Gabor Greif [Tue, 9 May 2017 11:49:00 +0000 (13:49 +0200)] 
Typos [ci skip]

2 years agoRevert "CoreTidy: Don't seq unfoldings"
Ben Gamari [Tue, 9 May 2017 20:00:29 +0000 (16:00 -0400)] 
Revert "CoreTidy: Don't seq unfoldings"

This reverts commit b3da6a6c3546562d5c5e83b8af5d3fd04c07e0c1 as it
reintroduces the original space leak.

2 years agoReset cc_pend_sc flag in dropDerivedCt
Simon Peyton Jones [Tue, 9 May 2017 08:29:44 +0000 (09:29 +0100)] 
Reset cc_pend_sc flag in dropDerivedCt

I'd forgotten to reset this flag to True when dropping Derived
constraints, which led to Trac #13662.  Easily fixed.

2 years agoMake CallInfo into a data type with fields
Simon Peyton Jones [Mon, 8 May 2017 15:50:37 +0000 (16:50 +0100)] 
Make CallInfo into a data type with fields

Simple refactor, no change in behaviour

2 years agoAdd regression test for Trac #13659
Simon Peyton Jones [Mon, 8 May 2017 13:06:01 +0000 (14:06 +0100)] 
Add regression test for Trac #13659

2 years agoDon't warn about variable-free strict pattern bindings
Simon Peyton Jones [Mon, 8 May 2017 13:04:34 +0000 (14:04 +0100)] 
Don't warn about variable-free strict pattern bindings

See Trac #13646 and the new
Note [Pattern bindings that bind no variables]

2 years agoUse mkSymCo in OptCoercion.wrapSym
Simon Peyton Jones [Mon, 8 May 2017 12:31:11 +0000 (13:31 +0100)] 
Use mkSymCo in OptCoercion.wrapSym

Always use the smart constructor!   Richard and I came across
this omission when looking at something else.

2 years agotestsuite: Fix attribution of "Don't seq unfoldings" regression
Ben Gamari [Tue, 9 May 2017 03:38:16 +0000 (23:38 -0400)] 
testsuite: Fix attribution of "Don't seq unfoldings" regression

2 years agoTreat banged bindings as FunBinds
Ben Gamari [Mon, 8 May 2017 21:47:19 +0000 (17:47 -0400)] 
Treat banged bindings as FunBinds

This reworks the HsSyn representation to make banged variable patterns
(e.g. !x = e) be represented as FunBinds instead of PatBinds, adding a flag to
FunRhs to record the bang.

Fixes #13594.

Reviewers: austin, goldfire, alanz, simonpj

Reviewed By: simonpj

Subscribers: simonpj, rwbarton, thomie, mpickering

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

2 years agoDataflow: use IntSet for mkDepBlocks
Michal Terepeta [Mon, 8 May 2017 21:47:02 +0000 (17:47 -0400)] 
Dataflow: use IntSet for mkDepBlocks

Using `IntSet` instead of `[Int]` is nicer since it gets rid of
appending to a list (in the backward case) and folding over it is
ordered.

I also added a comment about how `mkDepBlocks` works since its
behavior can be a bit surprising at first sight (it took me some time
to see that it's doing the right thing ;)

Signed-off-by: Michal Terepeta <michal.terepeta@gmail.com>
Test Plan: ./validate

Reviewers: austin, bgamari, simonmar

Reviewed By: bgamari

Subscribers: rwbarton, thomie

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

2 years agoAdd a failing test for T13644
Matthew Pickering [Mon, 8 May 2017 21:46:39 +0000 (17:46 -0400)] 
Add a failing test for T13644

The problem originates in TcPat.find_field_ty but I don't know how to
clearnly fix it.

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #13644

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

2 years agoMake XNegativeLiterals treat -0.0 as negative 0
Nolan [Mon, 8 May 2017 21:46:22 +0000 (17:46 -0400)] 
Make XNegativeLiterals treat -0.0 as negative 0

Reviewers: austin, goldfire, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie, mpickering

GHC Trac Issues: #13211

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

2 years agoFix Raspberry Pi
Moritz Angermann [Mon, 8 May 2017 21:45:18 +0000 (17:45 -0400)] 
Fix Raspberry Pi

This is two fold:

- We did not catch all ARM_ARCH_6 defines. Specifically not `6K` and
  `6KZ`, which is what llvm seems to use these days for
  `arm-none-linux-gnueabihf` (e.g. the triple that's used for raspbian
  as well). Without it, ghc assums we want to compile against some armv7
  system, which raspbian is not (it is armv6 for maximum compatibility
  across the pi family, compromising on using armv7 and up features).

- We stop forcing the -m and -arch flags on macOS. This is troublesome,
  as compiling for a 32bit system (e.g. raspberry pi, on a x86_64 macOS
  system results in the `-m64` flag being passed to to clang as well,
  which in turn figures out that you likely want 64bit, and rewrites
  your taret from `arm-none-linux-gnueabihf` to
  `aarch64-none-linux-gnueabihf`, which is definetly not what you want.

Reviewers: austin, hvr, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie, erikd

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

2 years agoOptimize casMutVar# for single-threaded RTS
David Feuer [Mon, 8 May 2017 21:44:37 +0000 (17:44 -0400)] 
Optimize casMutVar# for single-threaded RTS

The single-threaded RTS shouldn't actually need to use CAS to
implement `casMutVar#`; there are no other threads to coordinate
with.

Reviewers: austin, bgamari, erikd, simonmar

Reviewed By: simonmar

Subscribers: rwbarton, thomie

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