ghc.git
12 months agoStable name comment wibbles
David Feuer [Mon, 17 Sep 2018 14:46:05 +0000 (16:46 +0200)] 
Stable name comment wibbles

Summary:
Some comments in the `StableName` code still referred to
stable pointer details. Fix that.

Reviewers: bgamari, erikd, simonmar

Reviewed By: simonmar

Subscribers: rwbarton, carter

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

12 months agoFix for #13862: Optional "-v" not allowed with :load in GHCi
roland [Sun, 16 Sep 2018 16:06:13 +0000 (19:06 +0300)] 
Fix for #13862: Optional "-v" not allowed with :load in GHCi

Replace the error message
    `Use -v to see a list of the files searched for.`
with
    `Use -v (or :set -v` in ghci) to see a list of the files searched for.`

Reviewers: bgamari, monoidal, thomie, osa1

Subscribers: rwbarton, carter

GHC Trac Issues: #13862

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

12 months agoCorrect submodule update for haddock
Richard Eisenberg [Sat, 15 Sep 2018 19:41:39 +0000 (15:41 -0400)] 
Correct submodule update for haddock

Previous commit (Coercion Quantification) was missing a
commit on the haddock submodule. This (hopefully) corrects it.

12 months agoCoercion Quantification
ningning [Sat, 15 Sep 2018 14:16:47 +0000 (10:16 -0400)] 
Coercion Quantification

This patch corresponds to #15497.

According to https://ghc.haskell.org/trac/ghc/wiki/DependentHaskell/Phase2,
 we would like to have coercion quantifications back. This will
allow us to migrate (~#) to be homogeneous, instead of its current
heterogeneous definition. This patch is (lots of) plumbing only. There
should be no user-visible effects.

An overview of changes:

- Both `ForAllTy` and `ForAllCo` can quantify over coercion variables,
but only in *Core*. All relevant functions are updated accordingly.
- Small changes that should be irrelevant to the main task:
    1. removed dead code `mkTransAppCo` in Coercion
    2. removed out-dated Note Computing a coercion kind and
       roles in Coercion
    3. Added `Eq4` in Note Respecting definitional equality in
       TyCoRep, and updated `mkCastTy` accordingly.
    4. Various updates and corrections of notes and typos.
- Haddock submodule needs to be changed too.

Acknowledgments:
This work was completed mostly during Ningning Xie's Google Summer
of Code, sponsored by Google. It was advised by Richard Eisenberg,
supported by NSF grant 1704041.

Test Plan: ./validate

Reviewers: goldfire, simonpj, bgamari, hvr, erikd, simonmar

Subscribers: RyanGlScott, monoidal, rwbarton, carter

GHC Trac Issues: #15497

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

12 months agoMark code related symbols as @function not @object
Sergei Azovskov [Fri, 14 Sep 2018 14:09:59 +0000 (15:09 +0100)] 
Mark code related symbols as @function not @object

Summary:
This diff is a part of the bigger project which goal is to improve
common profiling tools support (perf) for GHC binaries.

A similar job was already done and reverted in the past:
 * https://phabricator.haskell.org/rGHCb1f453e16f0ce11a2ab18cc4c350bdcbd36299a6
 * https://phabricator.haskell.org/rGHCf1f3c4f50650110ad0f700d6566a44c515b0548f

Reasoning:

`Perf` and similar tools build in memory symbol table from the .symtab
section of the ELF file to display human-readable function names instead
of the addresses in the output. `Perf` uses only two types of symbols:
`@function` and `@notype` but GHC is not capable to produce any
`@function` symbols so the `perf` output is pretty useless (All the
haskell symbols that you can see in `perf` now are `@notype` internal
symbols extracted by mistake/hack).

The changes:
 * mark code related symbols as @function
 * small hack to mark InfoTable symbols as code if TABLES_NEXT_TO_CODE is true

Limitations:
 * The perf symbolization support is not complete after this patch but
   I'm working on the second patch.
 * Constructor symbols are not supported. To fix that we can issue extra
   local symbols which mark code sections as code and will be only used
   for debug.

Test Plan:
tests
any additional ideas?

Perf output on stock ghc 8.4.1:
```
     9.78%  FibbSlow  FibbSlow            [.] ckY_info
     9.59%  FibbSlow  FibbSlow            [.] cjqd_info
     7.17%  FibbSlow  FibbSlow            [.] c3sg_info
     6.62%  FibbSlow  FibbSlow            [.] c1X_info
     5.32%  FibbSlow  FibbSlow            [.] cjsX_info
     4.18%  FibbSlow  FibbSlow            [.] s3rN_info
     3.82%  FibbSlow  FibbSlow            [.] c2m_info
     3.68%  FibbSlow  FibbSlow            [.] cjlJ_info
     3.26%  FibbSlow  FibbSlow            [.] c3sb_info
     3.19%  FibbSlow  FibbSlow            [.] cjPQ_info
     3.05%  FibbSlow  FibbSlow            [.] cjQd_info
     2.97%  FibbSlow  FibbSlow            [.] cjAB_info
     2.78%  FibbSlow  FibbSlow            [.] cjzP_info
     2.40%  FibbSlow  FibbSlow            [.] cjOS_info
     2.38%  FibbSlow  FibbSlow            [.] s3rK_info
     2.27%  FibbSlow  FibbSlow            [.] cjq0_info
     2.18%  FibbSlow  FibbSlow            [.] cKQ_info
     2.13%  FibbSlow  FibbSlow            [.] cjSl_info
     1.99%  FibbSlow  FibbSlow            [.] s3rL_info
     1.98%  FibbSlow  FibbSlow            [.] c2cC_info
     1.80%  FibbSlow  FibbSlow            [.] s3rO_info
     1.37%  FibbSlow  FibbSlow            [.] c2f2_info
...
```

Perf output on patched ghc:
```
     7.97%  FibbSlow  FibbSlow            [.] c3rM_info
     6.75%  FibbSlow  FibbSlow            [.] 0x000000000032cfa8
     6.63%  FibbSlow  FibbSlow            [.] cifA_info
     4.98%  FibbSlow  FibbSlow            [.] integerzmgmp_GHCziIntegerziType_eqIntegerzh_info
     4.55%  FibbSlow  FibbSlow            [.] chXn_info
     4.52%  FibbSlow  FibbSlow            [.] c3rH_info
     4.45%  FibbSlow  FibbSlow            [.] chZB_info
     4.04%  FibbSlow  FibbSlow            [.] Main_fibbzuslow_info
     4.03%  FibbSlow  FibbSlow            [.] stg_ap_0_fast
     3.76%  FibbSlow  FibbSlow            [.] chXA_info
     3.67%  FibbSlow  FibbSlow            [.] cifu_info
     3.25%  FibbSlow  FibbSlow            [.] ci4r_info
     2.64%  FibbSlow  FibbSlow            [.] s3rf_info
     2.42%  FibbSlow  FibbSlow            [.] s3rg_info
     2.39%  FibbSlow  FibbSlow            [.] integerzmgmp_GHCziIntegerziType_eqInteger_info
     2.25%  FibbSlow  FibbSlow            [.] integerzmgmp_GHCziIntegerziType_minusInteger_info
     2.17%  FibbSlow  FibbSlow            [.] ghczmprim_GHCziClasses_zeze_info
     2.09%  FibbSlow  FibbSlow            [.] cicc_info
     2.03%  FibbSlow  FibbSlow            [.] 0x0000000000331e15
     2.02%  FibbSlow  FibbSlow            [.] s3ri_info
     1.91%  FibbSlow  FibbSlow            [.] 0x0000000000331bb8
     1.89%  FibbSlow  FibbSlow            [.] ci4N_info
