ghc.git
2 years agoWork on #12144 wip/T12144
Ryan Scott [Sat, 27 Aug 2016 18:00:56 +0000 (14:00 -0400)] 
Work on #12144

2 years agoImplement deriving strategies
Ryan Scott [Sat, 27 Aug 2016 18:00:04 +0000 (14:00 -0400)] 
Implement deriving strategies

Summary:
Allows users to explicitly request which approach to `deriving` to use via
keywords, e.g.,

```
newtype Foo = Foo Bar
  deriving Eq
  deriving builtin Ord
  deriving newtype Show
```

Fixes #10598.

Test Plan: ./validate

Reviewers: hvr, kosmikus, goldfire, bgamari, simonpj, alanz, austin, erikd, simonmar

Reviewed By: simonpj, alanz

Subscribers: thomie, mpickering, oerjan

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

GHC Trac Issues: #10598

2 years agoWwLib: Add strictness signature to "let x = absentError …"
Joachim Breitner [Tue, 26 Jul 2016 10:08:59 +0000 (12:08 +0200)] 
WwLib: Add strictness signature to "let x = absentError …"

indicating that it is bottom. This should help making the "empty cases"
lint error give less false alarms.

2 years agoDegrade "case scrutinee not known to diverge for sure" Lint error to warning
Joachim Breitner [Tue, 26 Jul 2016 09:44:53 +0000 (11:44 +0200)] 
Degrade "case scrutinee not known to diverge for sure" Lint error to warning

as proposed in #12435, as it easily gets in the way of development when
it reports false positives.

2 years agoDmdAnal: Testcase about splitFVs and dmdFix abortion
Joachim Breitner [Thu, 21 Jul 2016 15:44:25 +0000 (17:44 +0200)] 
DmdAnal: Testcase about splitFVs and dmdFix abortion

Any variable with useful information (strict or used-once) will not be
included in lazy_fv (according to splitFVs). If we now also remove them
from the strictness signatures, their uses are not recorded anywhere –
and then probably considered absent.

2 years agoDmdAnal: Add a final, safe iteration
Joachim Breitner [Thu, 7 Jul 2016 09:23:48 +0000 (11:23 +0200)] 
DmdAnal: Add a final, safe iteration

this fixes #12368.

It also refactors dmdFix a bit, removes some redundancies (such as
passing around an strictness signature right next to an id, when that id
is guaranteed to have been annotated with that strictness signature).

Note that when fixed-point iteration does not terminate, we
conservatively delete their strictness signatures (set them to nopSig).
But this loses the information on how its strict free variables are
used!

Lazily used variables already escape via lazy_fvs. We ensure that in the
case of an aborted fixed-point iteration, also the strict variables are
put there (with a conservative demand of topDmd).

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

2 years agoComments only: Refer to actually existing Notes
Joachim Breitner [Mon, 1 Aug 2016 00:59:54 +0000 (20:59 -0400)] 
Comments only: Refer to actually existing Notes

2 years agoTemplate Haskell support for unboxed sums
Ryan Scott [Tue, 23 Aug 2016 18:20:36 +0000 (14:20 -0400)] 
Template Haskell support for unboxed sums

This adds new constructors `UnboxedSumE`, `UnboxedSumT`, and
`UnboxedSumP` to represent unboxed sums in Template Haskell.

One thing you can't currently do is, e.g., `reify ''(#||#)`, since I
don't believe unboxed sum type/data constructors can be written in
prefix form.  I will look at fixing that as part of #12514.

Fixes #12478.

Test Plan: make test TEST=T12478_{1,2,3}

Reviewers: osa1, goldfire, austin, bgamari

Reviewed By: goldfire, bgamari

Subscribers: thomie

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

GHC Trac Issues: #12478

2 years agoRtClosureInspect: Fix off-by-one error in cvReconstructType
mniip [Tue, 23 Aug 2016 17:19:02 +0000 (13:19 -0400)] 
RtClosureInspect: Fix off-by-one error in cvReconstructType

Replaced error-prone index manipulation on a pointer array with
a simple fold on the array elements.

Test Plan: Added a test case that triggers the bug

Reviewers: hvr, austin, bgamari

Reviewed By: bgamari

Subscribers: simonpj, thomie

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

GHC Trac Issues: #12458

2 years agoAdd T12520 as a test
Ömer Sinan Ağacan [Tue, 23 Aug 2016 06:53:11 +0000 (06:53 +0000)] 
Add T12520 as a test

  #12520 was already fixed in HEAD. Adding a test to make sure it stays fixed.

2 years agoMove #12403, #12513 users guide notes to 8.2.1 release notes
Ryan Scott [Mon, 22 Aug 2016 23:01:01 +0000 (19:01 -0400)] 
Move #12403, #12513 users guide notes to 8.2.1 release notes

The changes in #12403 and #12513 subtly changed the behavior of Template
Haskell reification and splicing. While the old behavior was certainly buggy,
it's possible that there's code in the wild that depended on the old behavior
to work. To err on the side of caution, I'll postpone these changes to GHC
8.2.1 instead of having them merged into GHC 8.0.2.

2 years agoExtra comments, as per SPJ in #12035.
Edward Z. Yang [Mon, 22 Aug 2016 20:34:43 +0000 (13:34 -0700)] 
Extra comments, as per SPJ in #12035.

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
2 years agoSplice singleton unboxed tuples correctly with Template Haskell
Ryan Scott [Mon, 22 Aug 2016 14:39:12 +0000 (10:39 -0400)] 
Splice singleton unboxed tuples correctly with Template Haskell

Summary:
Previously, TH would implicitly remove the parentheses when splicing in
singleton unboxed tuple types (e.g., turning `(# Int #)` into `Int`). Luckily,
the fix is simply to delete some code.

