ghc.git
2 years agoTypos in comments
Gabor Greif [Fri, 25 Nov 2016 13:09:47 +0000 (14:09 +0100)] 
Typos in comments

2 years agoPerf improvements in T6048, T10547
Simon Peyton Jones [Fri, 25 Nov 2016 08:29:43 +0000 (08:29 +0000)] 
Perf improvements in T6048, T10547

I think this wave of commits just made these two a little better;
they must have been close to the threshold before.

2 years agoRemove redundant kind check
Simon Peyton Jones [Thu, 24 Nov 2016 13:57:04 +0000 (13:57 +0000)] 
Remove redundant kind check

The invariants for CTyEqCan mean that this check isn't needed.
Turn it into an ASSERT.

2 years agoAllow TyVars in TcTypes
Simon Peyton Jones [Wed, 23 Nov 2016 16:00:00 +0000 (16:00 +0000)] 
Allow TyVars in TcTypes

Up to now we've had a rule that a TyVar can't apppear in a type
seen by the type checker; they should all be TcTyVars.  But:

a) With -XTypeInType it becomes much harder to exclude them;
   see Note [TcTyVars in the typechecker] in TcType.

b) It's unnecessary to exculde them; instead we can just treat
   a TyVar just like vanillaSkolemTv.

This is what was causing an ASSERT error in
indexed-types/should_fail/T12041, reported in Trac #12826.

That patch allows a TyVar in a TcType.  The most significant
change is to make Var.tcTyVarDetails return vanillaSkolemTv.
In fact it already did, but (a) it was not documented, and
(b) we never exploited it.  Now we rely on it.

2 years agoAnother major constraint-solver refactoring
Simon Peyton Jones [Tue, 25 Oct 2016 16:41:45 +0000 (17:41 +0100)] 
Another major constraint-solver refactoring

This patch takes further my refactoring of the constraint
solver, which I've been doing over the last couple of months
in consultation with Richard.

It fixes a number of tricky bugs that made the constraint
solver actually go into a loop, including

  Trac #12526
  Trac #12444
  Trac #12538

The main changes are these

* Flatten unification variables (fmvs/fuvs) appear on the LHS
  of a tvar/tyvar equality; thus
           fmv ~ alpha
  and not
           alpha ~ fmv

  See Note [Put flatten unification variables on the left]
  in TcUnify.  This is implemented by TcUnify.swapOverTyVars.

* Don't reduce a "loopy" CFunEqCan where the fsk appears on
  the LHS:
      F t1 .. tn ~ fsk
  where 'fsk' is free in t1..tn.
  See Note [FunEq occurs-check principle] in TcInteract

  This neatly stops some infinite loops that people reported;
  and it allows us to delete some crufty code in reduce_top_fun_eq.
  And it appears to be no loss whatsoever.

  As well as fixing loops, ContextStack2 and T5837 both terminate
  when they didn't before.