...
```

Reviewers: simonmar, niteria, bgamari, goldfire

Reviewed By: simonmar, bgamari

Subscribers: lelf, rwbarton, thomie, carter

GHC Trac Issues: #15501

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

12 months agoMark system and internal symbols as private symbols in asm
Sergei Azovskov [Fri, 14 Sep 2018 13:56:37 +0000 (14:56 +0100)] 
Mark system and internal symbols as private symbols in asm

Summary:
This marks system and internal symbols as private in asm output so those
random generated sysmbols won't appear in .symtab

Reasoning:
 * internal symbols don't help to debug because names are just random
 * the symbols style breaks perf logic
 * internal symbols can take ~75% of the .symtab. In the same time
   .symtab can take about 20% of the binary file size

Notice:
This diff mostly makes sense on top of the D4713 (or similar)

Test Plan:
tests

Perf from D4713
```
     7.97%  FibbSlow  FibbSlow            [.] c3rM_info
     6.75%  FibbSlow  FibbSlow            [.] 0x000000000032cfa8
     6.63%  FibbSlow  FibbSlow            [.] cifA_info
     4.98%  FibbSlow  FibbSlow            [.] integerzmgmp_GHCziIntegerziType_eqIntegerzh_info
     4.55%  FibbSlow  FibbSlow            [.] chXn_info
     4.52%  FibbSlow  FibbSlow            [.] c3rH_info
     4.45%  FibbSlow  FibbSlow            [.] chZB_info
     4.04%  FibbSlow  FibbSlow            [.] Main_fibbzuslow_info
     4.03%  FibbSlow  FibbSlow            [.] stg_ap_0_fast
     3.76%  FibbSlow  FibbSlow            [.] chXA_info
     3.67%  FibbSlow  FibbSlow            [.] cifu_info
     3.25%  FibbSlow  FibbSlow            [.] ci4r_info
     2.64%  FibbSlow  FibbSlow            [.] s3rf_info
     2.42%  FibbSlow  FibbSlow            [.] s3rg_info
     2.39%  FibbSlow  FibbSlow            [.] integerzmgmp_GHCziIntegerziType_eqInteger_info
     2.25%  FibbSlow  FibbSlow            [.] integerzmgmp_GHCziIntegerziType_minusInteger_info
     2.17%  FibbSlow  FibbSlow            [.] ghczmprim_GHCziClasses_zeze_info
     2.09%  FibbSlow  FibbSlow            [.] cicc_info
     2.03%  FibbSlow  FibbSlow            [.] 0x0000000000331e15
     2.02%  FibbSlow  FibbSlow            [.] s3ri_info
     1.91%  FibbSlow  FibbSlow            [.] 0x0000000000331bb8
     1.89%  FibbSlow  FibbSlow            [.] ci4N_info
...
```

Perf from this patch:
```
    15.37%  FibbSlow  FibbSlow            [.] Main_fibbzuslow_info
    15.33%  FibbSlow  FibbSlow            [.] integerzmgmp_GHCziIntegerziType_minusInteger_info
    13.34%  FibbSlow  FibbSlow            [.] integerzmgmp_GHCziIntegerziType_eqIntegerzh_info
     9.24%  FibbSlow  FibbSlow            [.] integerzmgmp_GHCziIntegerziType_plusInteger_info
     9.08%  FibbSlow  FibbSlow            [.] frame_dummy
     8.25%  FibbSlow  FibbSlow            [.] integerzmgmp_GHCziIntegerziType_eqInteger_info
     4.29%  FibbSlow  FibbSlow            [.] 0x0000000000321ab0
     3.84%  FibbSlow  FibbSlow            [.] stg_ap_0_fast
     3.07%  FibbSlow  FibbSlow            [.] ghczmprim_GHCziClasses_zeze_info
     2.39%  FibbSlow  FibbSlow            [.] 0x0000000000321ab7
     1.90%  FibbSlow  FibbSlow            [.] 0x00000000003266b8
     1.88%  FibbSlow  FibbSlow            [.] base_GHCziNum_zm_info
     1.83%  FibbSlow  FibbSlow            [.] 0x0000000000326915
     1.34%  FibbSlow  FibbSlow            [.] 0x00000000003248cc
     1.07%  FibbSlow  FibbSlow            [.] base_GHCziNum_zp_info
     0.98%  FibbSlow  FibbSlow            [.] 0x00000000003247c8
     0.80%  FibbSlow  FibbSlow            [.] 0x0000000000121498
     0.79%  FibbSlow  FibbSlow            [.] stg_gc_noregs
     0.75%  FibbSlow  FibbSlow            [.] 0x0000000000321ad6
     0.67%  FibbSlow  FibbSlow            [.] 0x0000000000321aca
     0.64%  FibbSlow  FibbSlow            [.] 0x0000000000321b4a
     0.61%  FibbSlow  FibbSlow            [.] 0x00000000002ff633