Fixes #12513.

Test Plan: make test TEST=T12513

Reviewers: hvr, bgamari, austin, goldfire

Reviewed By: goldfire

Subscribers: thomie

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

GHC Trac Issues: #12513

2 years agopass -z wxneeded or -Wl,-zwxneeded for linking on OpenBSD
Karel Gardas [Sat, 13 Aug 2016 16:49:53 +0000 (18:49 +0200)] 
pass -z wxneeded or -Wl,-zwxneeded for linking on OpenBSD

Summary:
This patch fixes issue with abort in GHCi on OpenBSD current
as of Aug 12 2016. The OpenBSD is more and more strict about usage
of writable and executable memory. Programs/applications which
requires such functionality need to be linked with -z wxneeded linker
flag and need to be run from the file-system mounted with wxallowed
mount option. If either of those options in not met, then problematic
program/application usually fail on some mmap/mprotect call which fail.

Reviewers: bgamari, austin, hvr

Subscribers: thomie, erikd

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

2 years agoFix #12472 by looking for noinline/lazy inside oversaturated applications.
Edward Z. Yang [Sat, 6 Aug 2016 20:47:05 +0000 (13:47 -0700)] 
Fix #12472 by looking for noinline/lazy inside oversaturated applications.

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

Reviewers: simonpj, austin, bgamari

Subscribers: thomie

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

GHC Trac Issues: #12472

2 years agoWe also need to retypecheck before when we do parallel make.
Edward Z. Yang [Sat, 14 May 2016 02:32:37 +0000 (19:32 -0700)] 
We also need to retypecheck before when we do parallel make.

Summary:
Kept this seperate from the previous patch for clarity.
Comes with a test.

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

Reviewers: simonpj, austin, bgamari

Subscribers: thomie

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

GHC Trac Issues: #12035

2 years agoRetypecheck both before and after finishing hs-boot loops in --make.
Edward Z. Yang [Fri, 13 May 2016 07:10:47 +0000 (00:10 -0700)] 
Retypecheck both before and after finishing hs-boot loops in --make.

Summary:
This makes ghc --make's retypecheck behavior more in line
with ghc -c, which is able to tie the knot as we are typechecking.

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

Reviewers: simonpj, austin, bgamari

Subscribers: thomie

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

GHC Trac Issues: #12035

2 years agoWhen a value Id comes from hi-boot, insert noinline. Fixes #10083.
Edward Z. Yang [Fri, 13 May 2016 03:33:43 +0000 (20:33 -0700)] 
When a value Id comes from hi-boot, insert noinline. Fixes #10083.

