ghc.git
22 months agoFix a TyVar bug in the flattener
Simon Peyton Jones [Tue, 14 Nov 2017 09:16:22 +0000 (09:16 +0000)] 
Fix a TyVar bug in the flattener

A year ago I gave up on trying to rigorously separate TyVars
from TcTyVars, and instead allowed TyVars to appear rather more
freely in types examined by the constraint solver:

   commit 18d0bdd3848201882bae167e3b15fd797d217e93
   Author: Simon Peyton Jones <simonpj@microsoft.com>
   Date:   Wed Nov 23 16:00:00 2016 +0000

   Allow TyVars in TcTypes

See Note [TcTyVars in the typechecker] in TcType.

However, TcFlatten.flatten_tyvar1 turned out to treat
a TyVar specially, and implicitly assumed that it could
not have an equality constraint in the inert set.  Wrong!

This caused Trac #14450.  Fortunately it is easily fixed,
by deleting code.

22 months agoWIP on combined Step 1 and 3 for Trees That Grow, HsExpr
Alan Zimmerman [Thu, 9 Nov 2017 21:20:19 +0000 (23:20 +0200)] 
WIP on combined Step 1 and 3 for Trees That Grow, HsExpr

See https://ghc.haskell.org/trac/ghc/wiki/ImplementingTreesThatGrow

Trees that grow extension points are added for
- HsExpr

Updates haddock submodule

Test Plan: ./validate

Reviewers: bgamari, goldfire

Subscribers: rwbarton, thomie, shayan-najd, mpickering

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

22 months agoDeclare proper spec version in `base.cabal`
Herbert Valerio Riedel [Sat, 11 Nov 2017 16:40:15 +0000 (17:40 +0100)] 
Declare proper spec version in `base.cabal`

This is a follow-up to ba2ae2c8729d5aef2aeb7fb32d6c0ea2a465ea25
which started relying on a new Cabal feature requiring the
the cabal spec version declaration to be updated accordingly.

22 months agocircleci: Bump down thread count
Ben Gamari [Sat, 11 Nov 2017 16:45:37 +0000 (11:45 -0500)] 
circleci: Bump down thread count

It appears that our jobs generally run on VMs with 2 vCPUs. Consequently running
with 8 jobs will completely oversubscribe the machine. I suspect this is the
cause of #14453. Let's bump this down to 3 for now. Ideally we would determine
this from the environment.

22 months agoUse LICENSE instead of ../LICENSE in the compiler.cabal file
Moritz Angermann [Sat, 11 Nov 2017 15:56:10 +0000 (10:56 -0500)] 
Use LICENSE instead of ../LICENSE in the compiler.cabal file

Reviewers: bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

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

22 months agoAdds cmm-sources to base
Moritz Angermann [Sat, 11 Nov 2017 15:55:51 +0000 (10:55 -0500)] 
Adds cmm-sources to base

Bumps Cabal submodule.

Reviewers: bgamari, hvr

Reviewed By: bgamari

Subscribers: rwbarton, thomie

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

22 months agoWindows: Bump to GCC 7.2 for GHC 8.4
Tamar Christina [Sat, 11 Nov 2017 15:55:31 +0000 (10:55 -0500)] 
Windows: Bump to GCC 7.2 for GHC 8.4

GHC 8.4 is expected to ship with an updated GCC bindist based on GCC
7.2.

I am however at this time not updating the crt due to an issue
introduced in September.
https://sourceforge.net/p/mingw-w64/mailman/message/36085637/

Unless a favorable fix comes out of the discussion I will just ship the
old crt with GHC 8.4.

Test Plan: ./validate

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: thomie, rwbarton

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

22 months agoMerge commit '5229c43ccf77bcbffeced01dccb27398d017fa34'
Ben Gamari [Fri, 10 Nov 2017 14:28:36 +0000 (09:28 -0500)] 
Merge commit '5229c43ccf77bcbffeced01dccb27398d017fa34'

22 months agoSquashed 'hadrian/' changes from 438dc576e7..5ebb69ae1e
Ben Gamari [Fri, 10 Nov 2017 14:28:36 +0000 (09:28 -0500)] 
Squashed 'hadrian/' changes from 438dc576e7..5ebb69ae1e