```

Reviewers: simonmar, niteria, bgamari

Reviewed By: simonmar

Subscribers: lelf, angerman, olsner, rwbarton, thomie, carter

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

12 months agoFix T15502 on 32-bit
Krzysztof Gogolewski [Fri, 14 Sep 2018 12:38:42 +0000 (14:38 +0200)] 
Fix T15502 on 32-bit

Summary:
The expected output uses a hardcoded value for
maxBound :: Int.

This should fix one of circleci failures on i386.

Test Plan: make test TEST=T15502

Reviewers: RyanGlScott, bgamari

Reviewed By: RyanGlScott

Subscribers: rwbarton, carter

GHC Trac Issues: #15502

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

12 months agotests: increase (compile) timeout multiplier for T13701 and MultiLayerModules
Alp Mestanogullari [Fri, 14 Sep 2018 12:01:09 +0000 (14:01 +0200)] 
tests: increase (compile) timeout multiplier for T13701 and MultiLayerModules

Summary:
Those tests are currently making our i386 validation fail on CircleCI:

  https://circleci.com/gh/ghc/ghc/8827

Test Plan: Using my Phab<->CircleCI bridge to run i386 validation for this diff.

Reviewers: bgamari, monoidal

Reviewed By: monoidal

Subscribers: rwbarton, carter

GHC Trac Issues: #15484, #15383

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

12 months agoAdd support for ImplicitParams and RecursiveDo in TH
Michael Sloan [Fri, 14 Sep 2018 10:17:13 +0000 (12:17 +0200)] 
Add support for ImplicitParams and RecursiveDo in TH

Summary:
This adds TH support for the ImplicitParams and RecursiveDo extensions.

I'm submitting this as one review because I cannot cleanly make
the two commits independent.

Initially, my goal was just to add ImplicitParams support, and
I found that reasonably straightforward, so figured I might
as well use my newfound knowledge to address some other TH omissions.

Test Plan: Validate

Reviewers: goldfire, austin, bgamari, RyanGlScott

Reviewed By: RyanGlScott

Subscribers: carter, RyanGlScott, thomie

GHC Trac Issues: #1262

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

12 months agoUpdate hsc2hs submodule
Chaitanya Koparkar [Thu, 13 Sep 2018 22:15:18 +0000 (18:15 -0400)] 
Update hsc2hs submodule

Test Plan: ./validate

Reviewers: bgamari, hvr, RyanGlScott

Reviewed By: RyanGlScott

Subscribers: monoidal, rwbarton, carter

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

12 months agobase: showEFloat: Handle negative precisions the same of zero precision
Ben Gamari [Thu, 13 Sep 2018 21:09:56 +0000 (17:09 -0400)] 
base: showEFloat: Handle negative precisions the same of zero precision

Test Plan: Validate

Reviewers: hvr, alpmestan

Reviewed By: alpmestan

Subscribers: rwbarton, carter

GHC Trac Issues: #15509

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

12 months agoeventlog: Factor out eventlog header generation into separate function
Ben Gamari [Thu, 13 Sep 2018 15:31:08 +0000 (11:31 -0400)] 
eventlog: Factor out eventlog header generation into separate function

12 months agoFix build
Krzysztof Gogolewski [Thu, 13 Sep 2018 20:52:05 +0000 (22:52 +0200)] 
Fix build

12 months agoRemove dead variable binding
Simon Peyton Jones [Thu, 13 Sep 2018 16:47:50 +0000 (17:47 +0100)] 
Remove dead variable binding

Fallout from earlier commit, sorry.

12 months agoMore info for Implication with -dppr-debug
Simon Peyton Jones [Thu, 13 Sep 2018 11:56:29 +0000 (12:56 +0100)] 
More info for Implication with -dppr-debug

12 months agoAdd regression test for Trac #15629
Simon Peyton Jones [Thu, 13 Sep 2018 11:56:09 +0000 (12:56 +0100)] 
Add regression test for Trac #15629

12 months agoAllow (~) in the head of a quantified constraints
Simon Peyton Jones [Thu, 13 Sep 2018 10:23:53 +0000 (11:23 +0100)] 
Allow (~) in the head of a quantified constraints

Since the introduction of quantified constraints, GHC has rejected
a quantified constraint with (~) in the head, thus
  f :: (forall a. blah => a ~ ty) => stuff

I am frankly dubious that this is ever useful.  But /is/ necessary for
Coercible (representation equality version of (~)) and it does no harm
to allow it for (~) as well.  Plus, our users are asking for it
(Trac #15359, #15625).

It was really only excluded by accident, so
this patch lifts the restriction. See TcCanonical
Note [Equality superclasses in quantified constraints]

There are a number of wrinkles:

* If the context of the quantified constraint is empty, we
  can get trouble when we get down to unboxed equality (a ~# b)
  or (a ~R# b), as Trac #15625 showed. This is even more of
  a corner case, but it produced an outright crash, so I elaborated
  the superclass machinery in TcCanonical.makeStrictSuperClasses
  to add a void argument in this case.  See
  Note [Equality superclasses in quantified constraints]

* The restriction on (~) was in TcValidity.checkValidInstHead.
  In lifting the restriction I discovered an old special case for
  (~), namely
      | clas_nm `elem` [ heqTyConName, eqTyConName]
      , nameModule clas_nm /= this_mod
  This was (solely) to support the strange instance
      instance a ~~ b => a ~ b
  in Data.Type.Equality. But happily that is no longer
  with us, since
     commit f265008fb6f70830e7e92ce563f6d83833cef071
     Refactor (~) to reduce the suerpclass stack
  So I removed the special case.

* I found that the Core invariants on when we could have
       co = <expr>
  were entirely not written down. (Getting this wrong ws
  the proximate source of the crash in Trac #15625.  So

  - Documented them better in CoreSyn
      Note [CoreSyn type and coercion invariant],
  - Modified CoreOpt and CoreLint to match
  - Modified CoreUtils.bindNonRec to match
  - Made MkCore.mkCoreLet use bindNonRec, rather
    than duplicate its logic
  - Made Simplify.rebuildCase case-to-let respect
      Note [CoreSyn type and coercion invariant],

12 months agoComments only (on IfDataInstance)
Simon Peyton Jones [Thu, 13 Sep 2018 08:18:25 +0000 (09:18 +0100)] 
Comments only (on IfDataInstance)

12 months agoDelete duplicated comment line
Simon Peyton Jones [Wed, 12 Sep 2018 12:21:19 +0000 (13:21 +0100)] 
Delete duplicated comment line

12 months agoComments about join-point return types
Simon Peyton Jones [Wed, 12 Sep 2018 12:21:02 +0000 (13:21 +0100)] 
Comments about join-point return types

12 months agoTypo in user guide wrongly claims DeriveLift was added in 7.2
Merijn Verstraaten [Mon, 10 Sep 2018 14:38:16 +0000 (16:38 +0200)] 
Typo in user guide wrongly claims DeriveLift was added in 7.2

12 months agoHonor INLINE on 0-arity bindings (#15578)
Tobias Dammers [Thu, 13 Sep 2018 08:21:49 +0000 (10:21 +0200)] 
Honor INLINE on 0-arity bindings (#15578)

Summary:
Fix test for #15578

By allowing 0-arity values to be inlined, we end up changing boringness
annotations, and this gets reflected in the Core output for this
particular test.

Add Notes for #15578

Test Plan: ./validate

Reviewers: simonpj, bgamari

Reviewed By: simonpj

Subscribers: rwbarton, carter

GHC Trac Issues: #15578

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

12 months agorts/Printer.c: always define the findPtr symbol
Alp Mestanogullari [Wed, 12 Sep 2018 22:06:02 +0000 (18:06 -0400)] 
rts/Printer.c: always define the findPtr symbol

It was previously only defined (and therefore shipped) when DEBUG is
defined.  This patch defines it regardless of DEBUG. This will help fix
hadrian on OS X [1].

[1]: https://github.com/snowleopard/hadrian/issues/614

Test Plan: The error from hadrian#614 is gone

Reviewers: bgamari, erikd, simonmar

Reviewed By: simonmar

Subscribers: rwbarton, carter

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

12 months agotemplate-haskell: Fix typo in changelog
Ben Gamari [Mon, 10 Sep 2018 02:23:16 +0000 (22:23 -0400)] 
template-haskell: Fix typo in changelog

12 months agoRevert "ghc: Remove warning of StaticPointers not being supported by GHCi"
Ben Gamari [Fri, 7 Sep 2018 14:48:43 +0000 (10:48 -0400)] 
Revert "ghc: Remove warning of StaticPointers not being supported by GHCi"

While we now support use of StaticPointers in modules loaded via the
REPL (e.g. via `:load`), we currently do not support use of
StaticPointers on the REPL itself.

This reverts commit 9400a5c6b308fbb5b3a73690610736ca3b5eb0b3.

12 months agoBe a bit more aggressive about let-to-case
Simon Peyton Jones [Wed, 12 Sep 2018 12:06:53 +0000 (13:06 +0100)] 
Be a bit more aggressive about let-to-case

This patch takes up the missed opportunity described in
Trac #15631, by convering a case into a let slightly
more agressively. See Simplify.hs
Note [Case-to-let for strictly-used binders]

There is no measurable perf impact for good or ill. But
the code is simpler and easier to explain.

12 months agoRefactor info table entry error messages
Ömer Sinan Ağacan [Wed, 12 Sep 2018 06:11:18 +0000 (09:11 +0300)] 
Refactor info table entry error messages

We now show address of the entered object in error messages. Example:

    foo: internal error: Evaluated a CAF (0xe4c518) that was GC'd!
        (GHC version 8.6.0.20180907 for x86_64_unknown_linux)
        Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug

Helpful when debugging.

Test Plan: This validates

Reviewers: simonmar, bgamari, erikd

Reviewed By: simonmar

Subscribers: rwbarton, carter

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

12 months agoMake CoreMonad independent of TcEnv (#14391)
Krzysztof Gogolewski [Tue, 11 Sep 2018 18:46:04 +0000 (20:46 +0200)] 
Make CoreMonad independent of TcEnv (#14391)

Summary:
This removes the last direct import from simplCore/
to typechecker/.

Test Plan: validate

Reviewers: nomeata, simonpj, bgamari

Reviewed By: simonpj

Subscribers: rwbarton, carter

GHC Trac Issues: #14391

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

12 months agorts.cabal.in: advertise new default profiling ways for hadrian
Alp Mestanogullari [Tue, 11 Sep 2018 18:45:43 +0000 (20:45 +0200)] 
rts.cabal.in: advertise new default profiling ways for hadrian

Summary:
D5140 makes us build some new profiling ways by default, but since it
is not advertised in rts.cabal, hadrian doesn't know about that. This patch
fixes this and successfully lets hadrian build those flavours of libHSrts.

Test Plan: hadrian/build.sh --flavour=perf

Reviewers: bgamari, erikd, simonmar

Reviewed By: simonmar

Subscribers: rwbarton, carter

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

12 months agoRevert incorrect STM wakeup optimisation
Ömer Sinan Ağacan [Tue, 11 Sep 2018 18:43:50 +0000 (20:43 +0200)] 
Revert incorrect STM wakeup optimisation

Summary: (see the comments)

Reviewers: simonmar, bgamari, erikd

Reviewed By: simonmar

Subscribers: rwbarton, carter

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

12 months agoBuild debugged prof runtimes
Ömer Sinan Ağacan [Mon, 10 Sep 2018 10:53:59 +0000 (13:53 +0300)] 
Build debugged prof runtimes

For some reason these were disabled. I find these quite useful when
debugging profiling issues, so enable them again.

Reviewers: bgamari, simonmar

Reviewed By: simonmar

Subscribers: rwbarton, carter

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

12 months agoUpdate UnsafeReenter test
Ömer Sinan Ağacan [Mon, 10 Sep 2018 08:14:46 +0000 (11:14 +0300)] 
Update UnsafeReenter test

Only run the test in non-threaded, compiled mode. It hangs with threaded
runtime (which stage 2 compiler uses, so disable it for ghci too).

Reviewers: simonmar, alpmestan, bgamari

Reviewed By: simonmar

Subscribers: rwbarton, carter

GHC Trac Issues: #14912

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

12 months agoAvoid creating unevaluated Int thunks when iterating in GHC.Foreign
Neil Mitchell [Fri, 7 Sep 2018 18:02:18 +0000 (19:02 +0100)] 
Avoid creating unevaluated Int thunks when iterating in GHC.Foreign

12 months agoRefactor Foreign.Marshal modules for more modern style
Ömer Sinan Ağacan [Sat, 8 Sep 2018 06:55:45 +0000 (09:55 +0300)] 
Refactor Foreign.Marshal modules for more modern style

(use ScopedTypeVariables to remove dummy arguments)

Reviewers: bgamari, RyanGlScott, dfeuer, hvr, monoidal

Reviewed By: monoidal

Subscribers: monoidal, rwbarton, carter

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

12 months agousers-guide: Disable syntax highlighting
Takenobu Tani [Fri, 7 Sep 2018 14:02:39 +0000 (16:02 +0200)] 
users-guide: Disable syntax highlighting

Summary:
I disabled syntax highlighting for NumericUnderscores extension.

Because pygments does not yet correspond to syntax rule for NumericUnderscores.
(Sphinx uses pygments as the syntax highlighting.)

I've sent a pull-request to pygments project[1].
But development of pygments has been suspended since 2017 March.

[1]: https://bitbucket.org/birkenfeld/pygments-main/pull-requests/
       745/fix-haskell-lexer-for-numeric-literals/diff

[ci skip]

Test Plan: build

Reviewers: bgamari, monoidal

Reviewed By: monoidal

Subscribers: rwbarton, carter

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

12 months agoghc: Remove warning of StaticPointers not being supported by GHCi
Ben Gamari [Thu, 6 Sep 2018 22:51:31 +0000 (18:51 -0400)] 
ghc: Remove warning of StaticPointers not being supported by GHCi

Support for StaticPointers was added in #12356 but I apparently
neglected to remove the warning.

12 months agoDocumentation tweaks
Krzysztof Gogolewski [Fri, 7 Sep 2018 11:53:11 +0000 (13:53 +0200)] 
Documentation tweaks

Summary:
- Mention static pointers in "stolen syntax"
- Suggest importing Constraint and IsString from Data.* instead of GHC.*
- Remove obsolete SPECIALISE syntax; it was removed in or before 1999
  (d66d409bf6)
- Fix link in pattern signatures

Test Plan: build

Reviewers: bgamari, takenobu

Reviewed By: takenobu

Subscribers: rwbarton, carter

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

12 months agoVarious RTS bug fixes:
Ömer Sinan Ağacan [Fri, 7 Sep 2018 06:28:36 +0000 (09:28 +0300)] 
Various RTS bug fixes:

- Retainer profiler: init_srt_thunk() should mark the stack entry as SRT
- Retainer profiler: Remove an incorrect assertion about FUN_STATIC.
  FUN_STATIC does not have to have an SRT.
- Fix nptrs of BCO

Test Plan: validate

Reviewers: simonmar, bgamari, erikd

Reviewed By: simonmar

Subscribers: rwbarton, carter

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

12 months agoFix a race between GC threads in concurrent scavenging
Ömer Sinan Ağacan [Thu, 6 Sep 2018 12:52:53 +0000 (15:52 +0300)] 
Fix a race between GC threads in concurrent scavenging

While debugging #15285 I realized that free block lists (free_list in
BlockAlloc.c) get corrupted when multiple scavenge threads allocate and
release blocks concurrently. Here's a picture of one such race:

    Thread 2 (Thread 32573.32601):
    #0  check_tail
        (bd=0x940d40 <stg_TSO_info>) at rts/sm/BlockAlloc.c:860
    #1  0x0000000000928ef7 in checkFreeListSanity
        () at rts/sm/BlockAlloc.c:896
    #2  0x0000000000928979 in freeGroup
        (p=0x7e998ce02880) at rts/sm/BlockAlloc.c:721
    #3  0x0000000000928a17 in freeChain
        (bd=0x7e998ce02880) at rts/sm/BlockAlloc.c:738
    #4  0x0000000000926911 in freeChain_sync
        (bd=0x7e998ce02880) at rts/sm/GCUtils.c:80
    #5  0x0000000000934720 in scavenge_capability_mut_lists
        (cap=0x1acae80) at rts/sm/Scav.c:1665
    #6  0x000000000092b411 in gcWorkerThread
        (cap=0x1acae80) at rts/sm/GC.c:1157
    #7  0x000000000090be9a in yieldCapability
        (pCap=0x7f9994e69e20, task=0x7e9984000b70, gcAllowed=true) at rts/Capability.c:861
    #8  0x0000000000906120 in scheduleYield
        (pcap=0x7f9994e69e50, task=0x7e9984000b70) at rts/Schedule.c:673
    #9  0x0000000000905500 in schedule
        (initialCapability=0x1acae80, task=0x7e9984000b70) at rts/Schedule.c:293
    #10 0x0000000000908d4f in scheduleWorker
        (cap=0x1acae80, task=0x7e9984000b70) at rts/Schedule.c:2554
    #11 0x000000000091a30a in workerStart
        (task=0x7e9984000b70) at rts/Task.c:444
    #12 0x00007f99937fa6db in start_thread
        (arg=0x7f9994e6a700) at pthread_create.c:463
    #13 0x000061654d59f88f in clone
        () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

    Thread 1 (Thread 32573.32573):
    #0  checkFreeListSanity
        () at rts/sm/BlockAlloc.c:887
    #1  0x0000000000928979 in freeGroup
        (p=0x7e998d303540) at rts/sm/BlockAlloc.c:721
    #2  0x0000000000926f23 in todo_block_full
        (size=513, ws=0x1aa8ce0) at rts/sm/GCUtils.c:264
    #3  0x00000000009583b9 in alloc_for_copy
        (size=513, gen_no=0) at rts/sm/Evac.c:80
    #4  0x000000000095850d in copy_tag_nolock
        (p=0x7e998c675f28, info=0x421d98 <Main_Large_con_info>, src=0x7e998d075d80, size=513,
        gen_no=0, tag=1) at rts/sm/Evac.c:153
    #5  0x0000000000959177 in evacuate
        (p=0x7e998c675f28) at rts/sm/Evac.c:715
    #6  0x0000000000932388 in scavenge_small_bitmap
        (p=0x7e998c675f28, size=1, bitmap=0) at rts/sm/Scav.c:271
    #7  0x0000000000934aaf in scavenge_stack
        (p=0x7e998c675f28, stack_end=0x7e998c676000) at rts/sm/Scav.c:1908
    #8  0x0000000000934295 in scavenge_one
        (p=0x7e998c66e000) at rts/sm/Scav.c:1466
    #9  0x0000000000934662 in scavenge_mutable_list
        (bd=0x7e998d300440, gen=0x1b1d880) at rts/sm/Scav.c:1643
    #10 0x0000000000934700 in scavenge_capability_mut_lists
        (cap=0x1aaa340) at rts/sm/Scav.c:1664
    #11 0x00000000009299b6 in GarbageCollect
        (collect_gen=0, do_heap_census=false, gc_type=2, cap=0x1aaa340, idle_cap=0x1b38aa0)
        at rts/sm/GC.c:378
    #12 0x0000000000907a4a in scheduleDoGC
        (pcap=0x7ffdec5b5310, task=0x1b36650, force_major=false) at rts/Schedule.c:1798
    #13 0x0000000000905de7 in schedule
        (initialCapability=0x1aaa340, task=0x1b36650) at rts/Schedule.c:546
    #14 0x0000000000908bc4 in scheduleWaitThread
        (tso=0x7e998c0067c8, ret=0x0, pcap=0x7ffdec5b5430) at rts/Schedule.c:2537
    #15 0x000000000091b5a0 in rts_evalLazyIO
        (cap=0x7ffdec5b5430, p=0x9c11f0, ret=0x0) at rts/RtsAPI.c:530
    #16 0x000000000091ca56 in hs_main
        (argc=1, argv=0x7ffdec5b5628, main_closure=0x9c11f0, rts_config=...) at rts/RtsMain.c:72
    #17 0x0000000000421ea0 in main
        ()

In particular, dbl_link_onto() which is used to add a freed block to a
doubly-linked free list is not thread safe and corrupts the list when
called concurrently.

Note that thread 1 is to blame here as thread 2 is properly taking the
spinlock. With this patch we now take the spinlock when freeing a todo
block in GC, avoiding this race.

Test Plan:
- Tried slow validate locally: this patch does not introduce new failures.
- circleci: https://circleci.com/gh/ghc/ghc-diffs/283 The test got killed
  because it took 5 hours but T7919 (which was previously failing on circleci)
  passed.

Reviewers: simonmar, bgamari, erikd

Reviewed By: simonmar

Subscribers: rwbarton, carter

GHC Trac Issues: #15285

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

12 months agoRemove an incorrect assertion in threadPaused:
Ömer Sinan Ağacan [Thu, 6 Sep 2018 08:39:46 +0000 (11:39 +0300)] 
Remove an incorrect assertion in threadPaused:

The assertion is triggered when we have a loop in the program (in which case we
see the same update frame multiple times in the stack). See #14915 for more
details.

Reviewers: simonmar, bgamari, erikd

Reviewed By: simonmar

Subscribers: rwbarton, carter

GHC Trac Issues: #14915

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

12 months agoPreserve specialisations despite CSE
Simon Peyton Jones [Wed, 5 Sep 2018 14:54:48 +0000 (15:54 +0100)] 
Preserve specialisations despite CSE

Trac #15445 showed that, as a result of CSE, a function with an
automatically generated specialisation RULE could be inlined
before the RULE had a chance to fire.

This patch attaches a NOINLINE[2] activation to the Id, during
CSE, to stop this happening.

See Note [Delay inlining after CSE]

---- Historical note ---

This patch is simpler and more direct than an earlier
version:

  commit 2110738b280543698407924a16ac92b6d804dc36
  Author: Simon Peyton Jones <simonpj@microsoft.com>
  Date:   Mon Jul 30 13:43:56 2018 +0100

  Don't inline functions with RULES too early

We had to revert this patch because it made GHC itself slower.

Why? It delayed inlining of /all/ functions with RULES, and that was
very bad in TcFlatten.flatten_ty_con_app

* It delayed inlining of liftM
* That delayed the unravelling of the recursion in some dictionary
  bindings.
* That delayed some eta expansion, leaving
     flatten_ty_con_app = \x y. let <stuff> in \z. blah
* That allowed the float-out pass to put sguff between
  the \y and \z.
* And that permanently stopped eta expasion of the function,
  even once <stuff> was simplified.

-- End of historical note ---

12 months agoDefine activeAfterInitial, activeDuringFinal
Simon Peyton Jones [Wed, 5 Sep 2018 14:53:15 +0000 (15:53 +0100)] 
Define activeAfterInitial, activeDuringFinal

This is pure refactoring, just adding a couple of
definitions to BasicTypes, and using them.

Plus some whitespace stuff.

12 months agoExpose 'moduleToPkgConfAll' from 'PackageState'
Alec Theriault [Wed, 5 Sep 2018 12:27:40 +0000 (14:27 +0200)] 
Expose 'moduleToPkgConfAll' from 'PackageState'

Summary:
Having direct access to this field is going to enable Haddock to
compute in batch which modules to load before looking up instances
of external packages.

Reviewers: bgamari, monoidal

Reviewed By: monoidal

Subscribers: rwbarton, carter

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

12 months agotestsuite: Use bools for booleans, not ints
Ben Gamari [Wed, 5 Sep 2018 11:45:50 +0000 (13:45 +0200)] 
testsuite: Use bools for booleans, not ints

Summary: Just as it says on the tin.

Test Plan: Validate

Reviewers: bgamari, osa1

Reviewed By: osa1

Subscribers: osa1, monoidal, rwbarton, thomie, carter

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

12 months agobase: Add references to Notes for certain special imports
Chaitanya Koparkar [Wed, 5 Sep 2018 11:41:24 +0000 (13:41 +0200)] 
base: Add references to Notes for certain special imports

Summary:
Modules like GHC.Integer, GHC.Natural etc. are special and sometimes
have to be imported just to resolve build ordering issues. It's useful
to refer to the appropriate Notes at such import sites.

Test Plan: Read it.

Reviewers: RyanGlScott, bgamari, hvr, simonpj

Reviewed By: RyanGlScott, simonpj

Subscribers: simonpj, rwbarton, carter

GHC Trac Issues: #15526

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

12 months agotestsuite: Add test for #15368
Ben Gamari [Wed, 5 Sep 2018 11:22:24 +0000 (13:22 +0200)] 
testsuite: Add test for #15368

Reviewers: bgamari, osa1

Reviewed By: osa1

Subscribers: osa1, monoidal, rwbarton, thomie, carter

GHC Trac Issues: #15368

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

12 months agoSkip eventlog tests in GHCi way
Ömer Sinan Ağacan [Wed, 5 Sep 2018 11:11:30 +0000 (13:11 +0200)] 
Skip eventlog tests in GHCi way

Summary: (GHCi doesn't generate event logs)

Test Plan:
These tests were failing in GHCi way, they're now skipped in GHCi way as GHCi
doesn't generate eventlogs

Reviewers: bgamari, simonmar, maoe, alpmestan

Reviewed By: alpmestan

Subscribers: rwbarton, carter

GHC Trac Issues: #15587

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

12 months agoFix tests ghci057 and T9293. (#15071)
roland [Tue, 4 Sep 2018 20:23:55 +0000 (22:23 +0200)] 
Fix tests ghci057 and T9293. (#15071)

Summary: As both tests specify -fno-ghci-leak-check, the GHCi :set
command is not expected to list the -fghci-leak check flag.

Test Plan: WINDOWS: make test TESTS="ghci057 T9293"

Reviewers: bgamari, monoidal

Reviewed By: monoidal

Subscribers: rwbarton, carter

GHC Trac Issues: #15071

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

12 months agotestsuite: make CHECK_API_ANNOTATIONS and CHECK_PPR overridable
Alp Mestanogullari [Tue, 4 Sep 2018 17:09:06 +0000 (19:09 +0200)] 
testsuite: make CHECK_API_ANNOTATIONS and CHECK_PPR overridable

Summary:
Without this patch, boilerplate.mk (which is included by a lot of Makefiles from
our testsuite) just assumes they reside in the usual inplace directory, which is
not friendly to hadrian and this makes a lot of tests (e.g T10255) fail when
building GHC and running the testsuite with hadrian.

With this patch, the said tests pass.

Test Plan: api annotation tests (with hadrian)

Reviewers: bgamari, monoidal

Reviewed By: monoidal

Subscribers: rwbarton, carter

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

12 months agoAdd a test for Trac #15586
Krzysztof Gogolewski [Tue, 4 Sep 2018 13:42:52 +0000 (15:42 +0200)] 
Add a test for Trac #15586

Summary: The bug is already fixed in master.

Test Plan: make test TEST=T15586

Reviewers: bgamari, simonpj

Reviewed By: simonpj

Subscribers: rwbarton, carter

GHC Trac Issues: #15586

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

12 months agoCompiler panic on invalid syntax (unterminated pragma)
roland [Tue, 4 Sep 2018 12:09:20 +0000 (14:09 +0200)] 
Compiler panic on invalid syntax (unterminated pragma)

Summary: After a parse error in OPTIONS_GHC issue an error message instead of a compiler panic.

Test Plan: make test TEST=T15053

Reviewers: Phyx, thomie, bgamari, monoidal, osa1

Reviewed By: Phyx, monoidal, osa1

Subscribers: tdammers, osa1, rwbarton, carter

GHC Trac Issues: #15053

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

12 months agoFix typos in -Wsimplifiable-class-constraints flag docs
Sergey Vinokurov [Mon, 3 Sep 2018 23:09:45 +0000 (00:09 +0100)] 
Fix typos in -Wsimplifiable-class-constraints flag docs

12 months agoRemove duplicate "since" field in glasgow_exts.rst
Josh Price [Sun, 2 Sep 2018 23:20:28 +0000 (19:20 -0400)] 
Remove duplicate "since" field in glasgow_exts.rst

12 months agocanCFunEqCan: use isTcReflexiveCo (not isTcReflCo)
Simon Peyton Jones [Mon, 3 Sep 2018 08:00:49 +0000 (09:00 +0100)] 
canCFunEqCan: use isTcReflexiveCo (not isTcReflCo)

As Trac #15577 showed, it was possible for a /homo-kinded/
constraint to trigger the /hetero-kinded/ branch of canCFunEqCan,
and that triggered an infinite loop.

The fix is easier, but there remains a deeper questions: why is
the flattener producing giant refexive coercions?

12 months agomake iToBase62's inner loop stricter in one of its arguments
Alp Mestanogullari [Sun, 2 Sep 2018 20:06:55 +0000 (22:06 +0200)] 
make iToBase62's inner loop stricter in one of its arguments

Summary:
hadrian's support for dynamic ways is currently broken (see hadrian#641 [1]).
The stage 1 GHCs that hadrian produces end up producing bad code for
the `iToBase62` function after a few optimisation passes.

In the case where `quotRem` returns (overflowError, 0),
GHC isn't careful enough to realise q is _|_ and happily inlines,
distributes and floats code around until we end up trying to access
index `minBound :: Int` of an array of 62 chars, as a result of inlining
the definition of `quotRem` for Ints, in particular the minBound branch [2].

I will separately look into reproducing the bad transformation on a small
self-contained example and filling a ticket.

[1]: https://github.com/snowleopard/hadrian/issues/641
[2]: https://git.haskell.org/ghc.git/blob/HEAD:/libraries/base/GHC/Real.hs#l366

Test Plan: fixes hadrian#641

Reviewers: bgamari, tdammers

Reviewed By: tdammers

Subscribers: tdammers, rwbarton, carter

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

12 months agoReject class instances with type families in kinds
Ryan Scott [Sun, 2 Sep 2018 20:03:53 +0000 (22:03 +0200)] 
Reject class instances with type families in kinds

Summary:
GHC doesn't know how to handle type families that appear in
class instances. Unfortunately, GHC didn't reject instances where
type families appear in //kinds//, leading to #15515. This is easily
rectified by calling `checkValidTypePat` on all arguments to a class
in an instance (and not just the type arguments).

Test Plan: make test TEST=T15515

Reviewers: bgamari, goldfire, simonpj

Reviewed By: simonpj

Subscribers: simonpj, rwbarton, carter

GHC Trac Issues: #15515

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

12 months agoRemove knot-tying bug in TcHsSyn.zonkTyVarOcc
Simon Peyton Jones [Fri, 31 Aug 2018 10:33:08 +0000 (11:33 +0100)] 
Remove knot-tying bug in TcHsSyn.zonkTyVarOcc

There was a subtle knot-tying bug in TcHsSyn.zonkTyVarOcc, revealed
in Trac #15552.

I fixed it by

* Eliminating the short-circuiting optimisation in zonkTyVarOcc,
  instead adding a finite map to get sharing of zonked unification
  variables.

  See Note [Sharing when zonking to Type] in TcHsSyn

* On the way I /added/ the short-circuiting optimisation to
  TcMType.zonkTcTyVar, which has no such problem.  This turned
  out (based on non-systematic measurements) to be a modest win.

  See Note [Sharing in zonking] in TcMType

On the way I renamed some of the functions in TcHsSyn:

* Ones ending in "X" (like zonkTcTypeToTypeX) take a ZonkEnv

* Ones that do not end in "x" (like zonkTcTypeToType), don't.
  Instead they whiz up an empty ZonkEnv.

12 months agoCommets on flatten_args_tc
Simon Peyton Jones [Thu, 30 Aug 2018 10:55:31 +0000 (11:55 +0100)] 
Commets on flatten_args_tc

12 months agoComments only
Simon Peyton Jones [Thu, 30 Aug 2018 10:54:49 +0000 (11:54 +0100)] 
Comments only

12 months agoMinor improvements to comments [skip ci]
Richard Eisenberg [Fri, 31 Aug 2018 02:33:40 +0000 (22:33 -0400)] 
Minor improvements to comments [skip ci]

12 months agofix -ddump-asm description
Alp Mestanogullari [Thu, 30 Aug 2018 18:57:17 +0000 (20:57 +0200)] 
fix -ddump-asm description

Summary: It was missing some words.

Test Plan: None (docs only)

Reviewers: bgamari, monoidal

Reviewed By: monoidal

Subscribers: rwbarton, carter

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

12 months agoA few typos [ci skip]
Gabor Greif [Thu, 30 Aug 2018 16:38:38 +0000 (18:38 +0200)] 
A few typos [ci skip]

12 months agoFix the __GLASGOW_HASKELL__ comparison
Krzysztof Gogolewski [Thu, 30 Aug 2018 13:34:39 +0000 (15:34 +0200)] 
Fix the __GLASGOW_HASKELL__ comparison

Summary:
GHC 8.4 corresponds to 804, not 840.

Found by Gabor Greif.

Test Plan: Harbormaster

Reviewers: ggreif, bgamari, mpickering

Reviewed By: ggreif

Subscribers: rwbarton, carter

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

12 months agoFinish stable split
David Feuer [Wed, 29 Aug 2018 20:34:21 +0000 (16:34 -0400)] 
Finish stable split

Long ago, the stable name table and stable pointer tables were one.
Now, they are separate, and have significantly different
implementations. I believe the time has come to finish the split
that began in #7674.

* Divide `rts/Stable` into `rts/StableName` and `rts/StablePtr`.

* Give each table its own mutex.

* Add FFI functions `hs_lock_stable_ptr_table` and
`hs_unlock_stable_ptr_table` and document them.
  These are intended to replace the previously undocumented
`hs_lock_stable_tables` and `hs_lock_stable_tables`,
  which are now documented as deprecated synonyms.

* Make `eqStableName#` use pointer equality instead of unnecessarily
comparing stable name table indices.