* Previously we generated "derived shadow" constraints from
  Wanteds, but we could (and sometimes did; Trac #xxxx) repeatedly
  generate a derived shadow from the same Wanted.

  A big change in this patch is to have two kinds of Wanteds:
     [WD] behaves like a pair of a Wanted and a Derived
     [W]  behaves like a Wanted only
  See CtFlavour and ShadowInfo in TcRnTypes, and the ctev_nosh
  field of a Wanted.

  This turned out to be a lot simpler.  A [WD] gets split into a
  [W] and a [D] in TcSMonad.maybeEmitShaodow.

  See TcSMonad Note [The improvement story and derived shadows]

* Rather than have a separate inert_model in the InertCans, I've
  put the derived equalities back into inert_eqs.  We weren't
  gaining anything from a separate field.

* Previously we had a mode for the constraint solver in which it
  would more aggressively solve Derived constraints; it was used
  for simplifying the context of a 'deriving' clause, or a 'default'
  delcaration, for example.

  But the complexity wasn't worth it; now I just make proper Wanted
  constraints.  See TcMType.cloneWC

* Don't generate injectivity improvement for Givens; see
  Note [No FunEq improvement for Givens] in TcInteract

* solveSimpleWanteds leaves the insolubles in-place rather than
  returning them.  Simpler.

I also did lots of work on comments, including fixing Trac #12821.

2 years agoAdd elemDVarEnv
Simon Peyton Jones [Wed, 23 Nov 2016 09:05:33 +0000 (09:05 +0000)] 
Add elemDVarEnv

I need this in a later patch

2 years agoComments only in TcType
Simon Peyton Jones [Tue, 25 Oct 2016 14:25:03 +0000 (15:25 +0100)] 
Comments only in TcType

2 years agoFix a bug in mk_superclasses_of
Simon Peyton Jones [Tue, 25 Oct 2016 14:22:17 +0000 (15:22 +0100)] 
Fix a bug in mk_superclasses_of

This bug meant that we were less eager about expanding
tuple superclasses than we should have been; i.e. we stopped
too soon.  That's not fatal, beause we expand more superclasses
later, but it's less efficient.

2 years agoMake a panic into an ASSERT
Simon Peyton Jones [Tue, 25 Oct 2016 14:21:31 +0000 (15:21 +0100)] 
Make a panic into an ASSERT

2 years agoMake quoting and reification return the same types
Dominik Bollmann [Thu, 24 Nov 2016 19:14:09 +0000 (06:14 +1100)] 
Make quoting and reification return the same types

Previously TH was incorrectly returning a `Dec` using a `ConT` instead
of `PromotedT`.

Test Plan: validate

Reviewers: mainland, jstolarek, osa1, goldfire, thomie, bollmann,
bgamari, RyanGlScott, austin

Reviewed By: RyanGlScott

Subscribers: erikd

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

GHC Trac Issues: #11629

2 years agoCollect wildcards in sum types during renaming (#12711)
Ömer Sinan Ağacan [Thu, 24 Nov 2016 01:12:17 +0000 (04:12 +0300)] 
Collect wildcards in sum types during renaming (#12711)

This patch also removes the "catch all" pattern in the function and
explicitly lists constructors to get a warning in the future if a new
`HsType` was added.

Reviewers: bgamari, austin, simonpj

Reviewed By: simonpj

Subscribers: simonpj, thomie

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

GHC Trac Issues: #12711

2 years agoAllow to unregister threadWaitReadSTM action.
Alexander Vershilov [Wed, 23 Nov 2016 01:57:08 +0000 (20:57 -0500)] 
Allow to unregister threadWaitReadSTM action.

Allow to unregister threadWaitReadSTM/threadWaitWriteSTM on
a non-threaded runtime. Previosly noop action was returned,
as a result it was not possible to unregister action, unless
data arrives to Fd or it's closed.

Fixes #12852.

Reviewers: simonmar, hvr, austin, bgamari, trofi

Reviewed By: bgamari, trofi

Subscribers: thomie

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

GHC Trac Issues: #12852

2 years agoghc/hschooks.c: Fix include path of Rts.h
Ben Gamari [Tue, 22 Nov 2016 05:43:19 +0000 (00:43 -0500)] 
ghc/hschooks.c: Fix include path of Rts.h

We need to ensure that we don't include Rts.h from bootstrap compiler.
See #12796.

Test Plan: Validate

Reviewers: austin

Subscribers: thomie

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

GHC Trac Issues: #12796

2 years agoMake transformers upstream repository location consistent with others
Demi Obenour [Mon, 21 Nov 2016 22:09:27 +0000 (17:09 -0500)] 
Make transformers upstream repository location consistent with others

Reviewers: bgamari, austin

Reviewed By: bgamari

Subscribers: thomie

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

2 years agoIgnore Hadrian build products.
Edward Z. Yang [Mon, 21 Nov 2016 22:09:02 +0000 (17:09 -0500)] 
Ignore Hadrian build products.

Test Plan: none

Reviewers: austin, snowleopard, bgamari

Reviewed By: bgamari

Subscribers: thomie

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

2 years agoImplement fine-grained `-Werror=...` facility
Maciej Bielecki [Mon, 21 Nov 2016 22:08:45 +0000 (17:08 -0500)] 
Implement fine-grained `-Werror=...` facility

This patch add new options `-Werror=...`, `-Wwarn=...` and
`-Wno-error=...` (synonym for `-Wwarn=...`).

Semantics:

  - `-Werror` marks all warnings as fatal, including those that don't
    have a warning flag, and CPP warnings.
  - `-Werror=...` enables a warning and marks it as fatal
  - `-Wwarn=...` marks a warning as non-fatal, but doesn't disable it

Test Plan: validate

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: mpickering, svenpanne, RyanGlScott, thomie

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

GHC Trac Issues: #11219

2 years agoadd ieee754 next* functions to math_funs
Ben Gamari [Mon, 21 Nov 2016 22:08:38 +0000 (17:08 -0500)] 
add ieee754 next* functions to math_funs

Reviewers: austin, simonmar, trofi, bgamari

Reviewed By: bgamari

Subscribers: mpickering, thomie

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

GHC Trac Issues: #12802

2 years agotestsuite: Add (still failing) testcase for #12550
Ben Gamari [Mon, 21 Nov 2016 18:44:21 +0000 (13:44 -0500)] 
testsuite: Add (still failing) testcase for #12550

I thought that this would naturally resolve itself with the elimination
of the Type pretty-printer but somehow all of the stars in result
position of an arrow are still rendered in non-Unicode syntax. Quite
odd.

Test Plan: Validate

Reviewers: austin

Subscribers: thomie

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

GHC Trac Issues: #12550

2 years agotestsuite: Add (still broken) testcase for #12447
Ben Gamari [Mon, 21 Nov 2016 18:43:48 +0000 (13:43 -0500)] 
testsuite: Add (still broken) testcase for #12447

Test Plan: Validate

Reviewers: austin

Subscribers: thomie

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

GHC Trac Issues: #12447

2 years agotestsuite: Add test for #12024
Ben Gamari [Mon, 21 Nov 2016 18:43:35 +0000 (13:43 -0500)] 
testsuite: Add test for #12024

Test Plan: Validate

Reviewers: austin

Subscribers: thomie

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

GHC Trac Issues: #12024

2 years agotestsuite: Add test for #12855
Ben Gamari [Mon, 21 Nov 2016 18:42:15 +0000 (13:42 -0500)] 
testsuite: Add test for #12855

Test Plan: Validate

Reviewers: austin

Subscribers: thomie

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

GHC Trac Issues: #12855

2 years agoA few typos in comments
Gabor Greif [Mon, 21 Nov 2016 10:11:09 +0000 (11:11 +0100)] 
A few typos in comments

2 years agoUpdated code comment regarding EquationInfo. Trac #12856
Andreas Klebinger [Sun, 20 Nov 2016 00:03:51 +0000 (00:03 +0000)] 
Updated code comment regarding EquationInfo. Trac #12856

Summary: Updated code comment regarding EquationInfo. Fixes T12856

Reviewers: austin, bgamari, mpickering

Reviewed By: mpickering

Subscribers: mpickering, thomie

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

GHC Trac Issues: #12856

2 years agoOptimise whole module exports
Matthew Pickering [Fri, 18 Nov 2016 16:28:30 +0000 (16:28 +0000)] 
Optimise whole module exports

We directly build up the correct AvailInfos rather than generating
lots of singleton instances and combining them with expensive calls to
unionLists.

There are two other small changes.

* Pushed the nubAvails call into the explicit export list
  branch as we construct them correctly and uniquely ourselves.
* fix_faminst only needs to check the first element of the export
  list as we maintain the (yucky) invariant that the parent is the
  first thing in it.

Reviewers: simonpj, austin, bgamari

Reviewed By: simonpj, bgamari

Subscribers: simonpj, thomie, niteria

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

GHC Trac Issues: #12754

2 years agoAdd Data instance for Const
Ryan Scott [Fri, 18 Nov 2016 14:33:01 +0000 (09:33 -0500)] 
Add Data instance for Const

Summary:
Fixes #12438. As discussed on the Haskell libraries mailing list here:
https://mail.haskell.org/pipermail/libraries/2016-November/027396.html

Reviewers: hvr, austin, bgamari

Reviewed By: bgamari

Subscribers: thomie

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

GHC Trac Issues: #12438

2 years agoSpelling in comment only
Gabor Greif [Fri, 18 Nov 2016 09:57:46 +0000 (10:57 +0100)] 
Spelling in comment only

2 years agoAdd missing SMP symbols to RT linker.
Tamar Christina [Fri, 18 Nov 2016 08:50:11 +0000 (08:50 +0000)] 
Add missing SMP symbols to RT linker.

Summary:
Add some missing symbols that we
export from the public headers but forgot to include
in the runtime linker's symbol table.

This is a bit of a unsatifactory patch, since we have a bit of a
cat and mouse game going. We should find a way to automate this.

But I know of no good solutions at the moment that won't add all
rts symbols (including those we don't have an extern declaration for.).

So for now, just add the ones reported missing.

Test Plan: inplace/bin/ghc-stage2.exe --interactive

Reviewers: RyanGlScott, austin, erikd, simonmar, bgamari

Reviewed By: bgamari

Subscribers: thomie, #ghc_windows_task_force

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

GHC Trac Issues: #12846

2 years agoSwitch to LLVM version 3.9
Erik de Castro Lopo [Fri, 18 Nov 2016 08:14:42 +0000 (19:14 +1100)] 
Switch to LLVM version 3.9

Test Plan:
Build and test on x86_64/linux (perf-llvm) and armhf/linux.

Reviewers: austin, hvr, bgamari

Reviewed By: bgamari

Subscribers: RyanGlScott, thomie

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

2 years agoHave reify work for local variables with functional dependencies.
Facundo Domínguez [Thu, 17 Nov 2016 15:04:13 +0000 (10:04 -0500)] 
Have reify work for local variables with functional dependencies.

It turned out that finalizers were run too early and information
resulting from simplifying constraints was not available.

This patch runs finalizers after a first call to simplifyTop, and
then calls simplifyTop a second time to deal with constraints
that could result from running the finalizers.

Fixes T12777

Test Plan: ./validate

Reviewers: goldfire, simonpj, bgamari, austin

Reviewed By: simonpj

Subscribers: mpickering, mboes, thomie

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

GHC Trac Issues: #12777

2 years agoGHCi: Unconditionally import System.Directory
Ben Gamari [Thu, 17 Nov 2016 15:03:25 +0000 (10:03 -0500)] 
GHCi: Unconditionally import System.Directory

Both Windows and POSIX codepaths use System.Directory.canonicalizePath.

2 years agotestsuite: Rip out hack for #12554
Ben Gamari [Thu, 17 Nov 2016 03:17:26 +0000 (22:17 -0500)] 
testsuite: Rip out hack for #12554

@Phyx is working on correctly fixing (pun intended) the underlying issue
that prompted this hack. It turns out that `timeout` it the culprit.
Moreover, this hack breaks on msys python builds, which don't export
`WindowsError`.

Test Plan: Validate on Windows with `msys` python.

Reviewers: Phyx, austin

Subscribers: thomie, Phyx

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

GHC Trac Issues: #12554

2 years agoLLVM generate llvm.expect for conditional branches
Alex Biehl [Wed, 16 Nov 2016 23:16:39 +0000 (18:16 -0500)] 
LLVM generate llvm.expect for conditional branches

This patch adds likeliness annotations to heap and and stack checks and
modifies the llvm codegen to recognize those to help it generate better
code.

So with this patch

```
...
if ((Sp + 8) - 24 < SpLim) (likely: False) goto c23c; else goto c23d;
...
```

roughly generates:

```
  %ln23k = icmp ult i64 %ln23j, %SpLim_Arg
  %ln23m = call ccc i1 (i1, i1) @llvm.expect.i1( i1 %ln23k, i1 0 )
  br i1 %ln23m, label %c23c, label %c23d
```

Note the call to `llvm.expect` which denotes the expected result for
the comparison.

Test Plan: Look at assembler code with and without this patch. If the
heap-checks moved out of the way we are happy.

Reviewers: austin, simonmar, bgamari

Reviewed By: bgamari

Subscribers: michalt, thomie

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

GHC Trac Issues: #8321

2 years agoPass autoconf triplets to sub-project configures
Shea Levy [Wed, 16 Nov 2016 23:15:52 +0000 (18:15 -0500)] 
Pass autoconf triplets to sub-project configures

Reviewers: austin, hvr, bgamari

Reviewed By: bgamari

Subscribers: thomie, erikd

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

GHC Trac Issues: #12840

2 years agoRevert "Add Data instance for Const"
Ryan Scott [Thu, 17 Nov 2016 14:58:19 +0000 (09:58 -0500)] 
Revert "Add Data instance for Const"

This reverts commit 07e40e905357db805e6dbb557b35d6bdf76eaec6.

This was meant for a local branch, but accidentally wound up in master. Oops.

2 years agoAdd Data instance for Const
Ryan Scott [Thu, 17 Nov 2016 14:55:55 +0000 (09:55 -0500)] 
Add Data instance for Const

2 years agoCorrect name of Note in comment
Richard Eisenberg [Thu, 17 Nov 2016 14:08:04 +0000 (09:08 -0500)] 
Correct name of Note in comment

2 years agoCorrect spelling of command-line option in comment
Gabor Greif [Thu, 17 Nov 2016 09:13:46 +0000 (10:13 +0100)] 
Correct spelling of command-line option in comment

2 years agoTest for type synonym loops on TyCon.
Edward Z. Yang [Sat, 29 Oct 2016 00:54:36 +0000 (17:54 -0700)] 
Test for type synonym loops on TyCon.

Summary:
Previously, we tested for type synonym loops by doing
a syntactic test on the literal type synonym declarations.
However, in some cases, loops could go through hs-boot
files, leading to an infinite loop (#12042); a similar
situation can occur when signature merging.

This commit replaces the syntactic test with a test on
TyCon, simply by walking down all type synonyms until
we bottom out, or find we've looped back.  It's a lot
simpler.

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

Reviewers: simonpj, austin, bgamari

Subscribers: goldfire, thomie

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

GHC Trac Issues: #12042

2 years agoFix windows validate
Tamar Christina [Thu, 17 Nov 2016 00:45:17 +0000 (00:45 +0000)] 
Fix windows validate

Summary:
mark myindex as inline only and hide it from profilers.
Also prevent this function from being used any other way
than just for inlining.

Test Plan: ./validate

Reviewers: austin, erikd, simonmar, bgamari

Reviewed By: bgamari

Subscribers: thomie, #ghc_windows_task_force

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

2 years agoInline compiler/NOTES into X86/Ppr.hs
Matthew Pickering [Wed, 16 Nov 2016 15:59:32 +0000 (15:59 +0000)] 
Inline compiler/NOTES into X86/Ppr.hs

Reviewers: austin, bgamari

Subscribers: thomie

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

2 years agoGeneralise the implicit prelude import
Simon Marlow [Wed, 16 Nov 2016 12:47:36 +0000 (12:47 +0000)] 
Generalise the implicit prelude import

Now it's possible to have two lists of imports:
* extra_imports are imports that are always added to the context
* prelude_imports are imports that are added if we don't have
  any open modules in scope.

No UI changes or new commands are added for now.  This was functionality
that we needed in our customized GHCi at Facebook, so I wanted to get it
upstream to reduce the differences between our version and the upstream
version.

2 years agoAvoid calling newDynFlags when there are no changes
Simon Marlow [Tue, 15 Nov 2016 17:19:04 +0000 (17:19 +0000)] 
Avoid calling newDynFlags when there are no changes

This is a small optimisation for :set and :unset

2 years agoFix -fobject-code with -fexternal-interpreter
Simon Marlow [Tue, 15 Nov 2016 16:49:33 +0000 (16:49 +0000)] 
Fix -fobject-code with -fexternal-interpreter

If the user does :cd in GHCi with -fexternal-interpreter, then we can
fail to find the object files.

2 years agoStorage.c: Pass a size to sys_icache_invalidate
Shea Levy [Wed, 16 Nov 2016 03:01:56 +0000 (22:01 -0500)] 
Storage.c: Pass a size to sys_icache_invalidate

The previous code passed an end pointer, but the interface takes a size
instead.

Fixes #12838.

Reviewers: austin, erikd, simonmar, bgamari

Reviewed By: simonmar, bgamari

Subscribers: thomie

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

GHC Trac Issues: #12838

2 years agoDon't use mmap symbols when !RTS_LINKER_USE_MMAP
Shea Levy [Wed, 16 Nov 2016 03:01:20 +0000 (22:01 -0500)] 
Don't use mmap symbols when !RTS_LINKER_USE_MMAP

Some usages of symbols from sys/mman.h are guarded by
RTS_LINKER_USE_MMAP by C conditionals, not CPP conditionals. Since those
branches are dead anyway when !RTS_LINKER_USE_MMAP, we just stub out the
relevant symbols rather than increasing CPP branching.

Fixes #12839.

Reviewers: simonmar, austin, bgamari, erikd

Reviewed By: simonmar, bgamari, erikd

Subscribers: thomie

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

GHC Trac Issues: #12839

2 years agoUpdate xhtml submodule
Erik de Castro Lopo [Wed, 16 Nov 2016 03:00:13 +0000 (22:00 -0500)] 
Update xhtml submodule

Test Plan: validate

Reviewers: hvr, austin, Phyx, bgamari

Reviewed By: bgamari

Subscribers: thomie

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

2 years agoTest for unnecessary register spills
Thomas Jakway [Wed, 16 Nov 2016 02:59:28 +0000 (21:59 -0500)] 
Test for unnecessary register spills

Reviewers: mainland, simonmar, michalt, bgamari, austin

Reviewed By: bgamari

Subscribers: simonpj, mpickering, thomie

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

GHC Trac Issues: #12744, #12745

2 years agofixup! Stop the simplifier from removing StaticPtr binds.
Facundo Domínguez [Wed, 16 Nov 2016 00:39:40 +0000 (21:39 -0300)] 
fixup! Stop the simplifier from removing StaticPtr binds.

2 years agoTypos in comments, notes and manual
Gabor Greif [Mon, 14 Nov 2016 16:57:09 +0000 (17:57 +0100)] 
Typos in comments, notes and manual

2 years agoMark T12041 as expect_broken with -DDEBUG (#12826)
Simon Marlow [Tue, 15 Nov 2016 10:40:24 +0000 (10:40 +0000)] 
Mark T12041 as expect_broken with -DDEBUG (#12826)

2 years agoHopefully fix build on OS X
Simon Marlow [Mon, 14 Nov 2016 15:36:38 +0000 (15:36 +0000)] 
Hopefully fix build on OS X

Summary:
It looks like I broke the OS X build with 55d535da10dd, hopefully this
should fix it.

Test Plan: Harbourmaster

Reviewers: austin, bgamari, erikd

Subscribers: thomie

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

GHC Trac Issues: #12455

2 years agoSkip 64-bit symbol tables
Sylvain HENRY [Mon, 14 Nov 2016 22:16:27 +0000 (17:16 -0500)] 
Skip 64-bit symbol tables

This patch makes the RTS linker skip 64-bit symbol table entries.  See
https://mail.haskell.org/pipermail/ghc-devs/2016-November/013210.html

Test Plan: validate

Reviewers: austin, erikd, simonmar, bgamari

Reviewed By: bgamari

Subscribers: osa1, thomie

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

GHC Trac Issues: #12827

2 years agoconfigure: Verify that GCC recognizes -no-pie flag
Ben Gamari [Mon, 14 Nov 2016 19:13:30 +0000 (14:13 -0500)] 
configure: Verify that GCC recognizes -no-pie flag

It seems like GCC versions prior to 4.8 exit with code 0 when faced with
an unrecognized flag. Silly compilers.

Test Plan: Validate

Reviewers: hvr, austin, ggreif

Reviewed By: ggreif

Subscribers: thomie, erikd

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

GHC Trac Issues: #12759

2 years agotestsuite: Fix creep of T4029
Ben Gamari [Mon, 14 Nov 2016 14:20:14 +0000 (09:20 -0500)] 
testsuite: Fix creep of T4029

Ostensibly due to IfaceType rework, but I have my doubts.

2 years agoFix numa001 failure with "too many NUMA nodes"
Simon Marlow [Wed, 9 Nov 2016 11:02:12 +0000 (11:02 +0000)] 
Fix numa001 failure with "too many NUMA nodes"

It seems that recent versions of the Linux kernel are using larger NUMA
bitmasks; I see 1024 on my laptop running a 4.6.5 kernel.  This causes
the NUMA tests to fail.  I'm fixing it to only fail if we have that many
actual *nodes*, rather than failing if the size of the mask is too big.

2 years agoAccept output for scc003
Simon Marlow [Wed, 9 Nov 2016 10:58:57 +0000 (10:58 +0000)] 
Accept output for scc003

Looks like e3f341f334d89c88f388d8e864ed8762d0890a64 broke it, but we
wouldn't have noticed because the test isn't run in validate.

I think the change is OK.  We don't get a tick for x' any more, because
it is converted directly to a case instead of a let-binding, but we
still get a tick for the "pattern binding" (!x').  This could be better
- f.(...) isn't all that intuitive - but it's not strictly wrong.

2 years agoRemove CONSTR_STATIC
Simon Marlow [Wed, 9 Nov 2016 09:20:02 +0000 (09:20 +0000)] 
Remove CONSTR_STATIC

Summary:
We currently have two info tables for a constructor

* XXX_con_info: the info table for a heap-resident instance of the
  constructor, It has type CONSTR, or one of the specialised types like
  CONSTR_1_0

* XXX_static_info: the info table for a static instance of this
  constructor, which has type CONSTR_STATIC or CONSTR_STATIC_NOCAF.

I'm getting rid of the latter, and using the `con_info` info table for
both static and dynamic constructors.  For rationale and more details
see Note [static constructors] in SMRep.hs.

I also removed these macros: `isSTATIC()`, `ip_STATIC()`,
`closure_STATIC()`, since they relied on the CONSTR/CONSTR_STATIC
distinction, and anyway HEAP_ALLOCED() does the same job.

Test Plan: validate

Reviewers: bgamari, simonpj, austin, gcampax, hvr, niteria, erikd

Subscribers: thomie

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

GHC Trac Issues: #12455

2 years agoKill Type pretty-printer
Ben Gamari [Sun, 13 Nov 2016 21:17:37 +0000 (16:17 -0500)] 
Kill Type pretty-printer

Here we consolidate the pretty-printing logic for types in IfaceType. We
need IfaceType regardless and the printer for Type can be implemented in
terms of that for IfaceType. See #11660.

Note that this is very much a work-in-progress. Namely I still have yet
to ponder how to ease the hs-boot file situation, still need to rip out
more dead code, need to move some of the special cases for, e.g., `*` to
the IfaceType printer, and need to get it to validate. That being said,
it comes close to validating as-is.

Test Plan: Validate

Reviewers: goldfire, austin

Subscribers: goldfire, thomie, simonpj

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

GHC Trac Issues: #11660

2 years agorts: Fix references to UChar
Ben Gamari [Sun, 13 Nov 2016 21:07:59 +0000 (16:07 -0500)] 
rts: Fix references to UChar

Test Plan: Validate on Windows.

Reviewers: erikd, austin, simonmar

Reviewed By: erikd

Subscribers: Phyx, thomie

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

2 years agoghc: Fix ghc's template-haskell bound
Ben Gamari [Sat, 12 Nov 2016 16:54:45 +0000 (11:54 -0500)] 
ghc: Fix ghc's template-haskell bound

2 years agotemplate-haskell: Version bump
Ben Gamari [Sat, 12 Nov 2016 16:37:36 +0000 (11:37 -0500)] 
template-haskell: Version bump

2 years agoMake default output less verbose (source/object paths)
Sylvain HENRY [Sat, 12 Nov 2016 03:54:05 +0000 (22:54 -0500)] 
Make default output less verbose (source/object paths)

Reviewers: simonmar, mpickering, austin, bgamari

Reviewed By: bgamari

Subscribers: mpickering, nomeata, thomie

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

GHC Trac Issues: #12807

2 years agorts: Fix #include of <linker/PEi386.h>
Ben Gamari [Sat, 12 Nov 2016 03:04:45 +0000 (22:04 -0500)] 
rts: Fix #include of <linker/PEi386.h>

Test Plan: Validate on Windows

Reviewers: austin, erikd, simonmar

Subscribers: thomie

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

2 years agorts: Fix build when linked with gold
Ben Gamari [Sat, 12 Nov 2016 03:04:32 +0000 (22:04 -0500)] 
rts: Fix build when linked with gold

As reported in #12812, the runtime system fails to build when linked
with gold due to a missing dependency on libpthread.

Additionally, rts/package.conf.in uses the WORD_SIZE_IN_BITS macro
defined by MachDeps.h, which it does not #include. Fix this.

Test Plan: Validate with gold linker

Reviewers: hsyl20, austin, erikd, simonmar

Subscribers: thomie

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

GHC Trac Issues: #12816

2 years agoghc-pkg: Munge dynamic library directories
Ben Gamari [Fri, 11 Nov 2016 20:53:36 +0000 (15:53 -0500)] 
ghc-pkg: Munge dynamic library directories

Otherwise we end up looking in the wrong place for dynamic libraries on
Windows. This addresses a regression introduced by D2611. See #12479.

Test Plan: validate across platforms

Reviewers: austin

Subscribers: thomie

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

GHC Trac Issues: #12479

2 years agotestsuite: Lower allocations for T876
Ben Gamari [Sat, 12 Nov 2016 01:26:13 +0000 (20:26 -0500)] 
testsuite: Lower allocations for T876

If only we knew why...

[skip-ci]

2 years agoPass -no-pie to GCC
Ben Gamari [Fri, 11 Nov 2016 17:05:21 +0000 (12:05 -0500)] 
Pass -no-pie to GCC

Certain distributions (e.g. Debian and Ubuntu) have enabled PIE be
default in their GCC packaging. This breaks our abuse of GCC as a linker
which requires that we pass -Wl,-r, which is incompatible with
PIE (since the former implies that we are generating a relocatable
object file and the latter an executable).

This is a second attempt at D2691. This attempt constrasts with D2691 in that
it preserves the "does gcc support -no-pie" flag in settings, allowing this to
be reconfigured by `configure` during installation of a binary distribution.
Thanks for @rwbarton for drawing attention to this issue.

Test Plan: Validate

Reviewers: austin, hvr, erikd

Reviewed By: erikd

Subscribers: thomie, rwbarton, erikd

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

GHC Trac Issues: #12759

2 years agorts: Fix LoadArchive on OS X
Ben Gamari [Fri, 11 Nov 2016 15:58:08 +0000 (10:58 -0500)] 
rts: Fix LoadArchive on OS X

2 years agoRevert "Refactor CallStack defaulting slightly"
Simon Peyton Jones [Fri, 11 Nov 2016 15:31:56 +0000 (15:31 +0000)] 
Revert "Refactor CallStack defaulting slightly"

This reverts commit 317236db308d9bd497a11fa4c455428fc7477405.

I totally missed that in simplifyInfer for local functions
we must NOT default call stacks.  So I'm reverting this.

Fortunately caught by T10845, which sadly isn't run by
validate --fast

2 years agoRevert "Pass -no-pie to GCC"
Ben Gamari [Fri, 11 Nov 2016 04:48:27 +0000 (23:48 -0500)] 
Revert "Pass -no-pie to GCC"

This reverts commit bae4a55b1fb403f610b4b55a1b6fb3f03e9c2026.

This will be superceded by D2693.

2 years agoPrevent GND from inferring an instance context for method-less classes
Ryan Scott [Thu, 10 Nov 2016 20:22:48 +0000 (15:22 -0500)] 
Prevent GND from inferring an instance context for method-less classes

When `GeneralizedNewtypeDeriving` is used with a type class that has no
methods, it will generate a redundant context, and as a result, it can
trigger warnings when compiled with `-Wredundant-constraints`. This is a
simple change in behavior to check beforehand if a class has methods
when deriving it with GND, and if it has no methods, avoid inferring the
redundant context.

Beware that the test for #6088, which used to be expected to fail, now
compiles without issue since it doesn't infer a problematic instance
context.

Thanks to Simon Peyton Jones for doing the necessary refactoring in
f05d685ae05ec293083f2fa7ec7ba057fbe64869.

Fixes #12814.

Test Plan: ./validate

Reviewers: goldfire, rwbarton, simonpj, austin, bgamari

Reviewed By: simonpj

Subscribers: thomie

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

GHC Trac Issues: #12814

2 years agoUpdate user's guide after D2490
Thomas Winant [Thu, 10 Nov 2016 20:22:14 +0000 (15:22 -0500)] 
Update user's guide after D2490

D2490 added support for type wildcards in TH pattern splices. The user's
guide still said that they were not supported, this patch fixes this.

Test Plan: build documentation

Reviewers: goldfire, austin, mvv, bgamari

Reviewed By: bgamari

Subscribers: thomie

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

GHC Trac Issues: #12164

2 years agorts/linker: Move loadArchive to new source file
Ben Gamari [Thu, 10 Nov 2016 20:21:38 +0000 (15:21 -0500)] 
rts/linker: Move loadArchive to new source file

Test Plan: Validate

Reviewers: DemiMarie, austin, simonmar, erikd

Reviewed By: DemiMarie

Subscribers: Phyx, thomie, hvr

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

GHC Trac Issues: #12388

2 years agorts: Add api to pin a thread to a numa node but without fixing a capability
Darshan Kapashi [Thu, 10 Nov 2016 20:21:08 +0000 (15:21 -0500)] 
rts: Add api to pin a thread to a numa node but without fixing a capability

`rts_setInCallCapability` sets the thread affinity as well as pins the
numa node. We should also have the ability to set the numa node without
setting the capability affinity. `rts_pinNumaNodeForCapability` function
is added and exported via `RtsAPI.h`.

Previous callers of `rts_setInCallCapability` should now also call
`rts_pinNumaNodeForCapability` to get the same effect as before.

Test Plan:
  ./validate

Reviewers: austin, simonmar, bgamari

Reviewed By: simonmar, bgamari

Subscribers: thomie, niteria

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

GHC Trac Issues: #12764

2 years agoRead parentheses better
David Feuer [Thu, 10 Nov 2016 20:20:15 +0000 (15:20 -0500)] 
Read parentheses better

Instead of pulling a token and looking for `'('` or `')'`,
just look for the character itself. This prevents us from
lexing every single item twice, once to see if it's a
left parenthesis and once to actually parse it.

Partially fixes #12665

Make parens faster more aggressively

* Strip spaces before parsing, so we never have to strip
the same spaces twice.

* String parsers together manually, to try to avoid unnecessary closure
creation.

Test Plan: Validate

Reviewers: austin, hvr, bgamari

Reviewed By: bgamari

Subscribers: thomie

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

GHC Trac Issues: #12665

2 years agoAdd Richard Eisenberg's new email to mailmap
Ben Gamari [Thu, 10 Nov 2016 20:19:10 +0000 (15:19 -0500)] 
Add Richard Eisenberg's new email to mailmap

Reviewers: austin, mpickering

Reviewed By: mpickering

Subscribers: thomie

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

2 years agotestsuite: Update allocation numbers for T5631
Ben Gamari [Thu, 10 Nov 2016 20:25:08 +0000 (15:25 -0500)] 
testsuite: Update allocation numbers for T5631

2 years agoPass -no-pie to GCC
Ben Gamari [Thu, 10 Nov 2016 18:18:09 +0000 (13:18 -0500)] 
Pass -no-pie to GCC

Certain distributions (e.g. Debian and Ubuntu) have enabled PIE be
default in their GCC packaging. This breaks our abuse of GCC as a linker
which requires that we pass -Wl,-r, which is incompatible with
PIE (since the former implies that we are generating a relocatable
object file and the latter an executable).

Test Plan: Validate

Reviewers: hvr, austin

Subscribers: rwbarton, thomie, erikd

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

GHC Trac Issues: #12759

2 years agoconfigure: Pass HC_OPTS_STAGEx to build system
Ben Gamari [Fri, 4 Nov 2016 19:03:55 +0000 (15:03 -0400)] 
configure: Pass HC_OPTS_STAGEx to build system

Test Plan: Try `./configure HC_OPTS_STAGE0=-foobar` and watch it fail

Reviewers: austin, hvr

Subscribers: thomie, erikd

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

2 years agobuild system: Include CONF_LD_LINKER_OPTS in ALL_LD_OPTS
Ben Gamari [Fri, 4 Nov 2016 19:03:44 +0000 (15:03 -0400)] 
build system: Include CONF_LD_LINKER_OPTS in ALL_LD_OPTS

This ensures that artifacts built with build-prog see these options.
Also spruce up comments.

Test Plan: Carefully read it.

Reviewers: austin, hvr, erikd

Reviewed By: erikd

Subscribers: thomie, erikd

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

2 years agoghc-cabal: Use correct name of linker flags env variable
Ben Gamari [Fri, 4 Nov 2016 19:03:33 +0000 (15:03 -0400)] 
ghc-cabal: Use correct name of linker flags env variable

Currently passing the `CONF_LD_LINKER_OPTS_STAGE0` environment
variable to `configure` is broken due to this naming inconsistency.

Test Plan: Try passing `CONF_LD_LINKER_OPTS_STAGE0` to `configure`.
Look at resulting stage0 ghc invocation.

Reviewers: austin

Subscribers: thomie

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

2 years agoRefactor CallStack defaulting slightly
Simon Peyton Jones [Thu, 10 Nov 2016 16:02:42 +0000 (16:02 +0000)] 
Refactor CallStack defaulting slightly

This moves call-stack defaulting from simpl_top to solveWanteds,
for reasons described in Note [CallStack defaulting].

No change in visible behaviour.

2 years agoRefactoring of mkNewTypeEqn
Simon Peyton Jones [Thu, 10 Nov 2016 15:52:31 +0000 (15:52 +0000)] 
Refactoring of mkNewTypeEqn

The refactoring here is very small.  I did it while studying
Trac #12814.

To implement the change in #12814, we can just un-comment the
lines at line 1275.  It's ready to go but I didn't want to pull
the trigger in this commit

2 years agoAdapt the (commented out) pprTrace in OccurAnal
Simon Peyton Jones [Thu, 10 Nov 2016 15:50:57 +0000 (15:50 +0000)] 
Adapt the (commented out) pprTrace in OccurAnal

I did this while investigating Trac #12776

2 years agoFix comment about pointer tagging
Alex Biehl [Thu, 10 Nov 2016 12:12:30 +0000 (13:12 +0100)] 
Fix comment about pointer tagging

`Lcall` enters the closure. If it has tags we jump directly to `Lret`.

Confirmed with some generated cmm code:

```
           R1 = _s2pP::P64;
           Sp = Sp - 8;
           if (R1 & 7 != 0) goto c2x0; else goto c2x1;
       c2x1:
           call (I64[R1])(R1) returns to c2x0, args: 8, res: 8, upd: 8;
       c2x0:
           _s2pQ::P64 = R1;
```

2 years agoUpdate 8.0.2 release notes for #12784
Ryan Scott [Mon, 7 Nov 2016 13:56:22 +0000 (08:56 -0500)] 
Update 8.0.2 release notes for #12784

Summary:
The fix for #12220 exposed some ill-typed programs which passed the typechecker
in GHC 8.0.1 but now fail to typecheck in GHC 8.0.2. It's a bit difficult to
characterize what exactly triggers this bug, but we at least have a minimal
example and a simple fix to illustrate the problem and solution, so let's
add that the the 8.0.2 release notes to advertise this change.

Resolves #12784.

Reviewers: rwbarton, austin, bgamari

Reviewed By: bgamari

Subscribers: thomie

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

GHC Trac Issues: #12784

2 years agoFix hs_try_putmvar003 (#12800)
Simon Marlow [Fri, 4 Nov 2016 21:10:39 +0000 (14:10 -0700)] 
Fix hs_try_putmvar003 (#12800)

Summary:
There was a race condition on some shared data when creating the
callback thread.

I couldn't repro the issue without inserting a dummy usleep(100), but
it's definitely a bug.

Test Plan: validate

Reviewers: bgamari, austin, erikd

Subscribers: thomie

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

GHC Trac Issues: #12800

2 years agoFix broken validate build.
Tamar Christina [Sun, 6 Nov 2016 22:04:40 +0000 (22:04 +0000)] 
Fix broken validate build.

2 years agoSome minor linker cleanups.
Tamar Christina [Sun, 6 Nov 2016 19:08:40 +0000 (19:08 +0000)] 
Some minor linker cleanups.

Summary:
Just some cleanups to some oddities I've noticed
while investigating a linker issue.

Particularly the dll name returned by `findSysDll`
was decorated. So foo.dll is returned. We make it
`foo.dll.dll` and later drop one `.dll` when passed to
`addDll` which expects it without extension, but still
tries the name *as is* which is why it worked.

This should be slightly faster, since we don't try 4 loads
before we succeed.

Test Plan: ./validate

Reviewers: austin, hvr, erikd, simonmar, bgamari

Reviewed By: bgamari

Subscribers: thomie, #ghc_windows_task_force

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

2 years agoDescribe symptoms of (and the cure for) #12768 in 8.0.2 release notes
Ryan Scott [Sun, 6 Nov 2016 14:40:48 +0000 (09:40 -0500)] 
Describe symptoms of (and the cure for) #12768 in 8.0.2 release notes

GHC 8.0.2 introduced a bugfix involving GeneralizedNewtypeDeriving in
96d451450923a80b043b5314c5eaaa9d0eab7c56. This made typechecking of
GND-produced code a bit stricter, and an unfortunate side effect of this was
that there were a couple of corner-case programs that stopped compiling
when transitioning from GHC 8.0.1 to 8.0.2.

Since the number of affected programs seems quite small, and since the fix
is so straightforward, we opt to simply note this discrepancy in the 8.0.2
release notes.

Resolves #12768.

2 years agoAllow GeneralizedNewtypeDeriving for classes with associated type families
Ryan Scott [Sun, 6 Nov 2016 14:09:36 +0000 (09:09 -0500)] 
Allow GeneralizedNewtypeDeriving for classes with associated type families

Summary:
This implements the ability to derive associated type family instances
for newtypes automatically using `GeneralizedNewtypeDeriving`. Refer to the
users' guide additions for how this works; I essentially follow the pattern
laid out in https://ghc.haskell.org/trac/ghc/ticket/8165#comment:18.

Fixes #2721 and #8165.

Test Plan: ./validate

Reviewers: simonpj, goldfire, austin, bgamari

Reviewed By: simonpj

Subscribers: mpickering, thomie

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

GHC Trac Issues: #2721, #8165

2 years agoAdd tracing infrastructure to pattern match checker
Matthew Pickering [Sun, 6 Nov 2016 12:47:48 +0000 (12:47 +0000)] 
Add tracing infrastructure to pattern match checker

Summary:
This is the start of some tracing infrastructure which I found useful
when working through how the pattern match checker worked.

It adds the flag -ddump-ec-trace in order to turn on the trace.

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: thomie

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

2 years agoStop -dno-debug-output suppressing -ddump-tc-trace
Matthew Pickering [Sun, 6 Nov 2016 12:46:40 +0000 (12:46 +0000)] 
Stop -dno-debug-output suppressing -ddump-tc-trace

Summary:
The user manual states that -dno-debug-output should suppress
*unsolicited* debugging output which essentially amounts to calls
to `pprTrace`. Before I unified the interface of `traceTc` and
`traceRn`, the flag suppressed calls to `traceTc` but not to `traceRn`
or any other tracing function already controlled by a flag.

Thus, in order to make the behaviour more uniform, it seemed best to
remove this one special case.

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: thomie

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

GHC Trac Issues: #12691

2 years agoUpdate release notes for type sigs in TH patterns patch
Matthew Pickering [Sat, 5 Nov 2016 22:15:14 +0000 (22:15 +0000)] 
Update release notes for type sigs in TH patterns patch

[skip ci]

2 years agoHandle types w/ type variables in signatures inside patterns (DsMeta)
Mikhail Vorozhtsov [Sat, 5 Nov 2016 22:06:39 +0000 (22:06 +0000)] 
Handle types w/ type variables in signatures inside patterns (DsMeta)

The comment indicated that scoping of type variables was a large problem
but Simon fixed it in e21e13fb52b99b14770cc5857df57bbcc9c85102.

Thus, we can implement repP for signatures very easily in the usual way
now.

Reviewers: goldfire, simonpj, austin, bgamari

Reviewed By: simonpj

Subscribers: mpickering, simonpj, thomie

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

GHC Trac Issues: #12164

2 years agoTake account of injectivity when doing fundeps
Simon Peyton Jones [Fri, 4 Nov 2016 10:43:36 +0000 (10:43 +0000)] 
Take account of injectivity when doing fundeps

This fixes Trac #12803. Yikes!

See Note [Care with type functions].

2 years agoRemove a debug trace
Simon Peyton Jones [Thu, 3 Nov 2016 14:54:45 +0000 (14:54 +0000)] 
Remove a debug trace

I added this when debugging something else, but in general it doesn't
work (with -ddump-tc-trace) because of typecking recursive groups of
TyCons.  So removing it again.

2 years agoAdd comments from Trac #12768
Simon Peyton Jones [Thu, 3 Nov 2016 14:54:01 +0000 (14:54 +0000)] 
Add comments from Trac #12768

2 years agoOmit unnecessary linker flags
Simon Marlow [Thu, 27 Oct 2016 11:52:00 +0000 (12:52 +0100)] 
Omit unnecessary linker flags

Summary:
This omits -L and -l flags from the linker command line that shouldn't
be necessary because GHC will already add them via the -package-id
flags we pass.

This also reverts part of 90538d86af579595987826cd893828d6f379f35a
that rearranges the linker command line and causes some knock-on
problems (see D2618).

Test Plan: validate (need to validate on Windows too)

Reviewers: Phyx, bgamari, niteria, austin, erikd

Subscribers: thomie

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

GHC Trac Issues: #12738

2 years agoAPI Annotations: make all ModuleName Located
Alan Zimmerman [Thu, 3 Nov 2016 12:40:12 +0000 (14:40 +0200)] 
API Annotations: make all ModuleName Located

Summary:
This also changes the backpack Renaming type to use a Maybe for the
renameTo field, to more accurately reflect the parsed source.

Updates haddock submodule to match AST changes

Test Plan: ./validate

Reviewers: ezyang, bgamari, austin

Reviewed By: bgamari

Subscribers: thomie, mpickering

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