Summary:
This also drops the parked fix from
efa7b3a474bc373201ab145c129262a73c86f959
(though I didn't revert the refactoring).

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

Reviewers: simonpj, austin, bgamari

Subscribers: thomie

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

GHC Trac Issues: #10083

2 years agoIntroduce BootUnfolding, set when unfolding is absent due to hs-boot file.
Edward Z. Yang [Thu, 12 May 2016 19:47:16 +0000 (12:47 -0700)] 
Introduce BootUnfolding, set when unfolding is absent due to hs-boot file.

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

Reviewers: simonpj, austin, bgamari

Subscribers: thomie

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

2 years agoSupport for noinline magic function.
Edward Z. Yang [Fri, 13 May 2016 02:38:57 +0000 (19:38 -0700)] 
Support for noinline magic function.

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

Reviewers: simonpj, austin, bgamari

Subscribers: thomie

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

2 years agoAxe initIfaceTc, tie the knot through HPT (or if_rec_types).
Edward Z. Yang [Sun, 19 Jun 2016 21:28:55 +0000 (14:28 -0700)] 
Axe initIfaceTc, tie the knot through HPT (or if_rec_types).

Summary:
initIfaceTc was originally used to make sure when we typecheck
an interface, it can find the TyThings for things it itself
defined.  However, in the case of retypecheckLoop, this wasn't
necessary because we ALREADY tied the knot through the HPT.

This commit removes initIfaceTc, instead relying on the HPT
to tie the knot.  genModDetails' caller needed to be modified
to tie the knot, but there are not that many call-sites of
typecheckIface so the change is quite reasonable.

We also introduce a new 'initIfaceLoad', which does
NOT set up 'if_rec_types'.  It's used when we're
typechecking old, up-to-date interfaces in, since we're
never going to update the type environment.

The full details are in Note [Knot-tying typecheckIface].
Displeasingly, we need a special case to handle DFuns in
the case of tcHiBootIface, see
Note [DFun knot-tying special case] for the gory details.

I also added another test which tickles a bug in a buggy
version of this patch (see "Why the seq?")

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

Reviewers: simonpj, austin, bgamari

Subscribers: thomie

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

2 years agoAnnotate initIfaceCheck with usage information.
Edward Z. Yang [Mon, 20 Jun 2016 05:31:06 +0000 (22:31 -0700)] 
Annotate initIfaceCheck with usage information.

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
2 years agoRevert "codeGen: Remove binutils<2.17 hack, fixes T11758"
Simon Peyton Jones [Thu, 18 Aug 2016 17:16:01 +0000 (18:16 +0100)] 
Revert "codeGen: Remove binutils<2.17 hack, fixes T11758"

This reverts commit e3e2e49a8f6952e1c8a19321c729c17b294d8c92.

I'm reverting because it makes ghc-stage2 seg-fault on
64-bit Windows machines.  Even ghc-stage2 --version seg-faults.

2 years agoAdd gcoerceWith to Data.Type.Coercion
Ryan Scott [Thu, 18 Aug 2016 13:11:03 +0000 (09:11 -0400)] 
Add gcoerceWith to Data.Type.Coercion

Summary:
For symmetry with `gcastWith` in `Data.Type.Equality`.

Fixes #12493.

Test Plan: It compiles

Reviewers: bgamari, goldfire, hvr, austin

Subscribers: thomie

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

GHC Trac Issues: #12493

2 years agoRevert "T1969: Enable it again but bump the max residency temporarily"
Matthew Pickering [Wed, 17 Aug 2016 20:48:57 +0000 (21:48 +0100)] 
Revert "T1969: Enable it again but bump the max residency temporarily"

This reverts commit 773e3aadac4bbee9a0173ebc90ffdc9458a2a3a9.

2 years agoRefactor nestImplicTcS
Simon Peyton Jones [Wed, 17 Aug 2016 13:38:02 +0000 (14:38 +0100)] 
Refactor nestImplicTcS

Simpler code, and simpler to understand.
No change in behaviour.

2 years agoKeep the bindings local during defaultCallStacks
Simon Peyton Jones [Wed, 17 Aug 2016 13:35:19 +0000 (14:35 +0100)] 
Keep the bindings local during defaultCallStacks

defaultCallStacks generates evidence bindings for call stacks,
but wasn't setting the binding site correctly.  As a result
they were simply discarded in the case of pattern synonyms,
giving rise to Trac #12489.

The fix is easy; and I added an ASSERT to catch the error earlier.

2 years agoNot-in-scope variables are always errors
Simon Peyton Jones [Wed, 17 Aug 2016 11:04:30 +0000 (12:04 +0100)] 
Not-in-scope variables are always errors

This fixes Trac #12406.  A not-in-scope error shoudl be an error
even if you have -fdefer-typed-holes.

2 years agoTypo in comment
Gabor Greif [Thu, 11 Aug 2016 08:14:25 +0000 (10:14 +0200)] 
Typo in comment

2 years agoTypofix in System.Environment docs.
Edward Z. Yang [Tue, 16 Aug 2016 09:38:02 +0000 (02:38 -0700)] 
Typofix in System.Environment docs.

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
2 years agoMinor typofix.
Edward Z. Yang [Sat, 2 Jul 2016 00:00:01 +0000 (20:00 -0400)] 
Minor typofix.

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
2 years agoWhen in sanity mode, un-zero malloc'd memory; fix uninitialized memory bugs.
Edward Z. Yang [Mon, 15 Aug 2016 09:22:28 +0000 (02:22 -0700)] 
When in sanity mode, un-zero malloc'd memory; fix uninitialized memory bugs.

malloc'd memory is not guaranteed to be zeroed.  On Linux, however,
it is often zeroed, leading to latent bugs.  In fact, with this
patch I fix two uninitialized memory bugs stemming from this.

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

Reviewers: simonmar, austin, Phyx, bgamari, erikd

Subscribers: thomie

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

2 years agoDarwin: Detect broken NM program at configure time
Erik de Castro Lopo [Mon, 15 Aug 2016 20:41:19 +0000 (06:41 +1000)] 
Darwin: Detect broken NM program at configure time

Some recent versions of XCode ship a broken version of `nm`. Detect this
at configure time, and error out with a suggestion to rerun configure
with a `--with-nm=...` argument.

Test Plan: Test of Linux and OS X

Reviewers: carter, hvr, austin, bgamari

Reviewed By: bgamari

Subscribers: thomie

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

2 years agorefactor test for __builtin_unreachable into Rts.h macro RTS_UNREACHABLE
Karel Gardas [Mon, 15 Aug 2016 20:26:04 +0000 (22:26 +0200)] 
refactor test for __builtin_unreachable into Rts.h macro RTS_UNREACHABLE

Summary:
This patch refactors GNU C version test (for 4.5 and more modern)
due to usage of __builtin_unreachable done in the CNF.c code directly
into the new RTS_UNREACHABLE macro placed into Rts.h

Reviewers: bgamari, austin, simonmar, erikd

Subscribers: thomie

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

2 years agoUpdate hoopl submodule (extra .gitignore entry)
Edward Z. Yang [Mon, 15 Aug 2016 10:13:43 +0000 (03:13 -0700)] 
Update hoopl submodule (extra .gitignore entry)

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
2 years agofix compilation failure on OpenBSD with system supplied GNU C 4.2.1
Karel Gardas [Sat, 13 Aug 2016 16:46:43 +0000 (18:46 +0200)] 
fix compilation failure on OpenBSD with system supplied GNU C 4.2.1

Summary:
This patch fixes compilation failure on OpenBSD. The OpenBSD's
GNU C compiler is of 4.2.1 version and problematic __builtin_unreachable
was added in GNU C 4.5 release. Let's use pure abort() call
on OpenBSD instead of __builtin_unreachable

Reviewers: bgamari, austin, erikd, simonmar

Subscribers: thomie

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

2 years agoFix configure detection.
Tamar Christina [Sat, 13 Aug 2016 15:27:30 +0000 (16:27 +0100)] 
Fix configure detection.

Summary:
GHC's configure script seems to normalize the values returned from config.guess.
So for Windows it turns x86_64-pc-mingw64 into x86_64-unknown-mingw32.
These mangled names are stored in the values $BuildPlatform, $HostPlatform
and $TargetPlatform.

However further down the file when the comparison is done between the stage0
compiler and the host the normalized versions are not used.
So when normalization actually changes the triple this check will fail.

Not sure why it's worked for all this time.. Nor if this is the right fix?
Does it still work for cross compiling correctly?

Test Plan: ./configure

Reviewers: hvr, austin, thomie, bgamari, erikd

Reviewed By: erikd

Subscribers: erikd, #ghc_windows_task_force

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

GHC Trac Issues: #12487

2 years agoMisspellings in comments [skip ci]
Gabor Greif [Sun, 14 Aug 2016 11:03:23 +0000 (13:03 +0200)] 
Misspellings in comments [skip ci]

2 years agoUpdate `nofib` submodule to newest commit
Gabor Greif [Sun, 14 Aug 2016 07:50:49 +0000 (09:50 +0200)] 
Update `nofib` submodule to newest commit

2 years agoFix GHCi perf-llvm build on x86_64
Erik de Castro Lopo [Sat, 13 Aug 2016 21:23:35 +0000 (07:23 +1000)] 
Fix GHCi perf-llvm build on x86_64

With BuildFlavour set to `perf-llvm`, GHCi would fail as soon as it
was run with:

  ghc-stage2: .../ghc-prim/dist-install/build/HSghc-prim-0.5.0.0.o:
  unknown symbol `__udivti3'
  ghc-stage2: unable to load package `ghc-prim-0.5.0.0'

Fix this by adding `__udivti3` and `__umodti3` to RtsSymbols.c.

Test Plan: Validate

Reviewers: simonmar, austin, bgamari, Phyx, trofi

Reviewed By: Phyx, trofi

Subscribers: thomie

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

GHC Trac Issues: #11981

2 years agoImprove missing-sig warning
Simon Peyton Jones [Fri, 12 Aug 2016 14:52:07 +0000 (15:52 +0100)] 
Improve missing-sig warning

Fixes Trac #12484

2 years agoRemove StgRubbishArg and CmmArg
Ömer Sinan Ağacan [Wed, 10 Aug 2016 16:47:47 +0000 (16:47 +0000)] 
Remove StgRubbishArg and CmmArg

The idea behind adding special "rubbish" arguments was in unboxed sum types
depending on the tag some arguments are not used and we don't want to move some
special values (like 0 for literals and some special pointer for boxed slots)
for those arguments (to stack locations or registers). "StgRubbishArg" was an
indicator to the code generator that the value won't be used. During Stg-to-Cmm
we were then not generating any move or store instructions at all.

This caused problems in the register allocator because some variables were only
initialized in some code paths. As an example, suppose we have this STG: (after
unarise)

    Lib.$WT =
        \r [dt_sit]
            case
                case dt_sit of {
                  Lib.F dt_siv [Occ=Once] ->
                      (#,,#) [1# dt_siv StgRubbishArg::GHC.Prim.Int#];
                  Lib.I dt_siw [Occ=Once] ->
                      (#,,#) [2# StgRubbishArg::GHC.Types.Any dt_siw];
                }
            of
            dt_six
            { (#,,#) us_giC us_giD us_giE -> Lib.T [us_giC us_giD us_giE];
            };

This basically unpacks a sum type to an unboxed sum with 3 fields, and then
moves the unboxed sum to a constructor (`Lib.T`).

This is the Cmm for the inner case expression (case expression in the scrutinee
position of the outer case):

    ciN:
        ...
        -- look at dt_sit's tag
        if (_ciT::P64 != 1) goto ciS; else goto ciR;
    ciS: -- Tag is 2, i.e. Lib.F
        _siw::I64 = I64[_siu::P64 + 6];
        _giE::I64 = _siw::I64;
        _giD::P64 = stg_RUBBISH_ENTRY_info;
        _giC::I64 = 2;
        goto ciU;
    ciR: -- Tag is 1, i.e. Lib.I
        _siv::P64 = P64[_siu::P64 + 7];
        _giD::P64 = _siv::P64;
        _giC::I64 = 1;
        goto ciU;

Here one of the blocks `ciS` and `ciR` is executed and then the execution
continues to `ciR`, but only `ciS` initializes `_giE`, in the other branch
`_giE` is not initialized, because it's "rubbish" in the STG and so we don't
generate an assignment during code generator. The code generator then panics
during the register allocations:

    ghc-stage1: panic! (the 'impossible' happened)
      (GHC version 8.1.20160722 for x86_64-unknown-linux):
            LocalReg's live-in to graph ciY {_giE::I64}

(`_giD` is also "rubbish" in `ciS`, but it's still initialized because it's a
pointer slot, we have to initialize it otherwise garbage collector follows the
pointer to some random place. So we only remove assignment if the "rubbish" arg
has unboxed type.)

This patch removes `StgRubbishArg` and `CmmArg`. We now always initialize
rubbish slots. If the slot is for boxed types we use the existing `absentError`,
otherwise we initialize the slot with literal 0.

Reviewers: simonpj, erikd, austin, simonmar, bgamari

Reviewed By: erikd

Subscribers: thomie

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

2 years agoFix a bug in unboxed sum layout generation
Ömer Sinan Ağacan [Tue, 9 Aug 2016 22:30:56 +0000 (22:30 +0000)] 
Fix a bug in unboxed sum layout generation

We need to maintain the invariant that the layout fields are always sorted.

Two tests that were previously broken are added.

2 years agoActually update haddock.Cabal stats.
Edward Z. Yang [Mon, 8 Aug 2016 23:06:45 +0000 (16:06 -0700)] 
Actually update haddock.Cabal stats.

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
2 years agoCabal submodule update.
Edward Z. Yang [Wed, 4 May 2016 21:55:59 +0000 (14:55 -0700)] 
Cabal submodule update.

There's a substantial bump to the haddock.Cabal allocation
stats, because we added 50% more modules, so of course allocations
are going to increase 50%. (But perhaps this is indicative of
some bad constant factor in Haddock related to modules.)

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

Reviewers: ggreif, austin, bgamari

Subscribers: thomie

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

2 years agoFix typo in Data.Bitraversable Haddocks
Ryan Scott [Mon, 8 Aug 2016 16:59:17 +0000 (12:59 -0400)] 
Fix typo in Data.Bitraversable Haddocks

[ci skip]

2 years agoT1969: Enable it again but bump the max residency temporarily
Ömer Sinan Ağacan [Sun, 7 Aug 2016 15:19:01 +0000 (15:19 +0000)] 
T1969: Enable it again but bump the max residency temporarily

T1969 was broken by 714beb (which actually reduced allocations but
residency was increased). Instead of disabling it completely, just bump
the number a little bit to avoid making things even worse in the
meantime. See also #12437.

2 years agoconfigure.ac: Remove checks for bug 9439
Erik de Castro Lopo [Sat, 6 Aug 2016 22:24:16 +0000 (08:24 +1000)] 
configure.ac: Remove checks for bug 9439

Bug #9439 only affects some ghc 7.8 versions of the compiler and since
git HEAD no longer builds with ghc-7.8 we can drop this check.

Test Plan: Works here!

Reviewers: hvr, austin, bgamari

Reviewed By: bgamari

Subscribers: thomie

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

2 years agoUse Data.Functor.Const to implement Data.Data internals
Ryan Scott [Sat, 6 Aug 2016 15:08:31 +0000 (11:08 -0400)] 
Use Data.Functor.Const to implement Data.Data internals

Summary:
`Data.Data` uses an internal datatype `CONST`, which can be replaced
completely by `Const` from `Data.Functor.Const`.

Reviewers: austin, bgamari, hvr

Subscribers: thomie

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

2 years agoRegAlloc: Use IntSet/IntMaps instead of generic Set/Maps
Ömer Sinan Ağacan [Sat, 6 Aug 2016 13:10:03 +0000 (13:10 +0000)] 
RegAlloc: Use IntSet/IntMaps instead of generic Set/Maps

2 years agoRegAlloc: Remove duplicate seqList (use seqList from Util)
Ömer Sinan Ağacan [Sat, 6 Aug 2016 12:56:50 +0000 (12:56 +0000)] 
RegAlloc: Remove duplicate seqList (use seqList from Util)

2 years agoAsmCodeGen: Give linear-scan and coloring reg. allocators different cc names
Ömer Sinan Ağacan [Sat, 6 Aug 2016 12:55:54 +0000 (12:55 +0000)] 
AsmCodeGen: Give linear-scan and coloring reg. allocators different cc names

2 years agorts/Printer.h: fix constness of argument declaration
Sergei Trofimovich [Sat, 6 Aug 2016 10:55:14 +0000 (11:55 +0100)] 
rts/Printer.h: fix constness of argument declaration

Noticed on today's build failure:

  rts/Printer.c:659:13: error:
     error: conflicting types for 'DEBUG_LoadSymbols'
     extern void DEBUG_LoadSymbols( const char *name )
                 ^~~~~~~~~~~~~~~~~

  In file included from rts/Printer.c:17:0: error:

  rts/Printer.h:29:13: error:
     note: previous declaration of 'DEBUG_LoadSymbols' was here
     extern void DEBUG_LoadSymbols( char *name );
                 ^~~~~~~~~~~~~~~~~

Signed-off-by: Sergei Trofimovich <siarheit@google.com>
2 years agoUtil.count: Implement as a left-fold instead of a right-fold
Joachim Breitner [Sat, 6 Aug 2016 01:39:07 +0000 (21:39 -0400)] 
Util.count: Implement as a left-fold instead of a right-fold

2 years agoReplace some `length . filter` with `count`
Ömer Sinan Ağacan [Fri, 5 Aug 2016 20:58:02 +0000 (20:58 +0000)] 
Replace some `length . filter` with `count`

2 years agoStgCmm: Remove unused Bool field of Return sequel
Ömer Sinan Ağacan [Fri, 5 Aug 2016 18:52:46 +0000 (18:52 +0000)] 
StgCmm: Remove unused Bool field of Return sequel

2 years agoTemporarily mark T1969 perf test as broken (#12437)
Ömer Sinan Ağacan [Fri, 5 Aug 2016 15:28:26 +0000 (15:28 +0000)] 
Temporarily mark T1969 perf test as broken (#12437)

2 years agoBump `hoopl` submodule, mostly cosmetics
Gabor Greif [Fri, 5 Aug 2016 10:39:21 +0000 (12:39 +0200)] 
Bump `hoopl` submodule, mostly cosmetics

2 years agoAnother try to get thread migration right
Simon Marlow [Thu, 4 Aug 2016 14:59:43 +0000 (15:59 +0100)] 
Another try to get thread migration right

Summary:
This is surprisingly tricky.  There were linked list bugs in the
previous version (D2430) that showed up as a test failure in
setnumcapabilities001 (that's a great stress test!).

This new version uses a different strategy that doesn't suffer from
the problem that @ezyang pointed out in D2430.  We now pre-calculate
how many threads to keep for this capability, and then migrate any
surplus threads off the front of the queue, taking care to account for
threads that can't be migrated.

Test Plan:
1. setnumcapabilities001 stress test with sanity checking (+RTS -DS) turned on:

```
cd testsuite/tests/concurrent/should_run
make TEST=setnumcapabilities001 WAY=threaded1 EXTRA_HC_OPTS=-with-rtsopts=-DS CLEANUP=0
while true; do ./setnumcapabilities001.run/setnumcapabilities001 4 9 2000 || break; done
```

2. The test case from #12419

Reviewers: niteria, ezyang, rwbarton, austin, bgamari, erikd

Subscribers: thomie, ezyang

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

GHC Trac Issues: #12419

2 years agoFix an assertion that could randomly fail
Simon Marlow [Thu, 4 Aug 2016 14:57:37 +0000 (15:57 +0100)] 
Fix an assertion that could randomly fail

Summary:
ASSERT_THREADED_CAPABILITY_INVARIANTS was testing properties of the
returning_tasks queue, but that requires cap->lock to access safely.
This assertion would randomly fail if stressed enough.

Instead I've removed it from the catch-all
ASSERT_PARTIAL_CAPABILITIY_INVARIANTS and made it a separate assertion
only called under cap->lock.

Test Plan:
```
cd testsuite/tests/concurrent/should_run
make TEST=setnumcapabilities001 WAY=threaded1 EXTRA_HC_OPTS=-with-rtsopts=-DS CLEANUP=0
while true; do ./setnumcapabilities001.run/setnumcapabilities001 4 9 2000 || break; done
```

Reviewers: niteria, bgamari, ezyang, austin, erikd

Subscribers: thomie

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

GHC Trac Issues: #10860

2 years agoExpanded abbreviations in Haddock documentation
Ben Gamari [Thu, 4 Aug 2016 12:36:09 +0000 (14:36 +0200)] 
Expanded abbreviations in Haddock documentation

This adds notes to the Haddock documentation for various core datatypes
expanding abbreviations.

Reviewers: bgamari, thomie

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

GHC Trac Issues: #12405

2 years agocodeGen: Remove binutils<2.17 hack, fixes T11758
Alex Dzyoba [Thu, 4 Aug 2016 11:42:21 +0000 (13:42 +0200)] 
codeGen: Remove binutils<2.17 hack, fixes T11758

There was a complication on the x86_64 platform, where pointers were 64
bits, but the tools didn't support 64-bit relative relocations.  This
was true before binutils 2.17, which nowadays is quite standart (even
CentOs 5 is shipped with 2.17).

Hacks were removed from x86 genSwitch and asm pretty printer. Also
[x86-64-relative] note was dropped from
includes/rts/storage/InfoTables.h as it's not referenced anywhere now.

Reviewers: austin, simonmar, rwbarton, erikd, bgamari

Reviewed By: simonmar, erikd, bgamari

Subscribers: thomie

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

2 years agocheck that the number of parallel build is greater than 0
Ruey-Lin Hsu [Thu, 4 Aug 2016 11:41:57 +0000 (13:41 +0200)] 
check that the number of parallel build is greater than 0

Fixes #12062.

Reviewers: bgamari, thomie, austin, simonmar

Reviewed By: bgamari, thomie, simonmar

Subscribers: simonmar, thomie

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

GHC Trac Issues: #12062

2 years agoRemove identity update of field componentsConfigs
Gabor Greif [Fri, 5 Aug 2016 07:52:26 +0000 (09:52 +0200)] 
Remove identity update of field componentsConfigs

... in LocalBuildInfo, getting rid of a TODO in the
process. Turns out that componentsConfigs won't be
a field in Cabal 2.0 any more, so this can be seen
as a preparation for it.

2 years agoTrim all spaces after 'version:'
Gabor Greif [Fri, 5 Aug 2016 07:42:09 +0000 (09:42 +0200)] 
Trim all spaces after 'version:'

... that we grep out of libraries/Cabal/Cabal/Cabal.cabal

This is necessary because the file got reformatted
in the 'master' branch.

2 years agoFix omission in haddock instance head
Gabor Greif [Fri, 5 Aug 2016 07:00:51 +0000 (09:00 +0200)] 
Fix omission in haddock instance head

2 years agoReplace an unsafeCoerce with coerce
Ryan Scott [Thu, 4 Aug 2016 14:25:10 +0000 (10:25 -0400)] 
Replace an unsafeCoerce with coerce

This matches the implementations of `castPtr` and `castFunPtr`.

2 years agoCmmLayoutStack: Minor simplification
Ömer Sinan Ağacan [Thu, 4 Aug 2016 10:10:41 +0000 (10:10 +0000)] 
CmmLayoutStack: Minor simplification

2 years agoCmmLive: Remove some redundant exports
Ömer Sinan Ağacan [Thu, 4 Aug 2016 10:09:56 +0000 (10:09 +0000)] 
CmmLive: Remove some redundant exports

2 years agoClarify comment on makeCorePair
Matthew Pickering [Wed, 3 Aug 2016 16:06:42 +0000 (17:06 +0100)] 
Clarify comment on makeCorePair

2 years agoRemove `setUnfoldingInfoLazily`
Matthew Pickering [Wed, 3 Aug 2016 13:22:21 +0000 (14:22 +0100)] 
Remove `setUnfoldingInfoLazily`

The definition of `setUnfoldingInfoLazily` is exactly the same as
`setUnfoldingInfo` and is only used in one place, `TcIface`.

They were made equivalent in 2010 in
2ff2497dc374175b8ed81446258baf208d1f3e6e with the commit message.

{{{
commit 2ff2497dc374175b8ed81446258baf208d1f3e6e
Author: Ian Lynagh <igloo@earth.li>  Wed Oct 20 15:37:10 2010
Committer:      Ian Lynagh <igloo@earth.li>  Wed Oct 20 15:37:10 2010
Original File:  compiler/basicTypes/IdInfo.lhs

Don't seq unfoldings
We generate intermediate unfoldings which are just thrown away, so
evaluating them is a waste of time.
}}}

Closes #12453

2 years agoTypo in comment [skip ci]
Matthew Pickering [Wed, 3 Aug 2016 13:06:57 +0000 (14:06 +0100)] 
Typo in comment [skip ci]

2 years agoMore comments about InlinePragmas
Matthew Pickering [Wed, 3 Aug 2016 13:04:53 +0000 (14:04 +0100)] 
More comments about InlinePragmas

Just pointers about where to look in the source code.

2 years agoUpdate old comment InlinePragma
Matthew Pickering [Wed, 3 Aug 2016 10:37:05 +0000 (11:37 +0100)] 
Update old comment InlinePragma

2 years agoAdd comment about lexing of INLINE and INLINABLE pragma
Matthew Pickering [Wed, 3 Aug 2016 10:29:26 +0000 (11:29 +0100)] 
Add comment about lexing of INLINE and INLINABLE pragma

2 years agoStgSyn: Remove unused StgLiveVars types
Ömer Sinan Ağacan [Wed, 3 Aug 2016 08:50:31 +0000 (08:50 +0000)] 
StgSyn: Remove unused StgLiveVars types

2 years agoRemove the DEBUG_<blah> variables, use RtsFlags directly
Simon Marlow [Tue, 2 Aug 2016 12:09:32 +0000 (13:09 +0100)] 
Remove the DEBUG_<blah> variables, use RtsFlags directly

2 years agoOnly trace cap/capset events if we're tracing anything else
Simon Marlow [Tue, 2 Aug 2016 08:57:19 +0000 (09:57 +0100)] 
Only trace cap/capset events if we're tracing anything else

Summary:
I was getting annoyed by cap/capset messages when using +RTS -DS, which
doesn't cause any other trace messages to be emitted.  This makes it
possible to add --with-rtsopts=-DS when running tests, and not have all
the tests fail due to spurious trace messages.

Test Plan: validate

Reviewers: duncan, bgamari, ezyang, austin, erikd

Subscribers: thomie

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

2 years agoFix to thread migration
Simon Marlow [Wed, 27 Jul 2016 15:00:08 +0000 (16:00 +0100)] 
Fix to thread migration

Summary:
If we had 2 threads on the run queue, say [A,B], and B is bound to the
current Task, then we would fail to migrate any threads.  This fixes it
so that we would migrate A in that case.

This will help parallelism a bit in programs that have lots of bound
threads.

Test Plan:
Test program in #12419, which is actually not a great program but it
does behave a bit better after this change.

Reviewers: ezyang, niteria, bgamari, austin, erikd

Subscribers: thomie

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

GHC Trac Issues: #12419

2 years agoTrack the lengths of the thread queues
Simon Marlow [Tue, 2 Aug 2016 08:55:31 +0000 (09:55 +0100)] 
Track the lengths of the thread queues

Summary:
Knowing the length of the run queue in O(1) time is useful: for example
we don't have to traverse the run queue to know how many threads we have
to migrate in schedulePushWork().

Test Plan: validate

Reviewers: ezyang, erikd, bgamari, austin

Subscribers: thomie

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

2 years agoForeignCall.hs: Remove DrIFT directives
Ömer Sinan Ağacan [Tue, 2 Aug 2016 13:03:32 +0000 (13:03 +0000)] 
ForeignCall.hs: Remove DrIFT directives

2 years agoTypo in comment
Gabor Greif [Mon, 1 Aug 2016 13:25:10 +0000 (15:25 +0200)] 
Typo in comment

2 years agoUse MO_Cmpxchg in Primops.cmm instead of ccall cas(..)
alexbiehl [Mon, 1 Aug 2016 08:46:29 +0000 (18:46 +1000)] 
Use MO_Cmpxchg in Primops.cmm instead of ccall cas(..)

Adjust `CmmParse.y` to parse the `cmpxchg{8, 16, 32, 64}` instructions
and use the 32 respectively the 64 bit variant in `Primops.cmm`. This
effectively eliminates the compare-and-swap ccall to the rts.

Based off the mailing list question from @osa1
(https://mail.haskell.org/pipermail/ghc-devs/2016-July/012506.html).

Reviewers: simonmar, austin, erikd, bgamari, trommler

Reviewed By: erikd, bgamari, trommler

Subscribers: carter, trommler, osa1, thomie

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

2 years agoRelevant Bindings no longer reports shadowed bindings (fixes #12176)
Annie Cherkaev [Mon, 1 Aug 2016 06:30:42 +0000 (23:30 -0700)] 
Relevant Bindings no longer reports shadowed bindings (fixes #12176)

Summary: Modified the RelevantBindings method in TcErrors.hs to only search over
non-shadowed bindings.

Test Plan: Wrote 2 simple test cases, verified that it worked with multiple
shadowed bindings, and also non-shadowed bindings.

Reviewers: austin, bgamari, ezyang

Reviewed By: ezyang

Subscribers: ezyang, thomie

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

GHC Trac Issues: #12177

2 years agoAdd atomic operations to package.conf.in
alexbiehl [Sat, 30 Jul 2016 07:22:54 +0000 (17:22 +1000)] 
Add atomic operations to package.conf.in

This patch resulted from the discussion in D2431 and should be merged
first.

@erikd and @trommler reported errors like

```
/home/erikd/Git/ghc-upstream/rts/dist/build/libHSrts_thr.a(PrimOps.thr_o
): In function `c14_info':
(.text+0x2b8): undefined reference to `hs_cmpxchg32'
/home/erikd/Git/ghc-upstream/rts/dist/build/libHSrts_thr.a(PrimOps.thr_o
): In function `c5e_info':
(.text+0xac4): undefined reference to `hs_cmpxchg32'
/home/erikd/Git/ghc-upstream/rts/dist/build/libHSrts_thr.a(PrimOps.thr_o
): In function `c8b_info':
(.text+0x1198): undefined reference to `hs_cmpxchg32'
/home/erikd/Git/ghc-upstream/rts/dist/build/libHSrts_thr.a(PrimOps.thr_o
): In function `c8b_info':
(.text+0x122c): undefined reference to `hs_cmpxchg32'
/home/erikd/Git/ghc-upstream/rts/dist/build/libHSrts_thr.a(PrimOps.thr_o
): In function `c8b_info':
(.text+0x12ec): undefined reference to `hs_cmpxchg32'
```

on PowerPC. @simonmar suggests to add the specific exports to
`rts/package.conf.in`. This patch does exactly that, including all
other atomic ops as they probably (maybe someone can verify?) suffer
from the same problem on PPC.

Test Plan: Please make sure to build on PPC.

Reviewers: erikd, austin, bgamari, simonmar, trommler

Reviewed By: erikd, trommler

Subscribers: thomie

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

2 years agoMake Unique a newtype
Ömer Sinan Ağacan [Thu, 28 Jul 2016 15:13:54 +0000 (15:13 +0000)] 
Make Unique a newtype

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: thomie

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

2 years agoMove stat_startGCSync
Bartosz Nitka [Wed, 27 Jul 2016 15:25:59 +0000 (08:25 -0700)] 
Move stat_startGCSync

@simonmar told me that it makes more sense this way.

Test Plan: it still builds

Reviewers: bgamari, austin, simonmar, erikd

Reviewed By: simonmar, erikd

Subscribers: thomie, simonmar

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

2 years agoAdd mblocks_allocated to GC stats API
Bartosz Nitka [Wed, 27 Jul 2016 15:24:40 +0000 (08:24 -0700)] 
Add mblocks_allocated to GC stats API

This exposes mblocks_allocated in the GCStats struct.

Test Plan: it builds

Reviewers: bgamari, simonmar, austin, hvr, erikd

Reviewed By: erikd

Subscribers: thomie

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

2 years agoCompute boot-defined TyCon names from ModIface.
Edward Z. Yang [Sun, 3 Jul 2016 01:08:55 +0000 (18:08 -0700)] 
Compute boot-defined TyCon names from ModIface.

Summary:
Three things in this commit:

    1. Get rid of sb_ids; we are not going to use them
    to avoid infinite unfoldings in hs-boot files.

    2. Compute sb_tcs from ModIface rather than ModDetails.
    This means that the typechecker can look at this field
    without forcing the boot ModDetails, which would be
    bad if the ModDetails is not available yet (due to
    knot tying.)

    3. A big honking comment explaining what is going on
    here.

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
Reviewers: simonpj, austin, bgamari

Subscribers: thomie

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

2 years agoAccept better stats for T9675
Simon Marlow [Tue, 26 Jul 2016 15:01:58 +0000 (08:01 -0700)] 
Accept better stats for T9675

2 years agoFix productivity calculation (#12424)
Simon Marlow [Tue, 26 Jul 2016 14:55:37 +0000 (07:55 -0700)] 
Fix productivity calculation (#12424)

2 years agoMonadUtils: Typos in comments
Ömer Sinan Ağacan [Tue, 26 Jul 2016 14:47:43 +0000 (14:47 +0000)] 
MonadUtils: Typos in comments

2 years agoSome typos in comments
Gabor Greif [Mon, 25 Jul 2016 22:34:48 +0000 (00:34 +0200)] 
Some typos in comments

2 years agoTestsuite: fix T10482a
Thomas Miedema [Sun, 24 Jul 2016 23:36:20 +0000 (01:36 +0200)] 
Testsuite: fix T10482a

2 years agoFix the non-Linux build
Erik de Castro Lopo [Fri, 22 Jul 2016 12:59:44 +0000 (14:59 +0200)] 
Fix the non-Linux build

Summary:
The recent Compact Regions commit (cf989ffe49) builds fine on Linux
but doesn't build on OS X r Windows.

* rts/sm/CNF.c: Drop un-needed #includes.
* Fix parenthesis usage with CPP ASSERT macro.
* Fix format string in debugBelch messages.
* Use stg_max() instead hand rolled inline max() function.

Test Plan: Build on Linux, OS X and Windows

Reviewers: gcampax, simonmar, austin, bgamari

Subscribers: thomie

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

2 years agoUNPACK the size field of SizedSeq
Simon Marlow [Thu, 21 Jul 2016 12:47:47 +0000 (05:47 -0700)] 
UNPACK the size field of SizedSeq

2 years ago-fprof-auto-top
Simon Marlow [Thu, 21 Jul 2016 11:33:44 +0000 (04:33 -0700)] 
-fprof-auto-top

2 years agoSquash space leaks in the result of byteCodeGen
Simon Marlow [Thu, 21 Jul 2016 11:51:05 +0000 (04:51 -0700)] 
Squash space leaks in the result of byteCodeGen

When loading a large number of modules into GHCi, we collect
CompiledByteCode for every module and then link it all at the end.
Space leaks in the CompiledByteCode linger until we traverse it all for
linking, and possibly longer, if there are bits we don't look at.

This is the nuke-it-from-orbit approach: we deepseq the whole thing
after code generation. It's the only way to be sure.

Test Plan:
Heap profile of GHCi while loading nofib/real/anna into GHCi, this patch
reduces the peak heap usage from ~100M to ~50M.

Reviewers: hvr, austin, bgamari, erikd

Subscribers: thomie

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

2 years agoAdd deepseq dependency and a few NFData instances
Simon Marlow [Thu, 21 Jul 2016 11:32:55 +0000 (04:32 -0700)] 
Add deepseq dependency and a few NFData instances

I needed to rnf a data structure (CompiledByteCode) but we don't have
any good deepseq infrastructure in the compiler yet.  There are bits and
pieces, but nothing consistent, so this is a start.

We already had a dependency on deepseq indirectly via other packages
(e.g. containers).

Includes an update to the haddock submodule, to remove orphan NFData
instances in there.

Test Plan: validate

Reviewers: austin, bgamari, erikd, hvr

Subscribers: thomie

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

2 years agoStgCmmBind: Some minor simplifications
Ömer Sinan Ağacan [Fri, 22 Jul 2016 09:48:42 +0000 (09:48 +0000)] 
StgCmmBind: Some minor simplifications