Reviewers: simonmar, bgamari, erikd

Reviewed By: bgamari

Subscribers: rwbarton, carter

GHC Trac Issues: #15555

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

12 months agoFix a constant folding rule
Andrey Mokhov [Wed, 29 Aug 2018 13:16:51 +0000 (15:16 +0200)] 
Fix a constant folding rule

Summary:
One of the constant folding rules introduced in D2858 is:

```
(L y :-:   v) :-: (L x :-: w) -> return $ mkL (y-x)   `add` (w `add` v)
```

Or, after removing syntactic noise: `(y - v) - (x - w) ==> (y - x) + (w + v)`.
This is incorrect, since the sign of `v` is changed from negative to positive.
As a consequence, the following program prints `3` when compiled with `-O`:

```
-- This is just subtraction in disguise
minus :: Int -> Int -> Int
minus x y = (8 - y) - (8 - x)
{-# NOINLINE minus #-}

main :: IO ()
main = print (2 `minus` 1)
```

The correct rule is: `(y - v) - (x - w) ==> (y - x) + (w - v)`.

This commit does the fix. I haven't found any other issues with the constant
folding code, but it's difficult to be certain without some automated checking.

Reviewers: bgamari, tdammers

Subscribers: hsyl20, tdammers, rwbarton, carter