5ebb69ae1e Drop GccLtXX flags, require GCC > 4.7 and up (#450)

git-subtree-dir: hadrian
git-subtree-split: 5ebb69ae1eb063f25c59383bffb3b5449015c6f9

22 months agoFix PPC NCG after blockID patch
Peter Trommler [Thu, 9 Nov 2017 22:55:01 +0000 (17:55 -0500)] 
Fix PPC NCG after blockID patch

Commit rGHC8b007ab assigns the same label to the first basic block
of a proc and to the proc entry point. This violates the PPC 64-bit ELF
v. 1.9 and v. 2.0 ABIs and leads to duplicate symbols.

This patch fixes duplicate symbols caused by block labels

In commit rGHCd7b8da1 an info table label is generated from a block id.
Getting the entry label from that info label leads to an undefined
symbol because a suffix "_entry" that is not present in the block label.

To fix that issue add a new info table label flavour for labels
derived from block ids. Converting such a label with toEntryLabel
produces the original block label.

Fixes #14311

Test Plan: ./validate

Reviewers: austin, bgamari, simonmar, erikd, hvr, angerman

Reviewed By: bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #14311

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

22 months agoChange `OPTIONS_GHC -O` to `OPTIONS_GHC -O2`
Douglas Wilson [Thu, 9 Nov 2017 22:54:45 +0000 (17:54 -0500)] 
Change `OPTIONS_GHC -O` to `OPTIONS_GHC -O2`

These pragmas were having the perverse effect of having these
performance critical modules be LESS optimized in builds with -O2.

Test Plan: Check on gipedia whether this is worthwhile.

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

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

22 months agotestsuite: Add test for #5889
Douglas Wilson [Thu, 9 Nov 2017 22:54:28 +0000 (17:54 -0500)] 
testsuite: Add test for #5889

Test Plan: make test TEST=5889

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #5889

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

22 months agoRemove unreliable Core Lint empty case checks
David Feuer [Thu, 9 Nov 2017 22:54:11 +0000 (17:54 -0500)] 
Remove unreliable Core Lint empty case checks

Trac #13990 shows that the Core Lint checks for empty case are
unreliable, and very hard to make reliable. The consensus (among
simonpj, nomeata, and goldfire) seems to be that they should be
removed altogether. Do that.

Add test

Reviewers: goldfire, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #13990

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

22 months agoUpdate comment in GHC.Real (trac#14432)
Bodigrim [Thu, 9 Nov 2017 22:53:57 +0000 (17:53 -0500)] 
Update comment in GHC.Real (trac#14432)

Reviewers: hvr, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #14432

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

22 months agobase: Fix #14425
Ben Gamari [Thu, 9 Nov 2017 22:53:39 +0000 (17:53 -0500)] 
base: Fix #14425

Test Plan: Validate

Reviewers: hvr

Subscribers: rwbarton, thomie

GHC Trac Issues: #14425

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

22 months agobase: Normalize style of approxRational
Ben Gamari [Thu, 9 Nov 2017 22:53:24 +0000 (17:53 -0500)] 
base: Normalize style of approxRational

Stumbled upon this odd bit of style while looking at #14425. Usually I
don't like to do this sort of reformatting, but this seemed like it
would be necessary in the course fo fixing #14425.

Reviewers: hvr

Subscribers: rwbarton, thomie

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

22 months agobase: Add test for #14425
Ben Gamari [Thu, 9 Nov 2017 22:52:26 +0000 (17:52 -0500)] 
base: Add test for #14425

Test Plan: Validate

Reviewers: hvr

Subscribers: rwbarton, thomie

GHC Trac Issues: #14425

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

22 months agoMerge initial Hadrian snapshot
Ben Gamari [Thu, 9 Nov 2017 22:50:42 +0000 (17:50 -0500)] 
Merge initial Hadrian snapshot

We will continue to pull in squashed snapshots periodically until we
eventually discontinue development in Hadrian's GitHub repository.

22 months agoUpdate Win32 version for GHC 8.4.
Tamar Christina [Wed, 8 Nov 2017 06:21:16 +0000 (01:21 -0500)] 
Update Win32 version for GHC 8.4.

Update to Win32 2.6 which is the expected version release for 8.4

This involves moving Cabal forward which brings some backwards incompatible
changes that needs various fixups.

Bump a bunch of submodules

Test Plan: ./validate

Reviewers: austin, bgamari, angerman

Reviewed By: bgamari, angerman

Subscribers: angerman, thomie, rwbarton

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

22 months agotestsuite: Fix output of T14394
Ben Gamari [Thu, 9 Nov 2017 22:07:53 +0000 (17:07 -0500)] 
testsuite: Fix output of T14394

22 months agoRemove left-overs from compareByteArray# inline conversion
Herbert Valerio Riedel [Wed, 8 Nov 2017 23:38:53 +0000 (00:38 +0100)] 
Remove left-overs from compareByteArray# inline conversion

These removes left-overs from e3ba26f8b49700b41ff4672f3f7f6a4e453acdcc
where I implemented `compareByteArray#` as an out-of-line primop, which
got optimised into an inline primop shortly afterwards
(as per 7673561555ae354fd9eed8de1e57c681906e2d49).

22 months agoInvoke lintUnfolding only on top-level unfoldings (#14430)
Joachim Breitner [Wed, 8 Nov 2017 03:17:50 +0000 (22:17 -0500)] 
Invoke lintUnfolding only on top-level unfoldings (#14430)

as nested unfoldings are linted together with the top-level unfolding,
and lintUnfolding does the wrong things for nestd unfoldings that
mention join points.

The easiest way of doing that was to pass a TopLevel flag through
`tcUnfolding`, which is invoked both for top level and nested
unfoldings.

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

22 months agoWIP on Doing a combined Step 1 and 3 for Trees That Grow
Alan Zimmerman [Sun, 5 Nov 2017 19:49:11 +0000 (21:49 +0200)] 
WIP on Doing a combined Step 1 and 3 for Trees That Grow

See https://ghc.haskell.org/trac/ghc/wiki/ImplementingTreesThatGrow

Trees that grow extension points are added for
- ValBinds
- HsPat
- HsLit
- HsOverLit
- HsType
- HsTyVarBndr
- HsAppType
- FieldOcc
- AmbiguousFieldOcc

Updates haddock submodule

Test Plan: ./validate

Reviewers: shayan-najd, simonpj, austin, goldfire, bgamari

Subscribers: goldfire, rwbarton, thomie, mpickering

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

22 months agoFix in-scope set in simplifier
Simon Peyton Jones [Wed, 8 Nov 2017 11:09:33 +0000 (11:09 +0000)] 
Fix in-scope set in simplifier

This patch fixes Trac #14408.  The problem was that the StaticEnv
field of an ApplyToVar or Select continuation didn't have enough
variables in scope.  The fix is simple, and I documented the
invariant in Note [StaticEnv invariant] in SimplUtils.

No change in behaviour: this just stops an ASSERT from tripping.

22 months agoMinimise provided dictionaries in pattern synonyms
Simon Peyton Jones [Wed, 8 Nov 2017 08:52:06 +0000 (08:52 +0000)] 
Minimise provided dictionaries in pattern synonyms

Trac #14394 showed that it's possible to get redundant
constraints in the inferred provided constraints of a pattern
synonym.  This patch removes the redundancy with mkMinimalBySCs.

To do this I had to generalise the type of mkMinimalBySCs slightly.
And, to reduce confusing reversal, I made it stable: it now returns
its result in the same order as its input.  That led to a raft of
error message wibbles, mostly for the better.

22 months agoFix another dark corner in the shortcut solver
Simon Peyton Jones [Wed, 8 Nov 2017 08:45:53 +0000 (08:45 +0000)] 
Fix another dark corner in the shortcut solver

The shortcut solver for type classes (Trac #12791) was eagerly
solving a constaint from an OVERLAPPABLE instance. It happened
to be the only one in scope, so it was unique, but since it's
specfically flagged as overlappable it's really a bad idea to
solve using it, rather than using the Given dictionary.

This led to Trac #14434, a nasty and hard to identify bug.

22 months agoImrpove comments about equality types
Simon Peyton Jones [Wed, 8 Nov 2017 08:23:53 +0000 (08:23 +0000)] 
Imrpove comments about equality types

22 months agoMerge remote-tracking branch 'github/pr/83'
Ben Gamari [Wed, 8 Nov 2017 06:18:44 +0000 (01:18 -0500)] 
Merge remote-tracking branch 'github/pr/83'

22 months agobase: Escape \ in CallStack example
Chris Martin [Tue, 7 Nov 2017 02:18:49 +0000 (21:18 -0500)] 
base: Escape \ in CallStack example

[skip ci]

22 months agoUpdate link to Haskeline user preferences
Taylor Fausak [Tue, 7 Nov 2017 04:21:19 +0000 (22:21 -0600)] 
Update link to Haskeline user preferences

Unfortunately trac.haskell.org doesn't exist anymore.

[skip ci]

22 months agoRevert "WIP on combining Step 1 and 3 of Trees That Grow"
Ben Gamari [Tue, 7 Nov 2017 16:50:36 +0000 (11:50 -0500)] 
Revert "WIP on combining Step 1 and 3 of Trees That Grow"

This reverts commit 0ff152c9e633accca48815e26e59d1af1fe44ceb.

Sadly this broke when bootstrapping with 8.0.2 due to #14396.

Reverts haddock submodule.

22 months agorelnotes: Note enabling of -fllvm-pass-vectorse-in-regs
Ben Gamari [Tue, 7 Nov 2017 14:58:59 +0000 (09:58 -0500)] 
relnotes: Note enabling of -fllvm-pass-vectorse-in-regs

[skip ci]

22 months agorelnotes: Clarify a few things
Ben Gamari [Tue, 7 Nov 2017 14:55:02 +0000 (09:55 -0500)] 
relnotes: Clarify a few things

[skip ci]

22 months agotestsuite: Bump haddock.compiler allocations
Ben Gamari [Tue, 7 Nov 2017 14:02:39 +0000 (09:02 -0500)] 
testsuite: Bump haddock.compiler allocations

This is due to alanz's recent trees that grow patch, almost certainly because of
the increased surface area of libghc.

22 months agoFactor out builds into steps. Address ghc/ghc#83 comments.
Mateusz Kowalczyk [Tue, 7 Nov 2017 10:52:38 +0000 (10:52 +0000)] 
Factor out builds into steps. Address ghc/ghc#83 comments.

This should greatly improve log output.

22 months agoRevert "Sdist -> bindist -> tests"
Mateusz Kowalczyk [Thu, 2 Nov 2017 11:15:11 +0000 (11:15 +0000)] 
Revert "Sdist -> bindist -> tests"

This reverts commit e1d38d6f7decee1e513d44bb3bce08bd004bfa4d.

22 months agoSdist -> bindist -> tests
Mateusz Kowalczyk [Fri, 27 Oct 2017 18:02:33 +0000 (19:02 +0100)] 
Sdist -> bindist -> tests

22 months agoSet up AppVeyor, Windows CI.
Mateusz Kowalczyk [Fri, 27 Oct 2017 13:28:43 +0000 (14:28 +0100)] 
Set up AppVeyor, Windows CI.

22 months agoSet up Linux, OSX and FreeBSD on CircleCI.
Mateusz Kowalczyk [Fri, 27 Oct 2017 17:14:06 +0000 (18:14 +0100)] 
Set up Linux, OSX and FreeBSD on CircleCI.

22 months agoWIP on combining Step 1 and 3 of Trees That Grow
Alan Zimmerman [Sun, 5 Nov 2017 19:49:11 +0000 (21:49 +0200)] 
WIP on combining Step 1 and 3 of Trees That Grow

See https://ghc.haskell.org/trac/ghc/wiki/ImplementingTreesThatGrow

Trees that grow extension points are added for
- ValBinds
- HsPat
- HsLit
- HsOverLit
- HsType
- HsTyVarBndr
- HsAppType
- FieldOcc
- AmbiguousFieldOcc

Updates haddock submodule

Test Plan: ./validate

Reviewers: shayan-najd, simonpj, austin, goldfire, bgamari

Subscribers: goldfire, rwbarton, thomie, mpickering

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

22 months agoMerge commit '7b0b9f603bb1215e2b7af23c2404d637b95a4988' as 'hadrian'
Andrey Mokhov [Mon, 6 Nov 2017 22:59:38 +0000 (22:59 +0000)] 
Merge commit '7b0b9f603bb1215e2b7af23c2404d637b95a4988' as 'hadrian'

22 months agoSquashed 'hadrian/' content from commit 438dc57
Andrey Mokhov [Mon, 6 Nov 2017 22:59:37 +0000 (22:59 +0000)] 
Squashed 'hadrian/' content from commit 438dc57

git-subtree-dir: hadrian
git-subtree-split: 438dc576e7b84c473a09d1d7ec7798a30303bc4e

22 months agobase: Add examples to Bifunctor documentation
Julie Moronuki [Wed, 1 Nov 2017 03:28:46 +0000 (23:28 -0400)] 
base: Add examples to Bifunctor documentation

22 months agoSpecialise lcm :: Word -> Word -> Word (trac#14424)
Bodigrim [Mon, 6 Nov 2017 19:49:11 +0000 (21:49 +0200)] 
Specialise lcm :: Word -> Word -> Word (trac#14424)

22 months agoUpdate autoconf test for gcc to require 4.7 and up
Peter Trommler [Mon, 6 Nov 2017 20:35:30 +0000 (15:35 -0500)] 
Update autoconf test for gcc to require 4.7 and up

Fixing #14244 required the newer gcc atomic built-ins that are provided
from 4.7 and up. This updates the test to check for minimum gcc version
4.7.

The version tests for 3.4 (!), 4.4, and 4.6 are no longer needed and can
be removed. This makes the build system simpler.

Test Plan: validate

Reviewers: austin, bgamari, hvr, simonmar

Reviewed By: bgamari

Subscribers: rwbarton, thomie, erikd

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

22 months agoDynFlags: Introduce -show-mods-loaded flag
Ben Gamari [Mon, 6 Nov 2017 20:35:19 +0000 (15:35 -0500)] 
DynFlags: Introduce -show-mods-loaded flag

This flag reintroduces the verbose module name output produced by GHCi's
:load command behind a new flag, -show-mods-loaded. This was originally
removed in D3651 but apparently some tools (e.g. haskell-mode) rely on
this output.

Addresses #14427.

Test Plan: Validate

Reviewers: svenpanne

Reviewed By: svenpanne

Subscribers: rwbarton, thomie

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

22 months agoUpdate ErrorCall documentation for the location argument
Ömer Sinan Ağacan [Mon, 6 Nov 2017 20:35:08 +0000 (15:35 -0500)] 
Update ErrorCall documentation for the location argument

Reviewers: hvr, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

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

22 months agoTypo in glasgow_exts.rst
Douglas Wilson [Mon, 6 Nov 2017 20:34:51 +0000 (15:34 -0500)] 
Typo in glasgow_exts.rst

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

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

22 months agocmm/CBE: Fix a few more zip uses
Ben Gamari [Mon, 6 Nov 2017 20:34:37 +0000 (15:34 -0500)] 
cmm/CBE: Fix a few more zip uses

Ensure that we don't consider lists of equal length to be equal when
they are not. I noticed these while working on the fix for #14361.

Reviewers: austin, simonmar, michalt

Reviewed By: michalt

Subscribers: rwbarton, thomie

GHC Trac Issues: #14361

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

22 months agocmm/CBE: Fix comparison between blocks of different lengths
Ben Gamari [Mon, 6 Nov 2017 20:33:26 +0000 (15:33 -0500)] 
cmm/CBE: Fix comparison between blocks of different lengths

Previously CBE computed equality by taking the lists of middle nodes of
the blocks being compared and zipping them together. It would then map
over this list with the equality relation, and accumulate the result.

However, this is completely wrong: Consider what will happen when we
compare a block with no middle nodes with one with one or more. The
result of `zip` will be empty and consequently the pass may conclude
that the two are indeed equivalent (if their last nodes also match).
This is very bad and the cause of #14361.

The solution I chose was just to write out an explicit recursion, like I
distinctly recall considering doing when I first wrote this code.
Unfortunately I was feeling clever at the time.

Unfortunately this case was just rare enough not to be triggered by the
testsuite. I still need to find a testcase that doesn't have external
dependencies.

Test Plan: Need to find a more minimal testcase

Reviewers: austin, simonmar, michalt

Reviewed By: michalt

Subscribers: michalt, rwbarton, thomie, hvr

GHC Trac Issues: #14361

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

22 months agorts/win32: Emit exception handler output to stderr
Ben Gamari [Mon, 6 Nov 2017 20:33:18 +0000 (15:33 -0500)] 
rts/win32: Emit exception handler output to stderr

Test Plan: Validate

Reviewers: Phyx, austin, erikd, simonmar

Reviewed By: Phyx

Subscribers: rwbarton, thomie

GHC Trac Issues: #14415

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

22 months agotestsuite: Bump metrics of haddock.Cabal
Ben Gamari [Mon, 6 Nov 2017 20:23:45 +0000 (15:23 -0500)] 
testsuite: Bump metrics of haddock.Cabal

22 months agoClean up comments about match algorithm a bit.
klebinger.andreas@gmx.at [Sun, 29 Oct 2017 19:26:51 +0000 (20:26 +0100)] 
Clean up comments about match algorithm a bit.

22 months agochange example from msum to mfilter
Julie Moronuki [Tue, 31 Oct 2017 05:15:41 +0000 (01:15 -0400)] 
change example from msum to mfilter

22 months agoFix documentation and comment issues
Cyd Parser [Wed, 1 Nov 2017 06:13:50 +0000 (23:13 -0700)] 
Fix documentation and comment issues

22 months agoDeserialize all function TypeReps
David Feuer [Thu, 2 Nov 2017 21:30:59 +0000 (17:30 -0400)] 
Deserialize all function TypeReps

Previously, we could only deserialize `TypeRep (a -> b)` if
both `a` and `b` had kind `Type`. Now, we do it regardless of
their runtime representations.

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

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

22 months agoName TypeRep constructor fields
David Feuer [Thu, 2 Nov 2017 21:30:23 +0000 (17:30 -0400)] 
Name TypeRep constructor fields

Give `TypeRep` constructor fields names, and use them when pattern
matching and constructing values. This is a bit verbose, but makes
it obvious which field means what.

Reviewers: austin, hvr, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

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

22 months agoBump haddock submodule
alexbiehl [Thu, 2 Nov 2017 21:29:08 +0000 (17:29 -0400)] 
Bump haddock submodule

Reviewers: austin, bgamari

Subscribers: rwbarton, thomie

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

22 months agollvmGen: Pass vector arguments in vector registers by default
Ben Gamari [Thu, 2 Nov 2017 21:28:40 +0000 (17:28 -0400)] 
llvmGen: Pass vector arguments in vector registers by default

Earlier this year Edward Kmett requested [1] that we enable passing of
vector values in vector registers by default. The GHC calling convention
changes have been in LLVM for a number of years now so let's just flip
the switch.

[1] https://mail.haskell.org/pipermail/ghc-devs/2017-March/013905.html

Reviewers: austin

Subscribers: rwbarton, thomie

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

22 months agoCmmSink: Use a IntSet instead of a list
alexbiehl [Thu, 2 Nov 2017 21:27:37 +0000 (17:27 -0400)] 
CmmSink: Use a IntSet instead of a list

CmmProcs which have *lots* of local variables take a considerable
amount of time in CmmSink. This was noticed by @tdammers in #7258
while compiling files with large records (~200-400 fields).

Before:

```
        Sun Oct 29 19:58 2017 Time and Allocation Profiling Report (Final)

           ghc-stage2 +RTS -p -RTS
-B/Users/alexbiehl/git/ghc/inplace/lib /Users/alexbiehl/Downloads/W2.hs
-fforce-recomp -O2

        total time  =       26.00 secs   (25996 ticks @ 1000 us, 1 processor)
        total alloc = 14,921,627,912 bytes  (excludes profiling overheads)

COST CENTRE     MODULE      SRC %time %alloc

sink            CmmPipeline
compiler/cmm/CmmPipeline.hs:(104,13)-(105,59)        55.7   15.9
SimplTopBinds   SimplCore   compiler/simplCore/SimplCore.hs:761:39-74 19.5   30.6
FloatOutwards   SimplCore   compiler/simplCore/SimplCore.hs:471:40-66 4.2    9.0
RegAlloc-linear AsmCodeGen compiler/nativeGen/AsmCodeGen.hs:(658,27)-(660,55)    4.0   11.1
pprNativeCode   AsmCodeGen compiler/nativeGen/AsmCodeGen.hs:(529,37)-(530,65)    2.8    6.3
NewStranal      SimplCore   compiler/simplCore/SimplCore.hs:480:40-63 1.6    3.7
OccAnal         SimplCore compiler/simplCore/SimplCore.hs:(739,22)-(740,67)     1.5    3.5
StgCmm          HscMain compiler/main/HscMain.hs:(1426,13)-(1427,62)          1.2    2.4
regLiveness     AsmCodeGen compiler/nativeGen/AsmCodeGen.hs:(591,17)-(593,52)    1.2    1.9
genMachCode     AsmCodeGen compiler/nativeGen/AsmCodeGen.hs:(580,17)-(582,62)    0.9    1.8
NativeCodeGen   CodeOutput  compiler/main/CodeOutput.hs:171:18-78 0.9    2.1
CoreTidy        HscMain     compiler/main/HscMain.hs:1253:27-67 0.8    1.9
```

After:

```
        Sun Oct 29 19:18 2017 Time and Allocation Profiling Report (Final)

           ghc-stage2 +RTS -p -RTS
-B/Users/alexbiehl/git/ghc/inplace/lib /Users/alexbiehl/Downloads/W2.hs
-fforce-recomp -O2

        total time  =       13.31 secs   (13307 ticks @ 1000 us, 1 processor)
        total alloc = 15,772,184,488 bytes  (excludes profiling overheads)

COST CENTRE     MODULE         SRC %time %alloc

SimplTopBinds   SimplCore
compiler/simplCore/SimplCore.hs:761:39-74            38.3   29.0
sink            CmmPipeline compiler/cmm/CmmPipeline.hs:(104,13)-(105,59)        13.2   20.3
RegAlloc-linear AsmCodeGen compiler/nativeGen/AsmCodeGen.hs:(658,27)-(660,55)    8.3   10.5
FloatOutwards   SimplCore compiler/simplCore/SimplCore.hs:471:40-66             8.1    8.5
pprNativeCode   AsmCodeGen compiler/nativeGen/AsmCodeGen.hs:(529,37)-(530,65)    5.4    5.9
NewStranal      SimplCore compiler/simplCore/SimplCore.hs:480:40-63             3.1    3.5
OccAnal         SimplCore compiler/simplCore/SimplCore.hs:(739,22)-(740,67)     2.9    3.3
StgCmm          HscMain compiler/main/HscMain.hs:(1426,13)-(1427,62)          2.3    2.3
regLiveness     AsmCodeGen compiler/nativeGen/AsmCodeGen.hs:(591,17)-(593,52)    2.1    1.8
NativeCodeGen   CodeOutput     compiler/main/CodeOutput.hs:171:18-78 1.7    2.0
genMachCode     AsmCodeGen compiler/nativeGen/AsmCodeGen.hs:(580,17)-(582,62)    1.6    1.7
CoreTidy        HscMain        compiler/main/HscMain.hs:1253:27-67 1.4    1.8
foldNodesBwdOO  Hoopl.Dataflow compiler/cmm/Hoopl/Dataflow.hs:(397,1)-(403,17)       1.1    0.8
```

Reviewers: austin, bgamari, simonmar

Reviewed By: bgamari

Subscribers: duog, rwbarton, thomie, tdammers

GHC Trac Issues: #7258

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

22 months agorts/PrimOps.cmm: add declaration for heapOverflow closure
Sergei Trofimovich [Thu, 2 Nov 2017 23:07:57 +0000 (23:07 +0000)] 
rts/PrimOps.cmm: add declaration for heapOverflow closure

Before the change UNREG ghc build failed as:
```
  rts_dist_HC rts/dist/build/PrimOps.o
/tmp/ghc2370_0/ghc_4.hc: In function 'stg_newByteArrayzh':

/tmp/ghc2370_0/ghc_4.hc:26:13: error:
     error: 'base_GHCziIOziException_heapOverflow_closure'
         undeclared (first use in this function)
     R1.w = (W_)&base_GHCziIOziException_heapOverflow_closure;
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   |
26 | R1.w = (W_)&base_GHCziIOziException_heapOverflow_closure;
   |             ^
```

It's an UNREG-specific failure because C backend always requires
declarations to be known.

Added missing declaration.

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
22 months agoRevert "Move check-ppr and check-api-annotations to testsuite/utils"
Ben Gamari [Thu, 2 Nov 2017 18:35:01 +0000 (14:35 -0400)] 
Revert "Move check-ppr and check-api-annotations to testsuite/utils"

Unfortunately this (ironically) ended up breaking bindist testing since
we didn't have a package-data.mk. Unfortunately there is no easy way to
fix this.

This reverts commit 1e9f90af7311c33de0f7f5b7dba594725596d675.

22 months agoFix atomicread/write operations
Peter Trommler [Thu, 2 Nov 2017 17:34:41 +0000 (13:34 -0400)] 
Fix atomicread/write operations

In `libraries/ghc-prim/cbits/atomic.c` no barriers were issued for
atomic read and write operations. Starting with gcc 4.7 compiler
intrinsics are offered. The atomic intrinisics are also available in
clang. Use these to implement `hs_atomicread*` and `hs_atomicwrite`.

Test Plan: validate on OSX and Windows

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

Reviewed By: bgamari

Subscribers: dfeuer, rwbarton, thomie

GHC Trac Issues: #14244

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

22 months agoIntroduce -dsuppress-stg-free-vars flag
Ben Gamari [Thu, 2 Nov 2017 17:32:21 +0000 (13:32 -0400)] 
Introduce -dsuppress-stg-free-vars flag

This breaks out control over STG free variable list output from
-dppr-debug into its own distinct flag. This makes it more discoverable
and easier to change independently from other dump output.

Test Plan: Validate

Reviewers: austin

Subscribers: rwbarton, thomie

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

22 months agoTcRnDriver: Bracket family instance consistency output in -ddump-rn-trace
Ben Gamari [Thu, 2 Nov 2017 16:07:50 +0000 (12:07 -0400)] 
TcRnDriver: Bracket family instance consistency output in -ddump-rn-trace

Reviewers: austin

Subscribers: rwbarton, thomie

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

22 months agoAdd custom exception for fixIO
David Feuer [Thu, 2 Nov 2017 16:06:56 +0000 (12:06 -0400)] 
Add custom exception for fixIO

Traditionally, `fixIO f` throws `BlockedIndefinitelyOnMVar` if
`f` is strict. This is not particularly friendly, since the
`MVar` in question is just part of the way `fixIO` happens to be
implemented. Instead, throw a new `FixIOException` with a better
explanation of the problem.

Reviewers: austin, hvr, bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #14356

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

22 months agoUse proper Unique for Name
alexbiehl [Thu, 2 Nov 2017 16:06:21 +0000 (12:06 -0400)] 
Use proper Unique for Name

I noticed this while tinkering in haddock. This might be a relict from
ancient times where newtypes wouldn't optimize well.

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

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

22 months agoImplement the basics of hex floating point literals
Iavor Diatchki [Thu, 2 Nov 2017 16:02:22 +0000 (12:02 -0400)] 
Implement the basics of hex floating point literals

Implement hexadecmial floating point literals.

The digits of the mantissa are hexadecimal.
The exponent is written in base 10, and the base for the exponentiation is 2.
Hexadecimal literals look a lot like ordinary decimal literals, except that
they use hexadecmial digits, and the exponent is written using `p` rather than `e`.

The specification of the feature is available here:
https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0004-hexFloats.rst

For a discussion of the various choices:
https://github.com/ghc-proposals/ghc-proposals/pull/37

Reviewers: mpickering, goldfire, austin, bgamari, hvr

Reviewed By: bgamari

Subscribers: mpickering, thomie

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

22 months agoPPC NCG: Impl branch prediction, atomic ops.
Peter Trommler [Thu, 2 Nov 2017 15:57:05 +0000 (11:57 -0400)] 
PPC NCG: Impl branch prediction, atomic ops.

Implement AtomicRMW ops, atomic read, atomic write
in PowerPC native code generator. Also implement
branch prediction because we need it in atomic ops
anyway.

This patch improves the issue in #12537 a bit but
does not fix it entirely.

The fallback operations for atomicread and atomicwrite
in libraries/ghc-prim/cbits/atomic.c are incorrect.
This patch avoids those functions by implementing the
operations directly in the native code generator. This
is also what the x86/amd64 NCG and the LLVM backend
do.

Test Plan: validate on AIX and PowerPC (32-bit) Linux

Reviewers: erikd, hvr, austin, bgamari, simonmar

Reviewed By: hvr, bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #12537

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

22 months agoImplement the EmptyDataDeriving proposal
Ryan Scott [Thu, 2 Nov 2017 15:52:50 +0000 (11:52 -0400)] 
Implement the EmptyDataDeriving proposal

This implements the `EmptyDataDeriving` proposal put forth in
https://github.com/ghc-proposals/ghc-proposals/blob/dbf51608/proposals/0006-deriving-empty.rst.
This has two major changes:

* The introduction of an `EmptyDataDeriving` extension, which
  permits directly deriving `Eq`, `Ord`, `Read`, and `Show` instances
  for empty data types.
* An overhaul in the code that is emitted in derived instances for
  empty data types. To see an overview of the changes brought forth,
  refer to the changes to the 8.4.1 release notes.

Test Plan: ./validate

Reviewers: bgamari, dfeuer, austin, hvr, goldfire

Reviewed By: bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #7401, #10577, #13117

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

22 months agoTidy up IfaceEqualityTyCon
Simon Peyton Jones [Tue, 31 Oct 2017 11:01:17 +0000 (11:01 +0000)] 
Tidy up IfaceEqualityTyCon

This commit

  commit 85aa1f4253163985fe07d172f8da73b784bb7b4b
  Date:   Sun Oct 29 20:48:19 2017 -0400
    Fix #14390 by making toIfaceTyCon aware of equality

was a bit over-complicated. This patch simplifies the (horribly
ad-hoc) treatement of IfaceEqualityTyCon, and documents it better.

No visible change in behaviour.

22 months agocore-spec: Add join points to formalism
Luke Maurer [Mon, 30 Oct 2017 21:18:11 +0000 (17:18 -0400)] 
core-spec: Add join points to formalism

22 months agoAdd Note [Setting the right in-scope set]
Simon Peyton Jones [Mon, 30 Oct 2017 14:56:58 +0000 (14:56 +0000)] 
Add Note [Setting the right in-scope set]

22 months agoCatch a few more typos in comments
Gabor Greif [Mon, 30 Oct 2017 11:21:49 +0000 (12:21 +0100)] 
Catch a few more typos in comments

22 months agominor wordsmithing
Gabor Greif [Mon, 30 Oct 2017 11:03:30 +0000 (12:03 +0100)] 
minor wordsmithing

22 months agoTypofixes in comments
Gabor Greif [Tue, 24 Oct 2017 21:25:56 +0000 (23:25 +0200)] 
Typofixes in comments

22 months agoTypofix in panic
Gabor Greif [Sun, 22 Oct 2017 21:05:02 +0000 (23:05 +0200)] 
Typofix in panic

22 months agoFix typo in accessor name
Gabor Greif [Fri, 27 Oct 2017 20:59:18 +0000 (22:59 +0200)] 
Fix typo in accessor name

and in comments

22 months agoA bit more tc-tracing
Simon Peyton Jones [Mon, 16 Oct 2017 15:15:08 +0000 (16:15 +0100)] 
A bit more tc-tracing

22 months agoAllow packing constructor fields
Michal Terepeta [Mon, 30 Oct 2017 00:49:32 +0000 (20:49 -0400)] 
Allow packing constructor fields

This is another step for fixing #13825 and is based on D38 by Simon
Marlow.

The change allows storing multiple constructor fields within the same
word. This currently applies only to `Float`s, e.g.,
```
data Foo = Foo {-# UNPACK #-} !Float {-# UNPACK #-} !Float
```
on 64-bit arch, will now store both fields within the same constructor
word. For `WordX/IntX` we'll need to introduce new primop types.

Main changes:

- We now use sizes in bytes when we compute the offsets for
  constructor fields in `StgCmmLayout` and introduce padding if
  necessary (word-sized fields are still word-aligned)

- `ByteCodeGen` had to be updated to correctly construct the data
  types. This required some new bytecode instructions to allow pushing
  things that are not full words onto the stack (and updating
  `Interpreter.c`). Note that we only use the packed stuff when
  constructing data types (i.e., for `PACK`), in all other cases the
  behavior should not change.

- `RtClosureInspect` was changed to handle the new layout when
  extracting subterms. This seems to be used by things like `:print`.
  I've also added a test for this.

- I deviated slightly from Simon's approach and use `PrimRep` instead
  of `ArgRep` for computing the size of fields.  This seemed more
  natural and in the future we'll probably want to introduce new
  primitive types (e.g., `Int8#`) and `PrimRep` seems like a better
  place to do that (where we already have `Int64Rep` for example).
  `ArgRep` on the other hand seems to be more focused on calling
  functions.

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

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

Reviewed By: bgamari

Subscribers: maoe, rwbarton, thomie

GHC Trac Issues: #13825

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

22 months agoFix #14390 by making toIfaceTyCon aware of equality
Ryan Scott [Mon, 30 Oct 2017 00:48:19 +0000 (20:48 -0400)] 
Fix #14390 by making toIfaceTyCon aware of equality

GHC was panicking when pretty-printing a heterogeneous
equality type constructor (#14390) because the function which
produced the type constructor, `toIfaceTyCon`, wasn't attaching the
appropriate `IfaceTyConSort` for equality type constructors, which
is `IfaceEqualityTyCon`. This is fixed easily enough.

Test Plan: make test TEST=T14390

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #14390

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

22 months agoTurn `compareByteArrays#` out-of-line primop into inline primop
alexbiehl [Mon, 30 Oct 2017 00:47:26 +0000 (20:47 -0400)] 
Turn `compareByteArrays#` out-of-line primop into inline primop

Depends on D4090

Reviewers: austin, bgamari, erikd, simonmar, alexbiehl

Reviewed By: bgamari

Subscribers: rwbarton, thomie

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

22 months agoAdd -falignment-sanitization flag
Ben Gamari [Mon, 30 Oct 2017 00:46:45 +0000 (20:46 -0400)] 
Add -falignment-sanitization flag

Here we add a flag to instruct the native code generator to add
alignment checks in all info table dereferences. This is helpful in
catching pointer tagging issues.

Thanks to @jrtc27 for uncovering the tagging issues on Sparc which
inspired this flag.

Test Plan: Validate

Reviewers: simonmar, austin, erikd

Reviewed By: simonmar

Subscribers: rwbarton, trofi, thomie, jrtc27

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

22 months agobase: Implement file locking in terms of POSIX locks
Ben Gamari [Mon, 30 Oct 2017 00:46:21 +0000 (20:46 -0400)] 
base: Implement file locking in terms of POSIX locks

Hopefully these are more robust to NFS malfunction than BSD flock-style
locks.  See #13945.

Test Plan: Validate via @simonpj

Reviewers: austin, hvr

Subscribers: rwbarton, thomie, erikd, simonpj

GHC Trac Issues: #13945

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

22 months agoImplement a dedicated exitfication pass #14152
Joachim Breitner [Sat, 26 Aug 2017 12:35:50 +0000 (14:35 +0200)] 
Implement a dedicated exitfication pass #14152

The idea is described in #14152, and can be summarized: Float the exit
path out of a joinrec, so that the simplifier can do more with it.
See the test case for a nice example.

The floating goes against what the simplifier usually does, hence we
need to be careful not inline them back.

The position of exitification in the pipeline was chosen after a small
amount of experimentation, but may need to be improved. For example,
exitification can allow rewrite rules to fire, but for that it would
have to happen before the `simpl_phases`.

Perf.haskell.org reports these nice performance wins:

    Nofib allocations
    fannkuch-redux    78446640  - 99.92%      64560
    k-nucleotide     109466384  - 91.32%    9502040
    simple            72424696  -  5.96%   68109560

    Nofib instruction counts
    fannkuch-redux  1744331636  -  3.86% 1676999519
    k-nucleotide    2318221965  -  6.30% 2172067260
    scs             1978470869  -  3.35% 1912263779
    simple           669858104  -  3.38%  647206739
    spectral-norm    186423292  -  5.37%  176411536

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

22 months agosimplNonRecJoinPoint: Handle Shadowing correctly
Joachim Breitner [Thu, 26 Oct 2017 23:36:24 +0000 (19:36 -0400)] 
simplNonRecJoinPoint: Handle Shadowing correctly

Previously, (since 33452df), simplNonRecJoinPoint would do the wrong
thing in the presence of shadowing: It analyzed the RHS of a join
binding with the environment for the body. In particular, with

    foo x =
      join x = x * x
      in x

where there is shadowing, it renames the inner x to x1, and should
produce

    foo x =
      join x1 = x * x
      in x1

but because the substitution (x ↦ x1) is also used on the RHS we get the
bogus

    foo x =
      join x1 = x1 * x1
      in x1

Fixed this by adding a `rhs_se` parameter, analogous to `simplNonRecE`
and `simplLazyBind`.

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

22 months agoManual: The -ddump-cmm-* flags had a wrong spelling in the manual
Joachim Breitner [Sat, 28 Oct 2017 21:35:31 +0000 (17:35 -0400)] 
Manual: The -ddump-cmm-* flags had a wrong spelling in the manual

22 months agoMake tagForCon non-linear
Bartosz Nitka [Fri, 20 Oct 2017 19:30:52 +0000 (20:30 +0100)] 
Make tagForCon non-linear

Computing the number of constructors for TyCon is linear
in the number of constructors.
That's wasteful if all you want to check is if that
number is smaller than what fits in tag bits
(usually 8 things).

What this change does is to use a function that can
determine the ineqaulity without computing the size.

This improves compile time on a module with a
data type that has 10k constructors.
The variance in total time is (suspiciously) high,
but going by the best of 3 the numbers are 8.186s vs 7.511s.
For 1000 constructors the difference isn't noticeable:
0.646s vs 0.624s.
The hot spots were cgDataCon and cgEnumerationTyCon
where tagForCon is called in a loop.

One alternative would be to pass down the size.

Test Plan: harbormaster

Reviewers: bgamari, simonmar, austin

Reviewed By: simonmar

Subscribers: rwbarton, thomie

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

22 months agorelnotes: Fix a few minor formatting issues
Ben Gamari [Fri, 27 Oct 2017 18:02:19 +0000 (14:02 -0400)] 
relnotes: Fix a few minor formatting issues

22 months agoApplicativeDo: handle BodyStmt (#12143)
Simon Marlow [Thu, 26 Oct 2017 10:23:23 +0000 (11:23 +0100)] 
ApplicativeDo: handle BodyStmt (#12143)

Summary:
It's simple to treat BodyStmt just like a BindStmt with a wildcard
pattern, which is enough to fix #12143 without going all the way to
using `<*` and `*>` (#10892).

Test Plan:
* new test cases in `ado004.hs`
* validate

Reviewers: niteria, simonpj, bgamari, austin, erikd

Subscribers: rwbarton, thomie

GHC Trac Issues: #12143

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

22 months agoFix an exponential-blowup case in SpecConstr
Simon Peyton Jones [Thu, 26 Oct 2017 16:24:52 +0000 (17:24 +0100)] 
Fix an exponential-blowup case in SpecConstr

Trac #14379 showed a case where use of "forcing" to do
"damn the torpedos" specialisation without resource limits
(which 'vector' does a lot) led to exponential blowup.

The fix is easy.  Finding it wasn't.  See Note [Forcing
specialisation] and the one-line change in decreaseSpecCount.

22 months agoAdd more pprTrace to SpecConstr (debug only)
Simon Peyton Jones [Thu, 26 Oct 2017 16:12:17 +0000 (17:12 +0100)] 
Add more pprTrace to SpecConstr (debug only)

22 months agoDon't use $SHELL in wrapper scripts
Joachim Breitner [Tue, 1 Aug 2017 19:30:09 +0000 (19:30 +0000)] 
Don't use $SHELL in wrapper scripts

Do not use $SHELL as $SHELL is the user's preferred interactive shell.
We do not want this to leak into the wrapper scripts.

22 months agoconfigure: Add Alpine Linux to checkVendor
Tuncer Ayaz [Tue, 1 Aug 2017 19:25:25 +0000 (19:25 +0000)] 
configure: Add Alpine Linux to checkVendor

22 months agousers-guide: Disable index node generation
Ben Gamari [Thu, 26 Oct 2017 23:11:58 +0000 (19:11 -0400)] 
users-guide: Disable index node generation

This is breaking the build on some platforms. It's unclear exactly why but I
don't have time to investigate at the moment.

22 months agoDeclare upstram repo location for hsc2hs
Herbert Valerio Riedel [Thu, 26 Oct 2017 13:47:45 +0000 (15:47 +0200)] 
Declare upstram repo location for hsc2hs

[skip ci]

22 months agoFactor out readField (#14364)
Tobias Dammers [Wed, 25 Oct 2017 23:09:03 +0000 (19:09 -0400)] 
Factor out readField (#14364)

Improves compiler performance of deriving Read instances, as suggested
in the issue.

Additionally, we introduce `readSymField`, a companion to `readField`
that parses symbol-type fields (where the field name is a symbol, e.g.
`(#)`, rather than an alphanumeric identifier. The decision between
these two functions is made a compile time, because we already know
which one we need based on the field name.

Reviewers: austin, hvr, bgamari, RyanGlScott

Reviewed By: bgamari

Subscribers: RyanGlScott, rwbarton, thomie

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

22 months agobase: Enable listToMaybe to fuse via foldr/build
Douglas Wilson [Wed, 25 Oct 2017 23:05:30 +0000 (19:05 -0400)] 
base: Enable listToMaybe to fuse via foldr/build

Test Plan: Consider whether this is a good idea.

Reviewers: austin, hvr, bgamari, nomeata

Reviewed By: bgamari, nomeata

Subscribers: nomeata, rwbarton, thomie

GHC Trac Issues: #14387

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

22 months agouser-guide: Clarify default optimization flags
Ben Gamari [Wed, 25 Oct 2017 19:53:40 +0000 (15:53 -0400)] 
user-guide: Clarify default optimization flags

Begins to fix #14214.

[skip ci]

Test Plan: Read it.

Reviewers: austin

Subscribers: rwbarton, thomie

GHC Trac Issues: #14214

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

22 months agoFix a bug in 'alexInputPrevChar'
Alec Theriault [Wed, 25 Oct 2017 19:52:38 +0000 (15:52 -0400)] 
Fix a bug in 'alexInputPrevChar'

The lexer hacks around unicode by squishing any character into a 'Word8'
and then storing the actual character in its state. This happens at
'alexGetByte'.

That is all and well, but we ought to be careful that the characters we
retrieve via 'alexInputPrevChar' also fit this convention.

In fact, #13986 exposes nicely what can go wrong: the regex in the left
context of the type application rule uses the '$idchar' character set
which relies on the unicode hack. However, a left context corresponds
to a call to 'alexInputPrevChar', and we end up passing full blown
unicode characters to '$idchar', despite it not being equipped to deal
with these.

Test Plan: Added a regression test case

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #13986

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