GHC Trac Issues: #15569

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

12 months agoFixed typo in exponent example
chris-bacon [Mon, 27 Aug 2018 12:45:47 +0000 (13:45 +0100)] 
Fixed typo in exponent example

12 months agoRename kind vars in left-to-right order in bindHsQTyVars
Ryan Scott [Tue, 28 Aug 2018 20:58:52 +0000 (22:58 +0200)] 
Rename kind vars in left-to-right order in bindHsQTyVars

Summary:
When renaming kind variables in an `LHsQTyVars`, we were
erroneously putting all of the kind variables in the binders
//after// the kind variables in the body, resulting in #15568. The
fix is simple: just swap the order of these two around.

Test Plan: make test TEST=T15568

Reviewers: simonpj, bgamari, goldfire

Reviewed By: goldfire

Subscribers: goldfire, rwbarton, carter

GHC Trac Issues: #15568

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

12 months agoFix typo in 8.6.1 notes
Krzysztof Gogolewski [Tue, 28 Aug 2018 20:31:22 +0000 (22:31 +0200)] 
Fix typo in 8.6.1 notes

12 months agoFix #15572 by checking for promoted names in ConT
Ryan Scott [Tue, 28 Aug 2018 18:54:28 +0000 (20:54 +0200)] 
Fix #15572 by checking for promoted names in ConT

Summary:
When converting `ConT`s to `HsTyVar`s in `Convert`, we were
failing to account for the possibility of promoted data constructor
names appearing in a `ConT`, which could result in improper
pretty-printing results (as observed in #15572). The fix is
straightforward: use `Promoted` instead of `NotPromoted` when the
name of a `ConT` is a data constructor name.

Test Plan: make test TEST=T15572

Reviewers: goldfire, bgamari, simonpj, monoidal

Reviewed By: goldfire, simonpj

Subscribers: monoidal, rwbarton, carter

GHC Trac Issues: #15572

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

12 months agoRemove dead code for commandline parsing
Krzysztof Gogolewski [Tue, 28 Aug 2018 10:52:47 +0000 (12:52 +0200)] 
Remove dead code for commandline parsing

Summary:
PrefixPred and AnySuffixPred are not used
since static flags were removed in bbd3c399939.

Test Plan: validate

Reviewers: bgamari, tdammers

Reviewed By: tdammers

Subscribers: rwbarton, carter

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

12 months agorts: Handle SMALL_MUT_ARR_PTRS in retainer profilter
Ben Gamari [Mon, 27 Aug 2018 22:59:17 +0000 (00:59 +0200)] 
rts: Handle SMALL_MUT_ARR_PTRS in retainer profilter

Summary: These can be treated similarly to MUT_ARRY_PTRS. Fixes #15529.

Reviewers: erikd, simonmar

Reviewed By: simonmar

Subscribers: RyanGlScott, rwbarton, carter

GHC Trac Issues: #15529

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

12 months agoRemove dph, vector, primitive and random from .gitmodules
Chaitanya Koparkar [Mon, 27 Aug 2018 15:19:57 +0000 (17:19 +0200)] 
Remove dph, vector, primitive and random from .gitmodules

Summary:
These packages were removed from the GHC source tree in
Phab:D4761 and 0905fec089b3270f540c7ee33959cbf8ecfcb4d7.

Reviewers: RyanGlScott, bgamari

Reviewed By: RyanGlScott

Subscribers: rwbarton, carter

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

12 months agoBump nofib submodule
Krzysztof Gogolewski [Mon, 27 Aug 2018 14:39:13 +0000 (16:39 +0200)] 
Bump nofib submodule

12 months agoFix #10859 by using foldr1 while deriving Eq instances
Chaitanya Koparkar [Mon, 27 Aug 2018 12:07:08 +0000 (14:07 +0200)] 
Fix #10859 by using foldr1 while deriving Eq instances

Summary:
Previously, we were using foldl1 instead, which led to the derived
code to be wrongly associated.

Test Plan: ./validate

Reviewers: RyanGlScott, nomeata, simonpj, bgamari

Reviewed By: RyanGlScott, nomeata

Subscribers: rwbarton, carter

GHC Trac Issues: #10859

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

12 months agoDon't reify redundant class method tyvars/contexts
Ryan Scott [Mon, 27 Aug 2018 12:06:17 +0000 (14:06 +0200)] 
Don't reify redundant class method tyvars/contexts

Summary:
Currently, reifying classes produces class methods with
redundant tyvars and class contexts in their type signatures, such
as in the following:

```lang=haskell
class C a where
  method :: forall a. C a => a
```

Fixing this is very straightforward: just apply `tcSplitMethodTy` to
the type of each class method to lop off the redundant parts.

It's possible that this could break some TH code in the wild that
assumes the existence of these tyvars and class contexts, so I'll
advertise this change in the release notes just to be safe.

Test Plan: make test TEST="TH_reifyDecl1 T9064 T10891 T14888"

Reviewers: goldfire, bgamari, simonpj

Reviewed By: simonpj

Subscribers: simonpj, rwbarton, carter

GHC Trac Issues: #15551

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

12 months agoTake strict fields into account in coverage checking
Ryan Scott [Mon, 27 Aug 2018 12:05:45 +0000 (14:05 +0200)] 
Take strict fields into account in coverage checking

Summary:
The current pattern-match coverage checker implements the
formalism presented in the //GADTs Meet Their Match// paper in a
fairly faithful matter. However, it was discovered recently that
there is a class of unreachable patterns that
//GADTs Meet Their Match// does not handle: unreachable code due to
strict argument types, as demonstrated in #15305. This patch
therefore goes off-script a little and implements an extension to
the formalism presented in the paper to handle this case.

Essentially, when determining if each constructor can be matched on,
GHC checks if its associated term and type constraints are
satisfiable. This patch introduces a new form of constraint,
`NonVoid(ty)`, and checks if each constructor's strict argument types
satisfy `NonVoid`. If any of them do not, then that constructor is
deemed uninhabitable, and thus cannot be matched on. For the full
story of how this works, see
`Note [Extensions to GADTs Meet Their Match]`.

Along the way, I did a little bit of much-needed refactoring. In
particular, several functions in `Check` were passing a triple of
`(ValAbs, ComplexEq, Bag EvVar)` around to represent a constructor
and its constraints. Now that we're adding yet another form of
constraint to the mix, I thought it appropriate to turn this into
a proper data type, which I call `InhabitationCandidate`.

Test Plan: make test TEST=T15305

Reviewers: simonpj, bgamari

Reviewed By: simonpj

Subscribers: rwbarton, carter

GHC Trac Issues: #15305

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

12 months agoFix #15502 by not casting to Int during TH conversion
Ryan Scott [Mon, 27 Aug 2018 12:02:49 +0000 (14:02 +0200)] 
Fix #15502 by not casting to Int during TH conversion

Summary:
When turning an `IntegerL` to an `IntegralLit` during TH
conversion, we were stupidly casting an `Integer` to an `Int` in
order to determine how it should be pretty-printed. Unsurprisingly,
this causes problems when the `Integer` doesn't lie within the bounds
of an `Int`, as demonstrated in #15502.

The fix is simple: don't cast to an `Int`.

Test Plan: make test TEST=T15502

Reviewers: bgamari, simonpj

Reviewed By: simonpj

Subscribers: simonpj, rwbarton, carter

GHC Trac Issues: #15502

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

12 months agoFix #15550 by quoting RULE names during TH conversion
Ryan Scott [Mon, 27 Aug 2018 12:02:42 +0000 (14:02 +0200)] 
Fix #15550 by quoting RULE names during TH conversion

Summary:
When converting a `RuleP` to a GHC source `RuleD` during TH
conversion, we were stupidly not double-quoting the name of the rule.
Easily fixed.

Test Plan: make test TEST=T15550

Reviewers: goldfire, bgamari, simonpj

Reviewed By: simonpj

Subscribers: simonpj, rwbarton, carter

GHC Trac Issues: #15550

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

12 months agoghc, ghc-pkg: use getExecutablePath on Windows when base >= 4.11.0
Tamar Christina [Sat, 11 Aug 2018 18:25:09 +0000 (19:25 +0100)] 
ghc, ghc-pkg: use getExecutablePath on Windows when base >= 4.11.0

Summary:
This completes the work started in D4227 by using just 'getExecutablePath'
in ghc and ghc-pkg when building with base >= 4.11.0.

On the long term, we will be able to simply kill the existing code that
follows (or not) symlinks and just get this behaviour for free from
getExecutable. For now we however have to require base >= 4.11.0 to be able
to just use getExecutablePath under Windows, and use the current code when
building with an older base.

Original code by @alpmestan commandeering since patch has been stale
and bug remains open.

Test Plan: Validate

Reviewers: angerman, bgamari, erikd, alpmestan

Reviewed By: bgamari

Subscribers: carter, rwbarton, thomie

GHC Trac Issues: #14483

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

12 months agoBetter error reporting for inaccessible code
Simon Peyton Jones [Fri, 24 Aug 2018 15:40:28 +0000 (16:40 +0100)] 
Better error reporting for inaccessible code

This patch fixes Trac #15558.  There turned out to be
two distinct problems

* In TcExpr.tc_poly_expr_nc we had

    tc_poly_expr_nc (L loc expr) res_ty
      = do { traceTc "tcPolyExprNC" (ppr res_ty)
           ; (wrap, expr')
               <- tcSkolemiseET GenSigCtxt res_ty $ \ res_ty ->
                  setSrcSpan loc $
                    -- NB: setSrcSpan *after* skolemising,
                    -- so we get better skolem locations
                  tcExpr expr res_ty

  Putting the setSrcSpan inside the tcSkolemise means that
  the location on the Implication constraint is the /call/
  to the function rather than the /argument/ to the call,
  and that is really quite wrong.

  I don't know what Richard's comment NB means -- I moved the
  setSrcSpan outside, and the "binding site" info in error
  messages actually improved.

  The reason I found this is that it affects the span reported
  for Trac #15558.

* In TcErrors.mkGivenErrorReporter we carefully munge the location
  for an insoluble Given constraint (Note [Inaccessible code]).
  But the 'implic' passed in wasn't necesarily the immediately-
  enclosing implication -- but for location-munging purposes
  it jolly well should be.

  Solution: use the innermost implication. This actually
  simplifies the code -- no need to pass an implication in to
  mkGivenErrorReporter.

12 months agoAdd comments about pretty-printing via IfaceSyn
Simon Peyton Jones [Fri, 24 Aug 2018 09:29:58 +0000 (10:29 +0100)] 
Add comments about pretty-printing via IfaceSyn

Provoked by discussion on Phab:D5097 (Trac #15546), I'm adding
a big Note explaing the strategy of pretty-printing via IfaceSyn

12 months agoComments only
Simon Peyton Jones [Fri, 24 Aug 2018 09:29:40 +0000 (10:29 +0100)] 
Comments only

12 months agoClean up TcHsSyn.zonkEnv
Simon Peyton Jones [Fri, 24 Aug 2018 07:14:15 +0000 (08:14 +0100)] 
Clean up TcHsSyn.zonkEnv

Triggered by Trac #15552, I'd been looking at ZonkEnv in TcHsSyn.

This patch does some minor refactoring

* Make ZonkEnv into a record with named fields, and use them.
  (I'm planning to add a new field, for TyCons, so this prepares
  the way.)

* Replace UnboundTyVarZonker (a higer order function) with the
  simpler and more self-descriptive ZonkFlexi data type, below.
 It's just much more perspicuous and direct, and (I suspect)
 a tiny bit faster too -- no unknown function calls.

data ZonkFlexi   -- See Note [Un-unified unification variables]
  = DefaultFlexi    -- Default unbound unificaiton variables to Any
  | SkolemiseFlexi  -- Skolemise unbound unification variables
                    -- See Note [Zonking the LHS of a RULE]
  | RuntimeUnkFlexi -- Used in the GHCi debugger

There was one knock-on effect in the GHCi debugger -- the
RuntimeUnkFlexi case.  Somehow previously, these RuntimeUnk
variables were sometimes getting SystemNames (and hence
printed as 'a0', 'a1', etc) and sometimes not (and hence
printed as 'a', 'b' etc).  I'm not sure precisely why, but
the new behaviour seems more uniform, so I just accepted the
(small) renaming wibbles in some ghci.debugger tests.

I had a quick look at perf: any changes are tiny.

12 months agoUpdate unicode tables to v. 12 of the standard
Artem Pelenitsyn [Tue, 21 Aug 2018 23:33:35 +0000 (19:33 -0400)] 
Update unicode tables to v. 12 of the standard

Reviewers: hvr, bgamari, Azel

Reviewed By: bgamari

Subscribers: thomie, Azel, rwbarton, carter

GHC Trac Issues: #5518, #15525

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

12 months agodocs: Add changelog and release notes entry for traceBinaryEvent#
Ben Gamari [Tue, 21 Aug 2018 23:08:12 +0000 (19:08 -0400)] 
docs: Add changelog and release notes entry for traceBinaryEvent#

12 months agoTcSimplify: Condense MASSERT2() usage onto a single line
Ben Gamari [Fri, 24 Aug 2018 02:39:06 +0000 (22:39 -0400)] 
TcSimplify: Condense MASSERT2() usage onto a single line

Sadly macOS's C preprocessor gets angry at the sight of multi-line macro
invocations.

12 months agoAccommodate API change in transSuperClasses
Simon Peyton Jones [Thu, 23 Aug 2018 08:22:42 +0000 (09:22 +0100)] 
Accommodate API change in transSuperClasses

In this patch

    commit 6eabb6ddb7c53784792ee26b1e0657bde7eee7fb
    Author: Simon Peyton Jones <simonpj@microsoft.com>
    Date:   Tue Dec 15 14:26:13 2015 +0000

    Allow recursive (undecidable) superclasses

I changed (transSuperClasses p) to return only the
superclasses of p, but not p itself. (Previously it always
returned p as well.)

The use of transSuperClasses in TcErrors.warnRedundantConstraints
really needs 'p' in the result -- but I faild to fix this
call site, and instead crippled the test for Trac #10100.

This patch sets things right

* Accomodates the API change
* Re-enables T10100
* And thereby fixes Trac #11474

12 months agoComments only
Simon Peyton Jones [Wed, 22 Aug 2018 09:04:08 +0000 (10:04 +0100)] 
Comments only

12 months agoFix a typo in TcValidity.checkFamInstRhs
Simon Peyton Jones [Wed, 22 Aug 2018 09:00:20 +0000 (10:00 +0100)] 
Fix a typo in TcValidity.checkFamInstRhs

In error message generation we were using the wrong
type constructor in inst_head.  Result: the type became
ill-kinded, and that sent the compiler into a loop.

A separate patch fixes the loop. This patch fixes the
actual bug -- Trac #15473.

I also improved the "occurs more often" error message
a bit.  But it's still pretty terrible:

    * Variable ‘a’ occurs more often
      in the type family application ‘Undefined’
      than in the instance head ‘LetInterleave xs t ts is y z’

It looks like nonsense, but all becomes clear if you use
-fprint-explicit-kinds.  Really we should fix this by spotting
when invisible arguments are involved and at least suggesting
-fprint-explicit-kinds.

12 months agoTurn infinite loop into a panic
Simon Peyton Jones [Wed, 22 Aug 2018 08:51:26 +0000 (09:51 +0100)] 
Turn infinite loop into a panic

In these two functions
  * TcIface.toIfaceAppTyArgsX
  * Type.piResultTys
we take a type application (f t1 .. tn) and try to find
its kind. It turned out that, if (f t1 .. tn) was ill-kinded
the function would go into an infinite loop.

That's not good: it caused the loop in Trac #15473.

This patch doesn't fix the bug in #15473, but it does turn the
loop into a decent panic, which is a step forward.

12 months agoRevert "driver: unconditionally disable relaxation when linking partially"
Ryan Scott [Wed, 22 Aug 2018 13:19:42 +0000 (09:19 -0400)] 
Revert "driver: unconditionally disable relaxation when linking partially"

This reverts commit 1cc9061fce4270739677d475190fd6e890e8b1f9.

This appears to break a clean build with certain versions of
`ld.gold`. See
https://phabricator.haskell.org/rGHC1cc9061fce42#132967.

12 months agoRevert "Properly tag fun field of PAPs generated by ap_0_fast"
Ömer Sinan Ağacan [Wed, 22 Aug 2018 05:52:50 +0000 (08:52 +0300)] 
Revert "Properly tag fun field of PAPs generated by ap_0_fast"

This reverts commit 2693eb11f55f2001701c90c24183e21c794a8be1.

This patch isn't ready yet, see D5051.

12 months agoAdd traceBinaryEvent# primop
Mitsutoshi Aoe [Tue, 21 Aug 2018 20:08:17 +0000 (16:08 -0400)] 
Add traceBinaryEvent# primop

This adds a new primop called traceBinaryEvent# that takes the length
of binary data and a pointer to the data, then emits it to the eventlog.

There is some example code that uses this primop and the new event:

* [traceBinaryEventIO][1] that calls `traceBinaryEvent#`

* [A patch to ghc-events][2] that parses the new `EVENT_USER_BINARY_MSG`

There's no corresponding issue on Trac but it was discussed at
ghc-devs [3].

[1] https://github.com/maoe/ghc-trace-events/blob
    /fb226011ef1f85a97b4da7cc9d5f98f9fe6316ae/src/Debug/Trace/Binary.hs#L29)
[2] https://github.com/maoe/ghc-events/commit
    /239ca77c24d18cdd10d6d85a0aef98e4a7c56ae6)
[3] https://mail.haskell.org/pipermail/ghc-devs/2018-May/015791.html

Reviewers: bgamari, erikd, simonmar

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

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

12 months agodocs: "state transformer" -> "state monad" / "ST" (whichever is meant)
Artem Pelenitsyn [Tue, 21 Aug 2018 20:07:39 +0000 (16:07 -0400)] 
docs: "state transformer" -> "state monad" / "ST" (whichever is meant)

FIxes #15189.

Reviewers: hvr, bgamari, simonmar, simonpj

Reviewed By: simonpj

Subscribers: simonpj, rwbarton, thomie, carter

GHC Trac Issues: #15189

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

12 months agoFix precision of asinh/acosh/atanh by making them primops
Artem Pelenitsyn [Tue, 21 Aug 2018 20:07:24 +0000 (16:07 -0400)] 
Fix precision of asinh/acosh/atanh by making them primops

Reviewers: hvr, bgamari, simonmar, jrtc27

Reviewed By: bgamari

Subscribers: alpmestan, rwbarton, thomie, carter

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

12 months agoCorrect limb length and assertion for gcdExtInteger
DavidEichamnn [Tue, 21 Aug 2018 20:06:45 +0000 (16:06 -0400)] 
Correct limb length and assertion for gcdExtInteger

Reviewers: hvr, bgamari, monoidal

Reviewed By: monoidal

Subscribers: monoidal, rwbarton, thomie, carter

GHC Trac Issues: #15350

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

12 months agoProperly tag fun field of PAPs generated by ap_0_fast
Ömer Sinan Ağacan [Tue, 21 Aug 2018 20:06:29 +0000 (16:06 -0400)] 
Properly tag fun field of PAPs generated by ap_0_fast

Currently ap_0_fast doesn't maintain the invariant for PAP fun fields
which says if the closure can be tagged, it should be. This is checked
by `Sanity.c:checkPAP` and correctly implemented by `genautoapply`.

This causes sanity check failures when we have a profiling code like

    f = {-# SCC scc #-} g

where g is a PAP or a FUN, and `scc` is different than the current cost
centre.

Test Plan: Slow validate (not done yet)

Reviewers: simonmar, bgamari, erikd

Reviewed By: simonmar

Subscribers: rwbarton, carter

GHC Trac Issues: #15508

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

12 months agorts: Align the_gc_thread to 64 bytes
Ben Gamari [Tue, 21 Aug 2018 20:06:12 +0000 (16:06 -0400)] 
rts: Align the_gc_thread to 64 bytes

In a previous attempt (c6cc93bca69abc258513af8cf2370b14e70fd8fb) I had
tried aligning to 8 bytes under the assumption that the problem was that
the_gc_thread, a StgWord8[], wasn't being aligned to 8-bytes as the
gc_thread struct would expect. However, we actually need even stronger
alignment due to the alignment attribute attached to gen_workspace,
which claims it should be aligned to a 64-byte boundary.

This fixes #15482.

Reviewers: erikd, simonmar

Reviewed By: simonmar

Subscribers: rwbarton, carter

GHC Trac Issues: #15482

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

12 months agoShow -with-rtsopts options in runtime's --info (#15261)
roland [Tue, 21 Aug 2018 20:05:45 +0000 (16:05 -0400)] 
Show -with-rtsopts options in runtime's --info (#15261)

Add an additional line to the output of +RTS --info.  It shows the value
of the flag -with-rtsopts provided at compile/link time.

Test Plan: make test TESTS="T15261a T15261b"

Reviewers: hvr, erikd, dfeuer, thomie, austin, bgamari, simonmar, osa1,
monoidal

Reviewed By: osa1, monoidal

Subscribers: osa1, rwbarton, carter

GHC Trac Issues: #15261

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

12 months agoFix ambiguous/out-of-scope Haddock identifiers
Alec Theriault [Tue, 21 Aug 2018 20:05:16 +0000 (16:05 -0400)] 
Fix ambiguous/out-of-scope Haddock identifiers

This drastically cuts down on the number of Haddock warnings when making
docs for `base`.  Plus this means more actual links end up in the docs!
Also fixed other small mostly markup issues in the documentation along
the way.

This is a docs-only change.

Reviewers: hvr, bgamari, thomie

Reviewed By: thomie

Subscribers: thomie, rwbarton, carter

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