ghc.git
22 months agoFix utterly bogus TagToEnum rule in caseRules
Simon Peyton Jones [Wed, 7 Feb 2018 09:55:14 +0000 (09:55 +0000)] 
Fix utterly bogus TagToEnum rule in caseRules

In prelRules we had:

  tx_con_tte :: DynFlags -> AltCon -> AltCon
  tx_con_tte _      DEFAULT      = DEFAULT
  tx_con_tte dflags (DataAlt dc)
    | tag == 0  = DEFAULT   -- See Note [caseRules for tagToEnum]
    | otherwise = LitAlt (mkMachInt dflags (toInteger tag))

The tag==0 case is totally wrong, and led directly to Trac #14768.

See "Beware" in Note [caseRules for tagToEnum] (in the patch).

Easily fixed, though!

22 months agotestsuite: Add test for #14768
Ben Gamari [Tue, 6 Feb 2018 22:33:21 +0000 (17:33 -0500)] 
testsuite: Add test for #14768

22 months agorts: fix some barf format specifiers.
Douglas Wilson [Tue, 6 Feb 2018 22:27:32 +0000 (17:27 -0500)] 
rts: fix some barf format specifiers.

Reviewers: bgamari, erikd, simonmar

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

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

22 months agorts: Use BITS_IN macro in bitmap calculations
Ömer Sinan Ağacan [Tue, 6 Feb 2018 18:29:50 +0000 (13:29 -0500)] 
rts: Use BITS_IN macro in bitmap calculations

Reviewers: bgamari, erikd, simonmar

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

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

22 months agoImprove X86CodeGen's pprASCII.
HE, Tao [Tue, 6 Feb 2018 18:29:40 +0000 (13:29 -0500)] 
Improve X86CodeGen's pprASCII.

The original implementation generates a list of SDoc then concatenates
them using `hcat`. For memory optimization, we can transform the given
literal string into escaped string the construct SDoc directly.

This optimization will decreate the memory allocation when there's big
literal strings in haskell code, see Trac #14741.

Signed-off-by: HE, Tao <sighingnow@gmail.com>
Reviewers: bgamari, mpickering, simonpj

Reviewed By: simonpj

Subscribers: simonpj, rwbarton, thomie, carter

GHC Trac Issues: #14741

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

22 months agoRestore 'It is a member of hidden package' message.
Edward Z. Yang [Tue, 6 Feb 2018 18:27:46 +0000 (13:27 -0500)] 
Restore 'It is a member of hidden package' message.

See comment in Packages for more details.

Fixes #14717.

Signed-off-by: Edward Z. Yang <ezyang@fb.com>
Test Plan: validate

Reviewers: snoyberg, taylorfausak, bgamari

Reviewed By: snoyberg, taylorfausak, bgamari

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #14717

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

22 months agorts: Add format attribute to barf
Ben Gamari [Tue, 6 Feb 2018 18:27:35 +0000 (13:27 -0500)] 
rts: Add format attribute to barf

Test Plan: Validate

Reviewers: erikd, simonmar

Reviewed By: simonmar

Subscribers: rwbarton, thomie, carter

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

22 months agorts: Fix format of failed memory commit message
Ben Gamari [Tue, 6 Feb 2018 18:26:50 +0000 (13:26 -0500)] 
rts: Fix format of failed memory commit message

Test Plan: Validate

Reviewers: erikd, simonmar

Reviewed By: simonmar

Subscribers: rwbarton, thomie, carter

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

22 months agocmm: Remove unnecessary HsVersion.h includes
Michal Terepeta [Tue, 6 Feb 2018 18:26:29 +0000 (13:26 -0500)] 
cmm: Remove unnecessary HsVersion.h includes

Test Plan: ./validate

Reviewers: goldfire, bgamari, simonmar

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

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

22 months agoCompute the union of imp_finsts on the side
Bartosz Nitka [Fri, 2 Feb 2018 14:55:19 +0000 (06:55 -0800)] 
Compute the union of imp_finsts on the side

I've explained most of the rationale in a new Note.
I'd happily add a test for this, but the difference is only
visible in run time, allocations remain more or less the same.

FWIW running `generateModules` from #14693 with DEPTH=16, WIDTH=30
finishes in `23s` before, and `11s` after.

Test Plan: ./validate

Reviewers: simonpj, simonmar, bgamari

Reviewed By: simonpj

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #14693

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

22 months agoBump Cabal submodule
Ben Gamari [Tue, 6 Feb 2018 01:27:10 +0000 (20:27 -0500)] 
Bump Cabal submodule

22 months agoImprove unboxed sum documentation
David Feuer [Mon, 5 Feb 2018 14:45:30 +0000 (09:45 -0500)] 
Improve unboxed sum documentation

* Clarify the representation of sums without fields.
* Try to improve language, clarity, and examples.

Fixes #14752

Reviewers: osa1, bgamari

Reviewed By: osa1

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #14752

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

22 months agotestsuite: Add testcase for #14754
Ben Gamari [Sun, 4 Feb 2018 00:19:08 +0000 (19:19 -0500)] 
testsuite: Add testcase for #14754

22 months agocmm: Revert more aggressive CBE due to #14226
Ben Gamari [Sun, 4 Feb 2018 00:49:21 +0000 (19:49 -0500)] 
cmm: Revert more aggressive CBE due to #14226

Trac #14226 noted that the C-- CBE pass frequently fails to
common up semantically identical blocks due to the differences in local
register naming. These patches fixed this by making the pass consider
equality up to alpha-renaming.

However, the new logic failed to consider the possibility that local
register naming *may* matter across multiple blocks. This lead to the
regression #14754. I'll need to do a bit of thinking on a proper
solution to this but in the meantime I'm reverting all four patches.

This reverts commit a27056f9823f8bbe2302f1924b3ab38fd6752e37.
This reverts commit 6f990c54f922beae80362fe62426beededc21290.
This reverts commit 9aa73892e10e90a1799b9277da593e816a827364.
This reverts commit 7920a7d9c53083b234e060a3e72f00b601a46808.

22 months agobase: Deprecate STM invariant checking primitives
Ben Gamari [Sat, 3 Feb 2018 18:11:17 +0000 (13:11 -0500)] 
base: Deprecate STM invariant checking primitives

22 months agoDon't apply dataToTag's caseRules for data families
Ryan Scott [Sat, 3 Feb 2018 16:40:43 +0000 (11:40 -0500)] 
Don't apply dataToTag's caseRules for data families

Commit 193664d42dbceadaa1e4689dfa17ff1cf5a405a0 added a
special caseRule for `dataToTag`, but this transformation completely
broke when `dataToTag` was applied to somewith with a type headed by
a data family, leading to #14680. For now at least, the simplest
solution is to simply not apply this transformation when the type is
headed by a data family.

Test Plan: make test TEST=T14680

Reviewers: simonpj, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #14680

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

22 months agoghc-prim: Emulate C11 atomics when not available
Ben Gamari [Sat, 3 Feb 2018 16:37:01 +0000 (11:37 -0500)] 
ghc-prim: Emulate C11 atomics when not available

GCC's __sync primitives apparently "usually" imply a full barrier,
meaning they can be used to emulate the more precise C11 atomics albeit
with a loss of efficiency. This restores compatibility with GCC 4.4.

This partially reverts commit 59de290928e6903337f31c1f8107ac8a98ea145d.

Test Plan: Validate on Centos

Reviewers: hvr, simonmar, trommler

Subscribers: rwbarton, thomie, erikd, carter

GHC Trac Issues: #14244

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

22 months agoUpgrade containers submodule
David Feuer [Fri, 2 Feb 2018 18:58:28 +0000 (13:58 -0500)] 
Upgrade containers submodule

Reviewers: bgamari

Subscribers: rwbarton, thomie, carter

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

22 months agointeger-gmp: Simplify gmp/configure invocation
Ben Gamari [Fri, 2 Feb 2018 18:58:14 +0000 (13:58 -0500)] 
integer-gmp: Simplify gmp/configure invocation

There weas lots of historical cruft to be found here. The `export
SHELLOPTS` breaks on NixOS due to bash syntax in the gcc wrapper script.

Reviewers: hvr

Subscribers: rwbarton, thomie, carter

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

22 months agoDriverPhases: Fix flipped input extensions for cmm and cmmcpp
Ben Gamari [Fri, 2 Feb 2018 18:57:51 +0000 (13:57 -0500)] 
DriverPhases: Fix flipped input extensions for cmm and cmmcpp

Test Plan: Validate

Subscribers: rwbarton, thomie, carter

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

22 months agoAdd HasDebugCallStack to nameModule
Simon Peyton Jones [Fri, 2 Feb 2018 18:57:20 +0000 (13:57 -0500)] 
Add HasDebugCallStack to nameModule

This function is called in lots of places, so if it
every fails it's good to know from where it was called.

This is Simon's patch, part of his `wip/T2893` branch.

Test Plan: Validate

Subscribers: rwbarton, thomie, carter

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

22 months agotestsuite: Fix scc001 profile output
Ben Gamari [Thu, 1 Feb 2018 06:17:59 +0000 (01:17 -0500)] 
testsuite: Fix scc001 profile output

CircleCI seems to suggest that the cost center ordering is wrong in the prof
way. I'm beginning to wonder whether there is some non-determinism here. If only
I know what this test was supposed to be testing.

22 months agoHoopl.Collections: change right folds to strict left folds
Michal Terepeta [Thu, 1 Feb 2018 05:30:22 +0000 (00:30 -0500)] 
Hoopl.Collections: change right folds to strict left folds

It seems that most uses of these folds should be strict left folds
(I could only find a single place that benefits from a right fold).
So this removes the existing `setFold`/`mapFold`/`mapFoldWihKey`
replaces them with:
- `setFoldl`/`mapFoldl`/`mapFoldlWithKey` (strict left folds)
- `setFoldr`/`mapFoldr` (for the less common case where a right fold
  actually makes sense, e.g., `CmmProcPoint`)

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

Reviewers: bgamari, simonmar

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter, kavon

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

22 months agoFlag `-fdefer-typed-holes` also implies `-fdefer-out-of-scope-variables`.
HE, Tao [Thu, 1 Feb 2018 05:30:04 +0000 (00:30 -0500)] 
Flag `-fdefer-typed-holes` also implies `-fdefer-out-of-scope-variables`.

Reviewers: bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

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

22 months agoAdd -ddump-ds-preopt
Simon Peyton Jones [Thu, 1 Feb 2018 09:19:30 +0000 (09:19 +0000)] 
Add -ddump-ds-preopt

This allows you to see the output immediately after desugaring
but before any optimisation.

I've wanted this for some time, but I was triggered into action
by Trac #13032 comment:9.

Interestingly, the change means that with -dcore-lint we will
now Lint the output before the very simple optimiser;
and this showed up Trac #14749.  But that's not the fault
of -ddump-ds-preopt!

22 months agoRe-center improved perf for T3064
Simon Peyton Jones [Thu, 1 Feb 2018 12:16:40 +0000 (12:16 +0000)] 
Re-center improved perf for T3064

There's a 6% reduction in allocation on T3064.  I think it's due to

  commit e4ab65bd57b2c39f4af52879654514bb6d5b42a0
  Author: Tobias Dammers <tdammers@gmail.com>
  Date:   Wed Jan 31 21:39:45 2018 -0500

      Optimize coercionKind (Trac #11735)

I'm not certain -- but, hey, it's good news

22 months agoExperiment with eliminating the younger tyvar
Simon Peyton Jones [Wed, 31 Jan 2018 15:58:12 +0000 (15:58 +0000)] 
Experiment with eliminating the younger tyvar

This patch is comments only, plus a minor refactor that
does not change behaviour.

It just records an idea I had for reducing kick-out in the type
constraint-solver.

See Note [Eliminate younger unification variables] in TcUnify.

Sadly, it didn't improve perf, so I've put it aside, leaving
some breadcrumbs for future generations of GHC hackers.

22 months agoUnboxedTuples can't be used as constraints
HE, Tao [Thu, 1 Feb 2018 02:40:03 +0000 (21:40 -0500)] 
UnboxedTuples can't be used as constraints

Fixes #14740.

Test Plan: make test TEST="14740"

Reviewers: bgamari, simonpj

Reviewed By: simonpj

Subscribers: simonpj, rwbarton, thomie, carter

GHC Trac Issues: #14740

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

22 months agoOptimize coercionKind (Trac #11735)
Tobias Dammers [Thu, 1 Feb 2018 02:39:45 +0000 (21:39 -0500)] 
Optimize coercionKind (Trac #11735)

Reviewers: simonpj, goldfire, bgamari

Reviewed By: simonpj

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #11735

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

22 months agoMark xmm6 as caller saved in the register allocator for windows.
klebinger.andreas@gmx.at [Thu, 1 Feb 2018 02:39:19 +0000 (21:39 -0500)] 
Mark xmm6 as caller saved in the register allocator for windows.

This prevents the register being picked up as a scratch register.
Otherwise the allocator would be free to use it before a call. This
fixes #14619.

Test Plan: ci, repro case on #14619

Reviewers: bgamari, Phyx, erikd, simonmar, RyanGlScott, simonpj

Reviewed By: Phyx, RyanGlScott, simonpj

Subscribers: simonpj, RyanGlScott, Phyx, rwbarton, thomie, carter

GHC Trac Issues: #14619

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

22 months agorts: Ensure that forkOS releases Task on termination
Ben Gamari [Thu, 1 Feb 2018 02:37:21 +0000 (21:37 -0500)] 
rts: Ensure that forkOS releases Task on termination

Test Plan: validate

Reviewers: simonmar, erikd

Reviewed By: simonmar

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #14725

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

22 months agoSequester deriving-related validity check into cond_stdOK
Ryan Scott [Thu, 1 Feb 2018 02:36:51 +0000 (21:36 -0500)] 
Sequester deriving-related validity check into cond_stdOK

Currently, any standalone-derived instance must satisfy the
property that the tycon of the data type having an instance being
derived for it must be either a normal ADT tycon or a data family
tycon. But there are several other primitive tycons—such as `(->)`,
`Int#`, and others—which cannot have standalone-derived instances
(via the `anyclass` strategy) as a result of this check! See
https://ghc.haskell.org/trac/ghc/ticket/13154#comment:8 for an
example of where this overly conservative restriction bites.

Really, this validity check only makes sense in the context of
`stock` deriving, where we need the property that the tycon is that
of a normal ADT or a data family in order to inspect its data
constructors. Other deriving strategies don't require this validity
check, so the most sensible way to fix this error is to move the
logic of this check into `cond_stdOK`, which is specific to
`stock` deriving.

This makes progress towards fixing (but does not entirely fix)

Test Plan: make test TEST=T13154a

Reviewers: bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #13154

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

22 months agoImplement BlockArguments (#10843)
Takano Akio [Thu, 1 Feb 2018 02:35:29 +0000 (21:35 -0500)] 
Implement BlockArguments (#10843)

This patch implements the BlockArguments extension, as proposed at
https://github.com/ghc-proposals/ghc-proposals/pull/90. It also
fixes #10855 as a side-effect.

This patch adds a large number of shift-reduce conflicts to the parser.
All of them concern the ambiguity as to where constructs like `if` and
`let` end. Fortunately they are resolved correctly by preferring shift.

The patch is based on @gibiansky's ArgumentDo implementation (D1219).

Test Plan: ./validate

Reviewers: goldfire, bgamari, alanz, mpickering

Reviewed By: bgamari, mpickering

Subscribers: Wizek, dfeuer, gibiansky, rwbarton, thomie, mpickering, carter

GHC Trac Issues: #10843, #10855

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

22 months agoDon't add targets that can't be found in GHCi
Julian Priestley [Thu, 1 Feb 2018 02:35:00 +0000 (21:35 -0500)] 
Don't add targets that can't be found in GHCi

When using the :add command in haxlsh/ghci, a module/file that can't
be found is still added to the list of targets, resulting in an error
message for the bad module/file for every subsequent usage of the
command. The add command should verify that the module/file can be
found before adding it to the list of targets.

Also add a ":show targets" command to show the currently added list of
commands, and an ":unadd" command to remove a target.

Test Plan:
Add a new GHCi testcase that checks that :add doesn't remember either
files or modules that could not be found, and that both the new :show
and :unadd commands work as expected.

Reviewers: simonmar, bgamari

Reviewed By: simonmar

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #14676

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

22 months agoMake RTS keep less memory (fixes #14702)
Andrey Sverdlichenko [Thu, 1 Feb 2018 02:33:58 +0000 (21:33 -0500)] 
Make RTS keep less memory (fixes #14702)

Currently runtime keeps hold to 4*used_memory. This includes, in
particular, nursery, which can be quite large on multiprocessor
machines: 16 CPUs x 64Mb each is 1GB. Multiplying it by 4 means whatever
actual memory usage is, runtime will never release memory under 4GB, and
this is quite excessive for processes which only need a lot of memory
shortly (think building data structures from large files).

This diff makes multiplier to apply only to GC-managed memory, leaving
all "static" allocations alone.

Test Plan: make test TEST="T14702"

Reviewers: bgamari, erikd, simonmar

Reviewed By: simonmar

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #14702

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

22 months agoappveyor: Refactor
Ben Gamari [Thu, 1 Feb 2018 00:14:47 +0000 (19:14 -0500)] 
appveyor: Refactor

Move build logic into a dedicated bash script, avoiding repetitive
bash invocations. Furthermore, disable pacman update step as it breaks
things in non-predictable ways.

22 months agotestsuite: Fix test output broken by efba054640d3
Ben Gamari [Thu, 1 Feb 2018 04:02:52 +0000 (23:02 -0500)] 
testsuite: Fix test output broken by efba054640d3

Looks right to me.

22 months agotestsuite: Fix test output of T14715
Ben Gamari [Thu, 1 Feb 2018 03:53:16 +0000 (22:53 -0500)] 
testsuite: Fix test output of T14715

Arguably the warning should just be disabled for this test to eliminate
unnecessary wiggle in the future.

22 months agoappveyor: Don't install gcc
Ben Gamari [Wed, 31 Jan 2018 23:18:40 +0000 (18:18 -0500)] 
appveyor: Don't install gcc

We use GHC's toolchain anyways.

22 months agocircleci: Add Dockerfile for x86_64-linux
Ben Gamari [Wed, 31 Jan 2018 21:41:44 +0000 (16:41 -0500)] 
circleci: Add Dockerfile for x86_64-linux

22 months agotestsuite: Mark scc001 and T5363 as broken due to #14705
Ben Gamari [Wed, 31 Jan 2018 20:40:01 +0000 (15:40 -0500)] 
testsuite: Mark scc001 and T5363 as broken due to #14705

These two tests have been failing on CircleCI.

22 months agoLook inside implications in simplifyRule
Simon Peyton Jones [Wed, 31 Jan 2018 14:25:50 +0000 (14:25 +0000)] 
Look inside implications in simplifyRule

Trac #14732 was a perpelexing bug in which -fdefer-typed-holes
caused a mysterious type error in a RULE.  This turned out to
be because we are more aggressive about creating implications
when deferring (see TcUnify.implicationNeeded), and the rule
mechanism hadn't caught up.

This fixes it.

22 months agoPrioritise equalities when solving, incl deriveds
Simon Peyton Jones [Wed, 31 Jan 2018 13:05:13 +0000 (13:05 +0000)] 
Prioritise equalities when solving, incl deriveds

We already prioritise equalities when solving, but
Trac #14723 showed that we were not doing so consistently
enough, and as a result the type checker could go into a loop.
Yikes.

See Note [Prioritise equalities] in TcSMonad.

Fixng this bug changed the solve order enough to demonstrate
a problem with fundeps: Trac #14745.

22 months agoMore tc-tracing
Simon Peyton Jones [Wed, 31 Jan 2018 13:03:37 +0000 (13:03 +0000)] 
More tc-tracing

22 months agoMove zonkWC to the right place in simplfyInfer
Simon Peyton Jones [Wed, 31 Jan 2018 11:35:33 +0000 (11:35 +0000)] 
Move zonkWC to the right place in simplfyInfer

runTcSWithEvBinds does some unification, so the zonkWC
must be after, not before!  Yikes.  An outright bug.

This fixes Trac #14715.

22 months agoA bit more tc-tracing
Simon Peyton Jones [Wed, 31 Jan 2018 11:35:20 +0000 (11:35 +0000)] 
A bit more tc-tracing

22 months agoUpdate outputs of T12962, scc003
Ömer Sinan Ağacan [Tue, 30 Jan 2018 18:49:03 +0000 (13:49 -0500)] 
Update outputs of T12962, scc003

- T12962: just fix function locations
- scc003: reorder cost centres, cost centre `f.(...)` renamed to `f.x'`

Reviewers: bgamari

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #14704

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

22 months agoAdd likely annotation to cmm files in a few obvious places.
klebinger.andreas@gmx.at [Mon, 29 Jan 2018 23:25:00 +0000 (18:25 -0500)] 
Add likely annotation to cmm files in a few obvious places.

Provide information about paths more likely to be taken in the cmm files
used by the rts.

This leads to slightly better assembly being generated.

Reviewers: bgamari, erikd, simonmar

Subscribers: alexbiehl, rwbarton, thomie, carter

GHC Trac Issues: #14672

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

22 months agoInvert likeliness when improving conditionals
Alexander Biehl [Thu, 18 Jan 2018 12:21:02 +0000 (13:21 +0100)] 
Invert likeliness when improving conditionals

... in CmmSink

22 months agoBump hadrian submodule
Ben Gamari [Sat, 27 Jan 2018 03:20:27 +0000 (22:20 -0500)] 
Bump hadrian submodule

22 months agocmm: Use two equality checks for two alt switch with default
U-Maokai\andi [Fri, 26 Jan 2018 20:43:13 +0000 (15:43 -0500)] 
cmm: Use two equality checks for two alt switch with default

For code like:
f 1 = e1
f 7 = e2
f _ = e3

We can treat it as a sparse jump table, check if we are outside of the
range in one direction first and then start checking the values.

GHC currently does this by checking for x>7, then x <= 7 and at last x
== 1.

This patch changes this such that we only compare for equality against
the two values and jump to the default if non are equal.

The resulting code is both faster and smaller.
wheel-sieve1 improves by 4-8% depending on problem size.

This implements the idea from #14644

Reviewers: bgamari, simonmar, simonpj, nomeata

Reviewed By: simonpj, nomeata

Subscribers: nomeata, simonpj, rwbarton, thomie, carter

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

22 months agoFix #14719 by using the setting the right SrcSpan
Ryan Scott [Fri, 26 Jan 2018 18:10:26 +0000 (13:10 -0500)] 
Fix #14719 by using the setting the right SrcSpan

Currently, error messages that germane to GADT constructors
put the source span at only the first character in the constructor,
leading to insufficient caret diagnostics. This can be easily fixed
by using a source span that spans the entire constructor, instead of
just the first character.

Test Plan: make test TEST=T14719

Reviewers: alanz, bgamari, simonpj

Reviewed By: alanz, simonpj

Subscribers: simonpj, goldfire, rwbarton, thomie, carter

GHC Trac Issues: #14719

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

22 months agoFix Windows stack allocations.
Tamar Christina [Fri, 26 Jan 2018 18:10:10 +0000 (13:10 -0500)] 
Fix Windows stack allocations.

On Windows we use the function `win32AllocStack` to do stack
allocations in 4k blocks and insert a stack check afterwards
to ensure the allocation returned a valid block.

The problem is this function does something that by C semantics
is pointless. The stack allocated value can never escape the
function, and the stack isn't used so the compiler just optimizes
away the entire function body.

After considering a bunch of other possibilities I think the simplest
fix is to just disable optimizations for the function.

Alternatively inline assembly is an option but the stack check function
doesn't have a very portable name as it relies on e.g. `libgcc`.

Thanks to Sergey Vinokurov for helping diagnose and test.

Test Plan: ./validate

Reviewers: bgamari, erikd, simonmar

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #14669

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

22 months agoOption for LINE pragmas to get lexed into tokens
Alec Theriault [Fri, 26 Jan 2018 18:09:58 +0000 (13:09 -0500)] 
Option for LINE pragmas to get lexed into tokens

This adds a parser-level switch to have 'LINE' and 'COLUMN'
pragmas lexed into actual tokens (as opposed to updating the
position information in the parser).

'lexTokenStream' is the only place where this option is enabled.

Reviewers: bgamari, alexbiehl, mpickering

Reviewed By: mpickering

Subscribers: alanz, rwbarton, thomie, carter

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

22 months agoRemove Hoopl.Unique
Michal Terepeta [Fri, 26 Jan 2018 18:09:29 +0000 (13:09 -0500)] 
Remove Hoopl.Unique

Reasons to remove:
- It's confusing - we already have a widely used `Unique` module in
  `basicTypes/` that defines a newtype called `Unique`
- `Hoopl.Unique` is not actually used much

I've also moved the `Unique{Map,Set}` from `Hoopl.Unique` to
`Hoopl.Collections` to keep things together. But that module is also a
bit funny - it defines two type-classes that have only one instance
each. So we should probably either remove them or use them more
widely... In any case, that will be a separate change.

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

Reviewers: bgamari, simonmar

Reviewed By: bgamari

Subscribers: kavon, rwbarton, thomie, carter

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

22 months agoLinker: ignore empty paths in addEnvPaths
Ömer Sinan Ağacan [Fri, 26 Jan 2018 18:09:17 +0000 (13:09 -0500)] 
Linker: ignore empty paths in addEnvPaths

Previously `splitEnv` worked like this:

    > splitEnv "foo:::bar::baz:"
    ["foo","","","bar","","baz",""]

with this patch:

    > splitEnv working_dir "foo:::bar:baz:"
    ["foo",working_dir,working_dir"bar","baz",working_dir]

This fixes #14695, where having a trailing `:` in the env variable
caused ghci to pass empty `-B` parameter to `gcc`, which in turned
caused the next parameter (`--print-file-name`) to be considered as the
argument to `-B`. As a result ghci did not work.

The `working_dir` argument is to have a similar behavior with POSIX:
according to chapter 8.3 zero-length prefix means current working
directory.

Reviewers: hvr, bgamari, AndreasK, simonmar

Reviewed By: bgamari, AndreasK, simonmar

Subscribers: AndreasK, rwbarton, thomie, carter

GHC Trac Issues: #14695

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

22 months agoSort valid substitutions for typed holes by "relevance"
Matthías Páll Gissurarson [Fri, 26 Jan 2018 18:07:36 +0000 (13:07 -0500)] 
Sort valid substitutions for typed holes by "relevance"

This is an initial attempt at tackling the issue of how to order the
suggestions provided by the valid substitutions checker, by sorting
them by creating a graph of how they subsume each other. We'd like to
order them in such a manner that the most "relevant" suggestions are
displayed first, so that the suggestion that the user might be looking
for is displayed before more far-fetched suggestions (and thus also
displayed when they'd otherwise be cut-off by the
`-fmax-valid-substitutions` limit). The previous ordering was based on
the order in which the elements appear in the list of imports, which I
believe is less correlated with relevance than this ordering.

A drawback of this approach is that, since we now want to sort the
elements, we can no longer "bail out early" when we've hit the
`-fmax-valid-substitutions` limit.

Reviewers: bgamari, dfeuer

Reviewed By: dfeuer

Subscribers: dfeuer, rwbarton, thomie, carter

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

22 months agoAdd ptr-eq short-cut to `compareByteArrays#` primitive
Herbert Valerio Riedel [Fri, 26 Jan 2018 18:07:17 +0000 (13:07 -0500)] 
Add ptr-eq short-cut to `compareByteArrays#` primitive

This is an obvious optimisation whose overhead is neglectable but
which significantly simplifies the common uses of `compareByteArrays#`
which would otherwise require to make *careful* use of
`reallyUnsafePtrEquality#` or (equally fragile) `byteArrayContents#`
which can result in less optimal assembler code being generated.

Test Plan: carefully examined generated cmm/asm code; validate via phab

Reviewers: alexbiehl, bgamari, simonmar

Reviewed By: bgamari, simonmar

Subscribers: rwbarton, thomie, carter

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

22 months agoAdd ability to parse likely flags for ifs in Cmm.
klebinger.andreas@gmx.at [Fri, 26 Jan 2018 18:07:05 +0000 (13:07 -0500)] 
Add ability to parse likely flags for ifs in Cmm.

Adding the ability to parse likely flags in Cmm allows better codegen
for cmm files.

Test Plan: ci

Reviewers: bgamari, simonmar

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #14672

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

22 months agoHandle the likely:True case in CmmContFlowOpt
klebinger.andreas@gmx.at [Fri, 26 Jan 2018 18:06:50 +0000 (13:06 -0500)] 
Handle the likely:True case in CmmContFlowOpt

It's better to fall through to the likely case than to jump to it.

We optimize for this in CmmContFlowOpt when likely:False.
This commit extends the logic there to handle cases with likely:True
as well.

Test Plan: ci

Reviewers: bgamari, simonmar

Reviewed By: bgamari

Subscribers: simonmar, alexbiehl, rwbarton, thomie, carter

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

22 months agobase: Refactor Show ErrorCall instance into proper ShowS style
Ben Gamari [Fri, 26 Jan 2018 18:06:34 +0000 (13:06 -0500)] 
base: Refactor Show ErrorCall instance into proper ShowS style

Test Plan: Validate

Reviewers: hvr, dfeuer

Reviewed By: dfeuer

Subscribers: dfeuer, rwbarton, thomie, carter

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

22 months agoHaddock needs to pass visible modules for instance filtering
Alec Theriault [Fri, 26 Jan 2018 18:05:31 +0000 (13:05 -0500)] 
Haddock needs to pass visible modules for instance filtering

The GHC-side `getNameToInstancesIndex` filters out incorrectly some
instances because it is not aware of what modules are visible. Using
`runTcInteractive` means that `ie_visible` gets initialized to a one
module set containing some dummy GHCi module. This is clearly not the
module set we want to check against to see if a given orphan instance
is visible or not.

In fact, GHC has no way of knowing what we want that module set to be
since it doesn't know ahead of time which modules Haddock is making its
docs for. The fix is just to pass that set in as an argument.

Bumps haddock submodule.

Reviewers: bgamari

Reviewed By: bgamari

Subscribers: duog, alexbiehl, rwbarton, thomie, carter

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

22 months agotestsuite: Add testcase for #12158
Ben Gamari [Fri, 26 Jan 2018 17:55:25 +0000 (12:55 -0500)] 
testsuite: Add testcase for #12158

Subscribers: rwbarton, thomie, carter

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

22 months agoTurn EvTerm (almost) into CoreExpr (#14691)
Joachim Breitner [Fri, 26 Jan 2018 16:50:48 +0000 (11:50 -0500)] 
Turn EvTerm (almost) into CoreExpr (#14691)

Ideally, I'd like to do

    type EvTerm = CoreExpr

and the type checker builds the evidence terms as it goes. This failed,
becuase the evidence for `Typeable` refers to local identifiers that are
added *after* the typechecker solves constraints. Therefore, `EvTerm`
stays a data type with two constructors: `EvExpr` for `CoreExpr`
evidence, and `EvTypeable` for the others.

Delted `Note [Memoising typeOf]`, its reference (and presumably
relevance) was removed in 8fa4bf9.

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

22 months agotestsuite: Bump haddock.Cabal allocations due to submodule bump
Ben Gamari [Mon, 22 Jan 2018 16:50:47 +0000 (11:50 -0500)] 
testsuite: Bump haddock.Cabal allocations due to submodule bump

22 months agoBump terminfo submodule
Ben Gamari [Mon, 22 Jan 2018 03:18:24 +0000 (22:18 -0500)] 
Bump terminfo submodule

22 months agoFix the lone-variable case in callSiteInline
Simon Peyton Jones [Thu, 25 Jan 2018 10:32:46 +0000 (10:32 +0000)] 
Fix the lone-variable case in callSiteInline

See Note [Lone variables] in CoreUnfold and
Note [exprIsExpandable] in CoreUtils.

Helpfully pointed out by Matthew Pickering in Trac #14688

Nofib results are good:

--------------------------------------------------------------------------------
        Program           Size    Allocs   Runtime   Elapsed  TotalMem
--------------------------------------------------------------------------------
           anna          +0.1%     +0.3%     0.151     0.151      0.0%
         awards          +0.0%     -0.2%     0.001     0.001      0.0%
      compress2          +0.6%     -0.7%     -4.8%     -5.0%     -4.0%
          eliza          +0.0%     -2.4%     0.001     0.001      0.0%
         fulsom          +0.4%    -13.3%     -7.6%     -7.6%   +190.0%
         gamteb          +0.0%     -0.6%     0.062     0.062      0.0%
             gg          +0.1%     -0.4%     0.016     0.016      0.0%
            ida          +0.1%     +0.3%     0.110     0.110      0.0%
          kahan          +0.0%     -0.7%     -0.9%     -0.9%      0.0%
           mate          +0.1%     -5.2%     -4.9%     -4.9%      0.0%
         n-body          +0.0%     -0.2%     -0.3%     -3.0%      0.0%
         pretty          +0.0%     -2.8%     0.000     0.000      0.0%
            scs          +0.0%     -0.2%     +1.6%     +2.4%      0.0%
         simple          +0.4%     -0.2%     -2.3%     -2.3%     -3.4%
        veritas          +0.4%     -1.0%     0.003     0.003      0.0%
           wang          +0.0%     -1.6%     0.165     0.165      0.0%
--------------------------------------------------------------------------------
            Min          -0.0%    -13.3%    -16.2%    -18.8%     -4.0%
            Max          +0.6%     +0.3%     +4.9%     +4.9%   +190.0%
 Geometric Mean          +0.1%     -0.3%     -1.7%     -2.4%     +0.9%

22 months agoComments only
Simon Peyton Jones [Thu, 25 Jan 2018 09:58:53 +0000 (09:58 +0000)] 
Comments only

22 months agoRemove dead code: mkNthCoRole
Simon Peyton Jones [Thu, 25 Jan 2018 09:58:17 +0000 (09:58 +0000)] 
Remove dead code: mkNthCoRole

22 months agoComments about CoercionHoles
Simon Peyton Jones [Thu, 25 Jan 2018 09:57:01 +0000 (09:57 +0000)] 
Comments about CoercionHoles

Richard was confused; I hope these comments help.

22 months agoAllocate less in plus_mod_dep
Bartosz Nitka [Sun, 21 Jan 2018 17:16:33 +0000 (17:16 +0000)] 
Allocate less in plus_mod_dep

This gives a 10% allocation improvement on MultiLayerModules.
The idea is to reuse existing tuples, instead of constantly
constructing new ones.

Test Plan: ./validate

Reviewers: simonpj, bgamari

Reviewed By: simonpj, bgamari

Subscribers: rwbarton, thomie, simonmar, carter

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

22 months agoPass -dsuppress-uniques when running T14507
Ryan Scott [Mon, 22 Jan 2018 19:16:12 +0000 (14:16 -0500)] 
Pass -dsuppress-uniques when running T14507

Not doing so resulted in different uniques being printed on different
environments, as shown in #14703.

22 months agoImprove comments about TcLevel invariants
Simon Peyton Jones [Mon, 22 Jan 2018 14:49:46 +0000 (14:49 +0000)] 
Improve comments about TcLevel invariants

22 months agoBump transformers submodule to 0.5.5.0
Ben Gamari [Mon, 22 Jan 2018 01:09:20 +0000 (20:09 -0500)] 
Bump transformers submodule to 0.5.5.0

22 months agoUpdate Cabal submodule
Oleg Grenrus [Sun, 21 Jan 2018 18:37:17 +0000 (20:37 +0200)] 
Update Cabal submodule

- Cabal-2.2 uses SPDX license identifiers, so I had to update
  `cabal-version: 2.1` packages `license: BSD3` to `license: BSD-3-Clause`
- `ghc-cabal` used old ReadP parsec, now it uses `parsec` too
- InstalledPackageInfo pretty-printing have changed a little,
  fields with default values aren't printed. This can be changed in
  `Cabal` still, but I haven't found problems with omitting them.

Note: `BSD-3-Clause` is parsed as "name = BSD, version = 3" by old
parser (because 3-Clause looks like version 3 with tag Clause).
If you see *"BSD-3" is not a valid license*, then something is using
old parser still.

Fixes #9885.

22 months agoSysTools: Add detection support for LLD linker
Ben Gamari [Sun, 21 Jan 2018 18:31:29 +0000 (13:31 -0500)] 
SysTools: Add detection support for LLD linker

I noticed while trying to test against LLVM 5.0 that GHC would throw "Couldn't
figure out linker information" warnings due to LLD being chosen by configure.
Adding detection support to silence these is simple enough, let's just do it.

22 months agoUse IntSet in Dataflow
Bartosz Nitka [Sun, 21 Jan 2018 17:11:28 +0000 (12:11 -0500)] 
Use IntSet in Dataflow

Before this change, a list was used as a substitute for a heap.
This led to quadratic behavior on a simple program (see new
test case).

This change replaces it with IntSet in effect reverting
5a1a2633553. @simonmar said it's fine to revert as long as nofib
results are good.

Test Plan:
new test case:

20% improvement
3x improvement when N=10000

nofib:

I run it twice for before and after because the compile time
results are noisy.

- Compile Allocations:

```
          before    before re-run    after     after re-run
-1 s.d.   -----     -0.0%            -0.1%     -0.1%
+1 s.d.   -----     +0.0%            +0.1%     +0.1%
Average   -----     +0.0%            -0.0%     -0.0%
```
- Compile Time:

```
          before    before re-run    after     after re-run
-1 s.d.   -----     -0.1%            -2.3%     -2.6%
+1 s.d.   -----     +5.2%            +3.7%     +4.4%
Average   -----     +2.5%            +0.7%     +0.8%

```
I checked each case and couldn't find consistent slow-down/speed-up on
compile time. Full results here: P173

Reviewers: simonpj, simonmar, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter, simonmar

GHC Trac Issues: #14667

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

22 months agoImplement underscores in numeric literals (NumericUnderscores extension)
Takenobu Tani [Sun, 21 Jan 2018 17:08:59 +0000 (12:08 -0500)] 
Implement underscores in numeric literals (NumericUnderscores extension)

Implement the proposal of underscores in numeric literals.
Underscores in numeric literals are simply ignored.

The specification of the feature is available here:
https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/000
9-numeric-underscores.rst

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

Implementation detail:

* Added dynamic flag
  * `NumericUnderscores` extension flag is added for this feature.

* Alex "Regular expression macros" in Lexer.x
  * Add `@numspc` (numeric spacer) macro to represent multiple
    underscores.
  * Modify `@decimal`, `@decimal`, `@binary`, `@octal`, `@hexadecimal`,
    `@exponent`, and `@bin_exponent` macros to include `@numspc`.

* Alex "Rules" in Lexer.x
  * To be simpler, we have only the definitions with underscores.
    And then we have a separate function (`tok_integral` and `tok_frac`)
    that validates the literals.

* Validation functions in Lexer.x
  * `tok_integral` and `tok_frac` functions validate
    whether contain underscores or not.
    If `NumericUnderscores` extensions are not enabled,
    check that there are no underscores.
  * `tok_frac` function is created by merging `strtoken` and
    `init_strtoken`.
  * `init_strtoken` is deleted. Because it is no longer used.

* Remove underscores from target literal string
  * `parseUnsignedInteger`, `readRational__`, and `readHexRational} use
    the customized `span'` function to remove underscores.

* Added Testcase
  * testcase for NumericUnderscores enabled.
      NumericUnderscores0.hs and NumericUnderscores1.hs
  * testcase for NumericUnderscores disabled.
      NoNumericUnderscores0.hs and NoNumericUnderscores1.hs
  * testcase to invalid pattern for NumericUnderscores enabled.
      NumericUnderscoresFail0.hs and NumericUnderscoresFail1.hs

Test Plan: `validate` including the above testcase

Reviewers: goldfire, bgamari

Reviewed By: bgamari

Subscribers: carter, rwbarton, thomie

GHC Trac Issues: #14473

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

22 months ago[rts] Adjust whitehole_spin
Douglas Wilson [Sun, 21 Jan 2018 17:08:19 +0000 (12:08 -0500)] 
[rts] Adjust whitehole_spin

Rename to whitehole_gc_spin, in preparation for adding stats for the
whitehole busy-loop in SMPClosureOps.

Make whitehole_gc_spin volatile, and move it to be defined and
statically initialised in GC.c. This saves some #ifs, and I'm pretty
sure it should be volatile.

Test Plan: ./validate

Reviewers: bgamari, erikd, simonmar

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

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

22 months agotentative improvement to callstack docs
Alp Mestanogullari [Sun, 21 Jan 2018 17:07:58 +0000 (12:07 -0500)] 
tentative improvement to callstack docs

This is an attempt at clarifying the docs for HasCallStack in both the
user guide and libraries/base/GHC/Stack/Types.hs. The example used right
now is built around an hypothetical 'error' function that doesn't itself
print call stacks, and the fact that this doesn't hold makes it all
confusing, see #14635.

Reviewers: hvr, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #14635

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

22 months agoFix #14692 by correcting an off-by-one error in TcGenDeriv
Ryan Scott [Sun, 21 Jan 2018 17:06:06 +0000 (12:06 -0500)] 
Fix #14692 by correcting an off-by-one error in TcGenDeriv

A silly mistake in `gen_Show_binds` was causing derived
`Show` instances for empty data types to case on the precedence
argument instead of the actual value being showed.

Test Plan: make test TEST=drv-empty-data

Reviewers: bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #14692

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

22 months agotestsuite: Add testcase for #14670
Ben Gamari [Sun, 21 Jan 2018 16:57:34 +0000 (11:57 -0500)] 
testsuite: Add testcase for #14670

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #14670

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

22 months agoAdd new mbmi and mbmi2 compiler flags
John Ky [Sun, 21 Jan 2018 16:55:45 +0000 (11:55 -0500)] 
Add new mbmi and mbmi2 compiler flags

This adds support for the bit deposit and extraction operations provided
by the BMI and BMI2 instruction set extensions on modern amd64 machines.

Implement x86 code generator for pdep and pext.  Properly initialise
bmiVersion field.

pdep and pext test cases

Fix pattern match for pdep and pext instructions

Fix build of pdep and pext code for 32-bit architectures

Test Plan: Validate

Reviewers: austin, simonmar, bgamari, angerman

Reviewed By: bgamari

Subscribers: trommler, carter, angerman, thomie, rwbarton, newhoggy

GHC Trac Issues: #14206

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

22 months agotestsuite: Add test for #14335
Ben Gamari [Thu, 18 Jan 2018 23:23:06 +0000 (18:23 -0500)] 
testsuite: Add test for #14335

Subscribers: rwbarton, thomie

GHC Trac Issues: #14335

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

22 months agoFix #14681 and #14682 with precision-aimed parentheses
Ryan Scott [Thu, 18 Jan 2018 16:06:42 +0000 (11:06 -0500)] 
Fix #14681 and #14682 with precision-aimed parentheses

It turns out that `Convert` was recklessly leaving off
parentheses in two places:

* Negative numeric literals
* Patterns in lambda position

This patch fixes it by adding three new functions, `isCompoundHsLit`,
`isCompoundHsOverLit`, and `isCompoundPat`, and using them in the
right places in `Convert`. While I was in town, I also sprinkled
`isCompoundPat` among some `Pat`-constructing functions in `HsUtils`
to help avoid the likelihood of this problem happening in other
places. One of these places is in `TcGenDeriv`, and sprinkling
`isCompountPat` there fixes #14682

Test Plan: make test TEST="T14681 T14682"

Reviewers: alanz, goldfire, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #14681, #14682

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

22 months agoRemove unused extern cost centre collection
Ömer Sinan Ağacan [Thu, 18 Jan 2018 16:06:30 +0000 (11:06 -0500)] 
Remove unused extern cost centre collection

Reviewers: bgamari, simonmar

Reviewed By: simonmar

Subscribers: alexbiehl, rwbarton, thomie, carter

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

22 months agocmm: Include braces on default branch as required by the parser
klebinger.andreas@gmx.at [Thu, 18 Jan 2018 16:05:40 +0000 (11:05 -0500)] 
cmm: Include braces on default branch as required by the parser

Test Plan: Looking at cmm-dump

Reviewers: bgamari, simonmar

Reviewed By: simonmar

Subscribers: rwbarton, thomie, carter

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

22 months agoRevert "Improve accuracy of get/setAllocationCounter"
Ben Gamari [Thu, 18 Jan 2018 05:50:31 +0000 (00:50 -0500)] 
Revert "Improve accuracy of get/setAllocationCounter"

This reverts commit a1a689dda48113f3735834350fb562bb1927a633.

22 months agoRevert "Fix regression on i386 due to get/setAllocationCounter change"
Ben Gamari [Thu, 18 Jan 2018 05:50:05 +0000 (00:50 -0500)] 
Revert "Fix regression on i386 due to get/setAllocationCounter change"

This reverts commit a770226e03f09b767fdb4ce826162a5c0f29ec29.

22 months agoInform hole substitutions of typeclass constraints (fixes #14273).
Matthías Páll Gissurarson [Thu, 18 Jan 2018 05:49:38 +0000 (00:49 -0500)] 
Inform hole substitutions of typeclass constraints (fixes  #14273).

This implements SPJ's suggestion on the ticket (#14273). We find the
relevant constraints (ones that whose free unification variables are all
mentioned in the type of the hole), and then clone the free unification
variables of the hole and the relevant constraints. We then add a
subsumption constraints and run the simplifier, and then check whether
all the constraints were solved.

Reviewers: bgamari

Reviewed By: bgamari

Subscribers: RyanGlScott, rwbarton, thomie, carter

GHC Trac Issues: #14273

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

22 months agoFix references to cminusminus.org
Ben Gamari [Thu, 18 Jan 2018 00:58:41 +0000 (19:58 -0500)] 
Fix references to cminusminus.org

Reviewers: simonmar

Reviewed By: simonmar

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #14665

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

22 months agoTypos in comments
Gabor Greif [Wed, 17 Jan 2018 13:05:48 +0000 (14:05 +0100)] 
Typos in comments

22 months agoFix quadratic behavior of prepareAlts
Bartosz Nitka [Sat, 13 Jan 2018 02:02:22 +0000 (02:02 +0000)] 
Fix quadratic behavior of prepareAlts

Summary:
This code is quadratic and a simple test case I used
managed to tickle it.

The example (same one as #14667) looks like this:
```
module A10000 where

 data A = A
   | A00001
   | A00002
 ...
   | A10000

 f :: A -> Int
 f A00001 = 19900001
 f A00002 = 19900002
 ...
 f A10000 = 19910000
```

Applied on top of a fix for #14667, it gives a 30% compile time
improvement.

Test Plan: ./validate

Reviewers: simonpj, bgamari

Subscribers: rwbarton, thomie, simonmar, carter

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

23 months agoconfigure: Various cleanups
John Ericson [Mon, 15 Jan 2018 18:53:08 +0000 (13:53 -0500)] 
configure: Various cleanups

Substitute RanlibCmd for consistency, and other configure cleanups that
should have no effect

The other commands are so substituted. Maybe we don't need ranlib at
all, and the configure snippet can be removed all together, but that
can always be done later.

Reviewers: bgamari, hvr, angerman

Reviewed By: bgamari, angerman

Subscribers: rwbarton, thomie, erikd, carter

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

23 months agoSimplify guard in createSwitchPlan.
klebinger.andreas@gmx.at [Mon, 15 Jan 2018 18:52:33 +0000 (13:52 -0500)] 
Simplify guard in createSwitchPlan.

Given that we have two unique keys (guaranteed by Map) checking that
`|range| == 1` is faster.

The fact that `x1 == lo` and `x2 == hi` is guaranteed by mkSwitchTargets
which removes values outside of the range.

Test Plan: ci

Reviewers: bgamari, simonmar

Reviewed By: simonmar

Subscribers: rwbarton, thomie, carter

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

23 months agoRemove executable filename check on windows
klebinger.andreas@gmx.at [Mon, 15 Jan 2018 18:52:15 +0000 (13:52 -0500)] 
Remove executable filename check on windows

On Windows GHC enforces currently that the real executable is named
ghc.exe/ghc-stage[123].exe.

I don't see a good reason why this is neccessary.
This patch removes this restriction and fixes #14652

Test Plan: ci

Reviewers: bgamari, Phyx

Reviewed By: Phyx

Subscribers: Phyx, rwbarton, thomie, carter

GHC Trac Issues: #14652

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

23 months agoParenthesize forall-type args in cvtTypeKind
Ryan Scott [Mon, 15 Jan 2018 18:51:55 +0000 (13:51 -0500)] 
Parenthesize forall-type args in cvtTypeKind

Trac #14646 happened because we forgot to parenthesize `forall` types to
the left of an arrow. This simple patch fixes that.

Test Plan: make test TEST=T14646

Reviewers: alanz, goldfire, bgamari

Reviewed By: alanz

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #14646

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

23 months agoAdd flag -fno-it
Matthew Pickering [Mon, 15 Jan 2018 18:51:38 +0000 (13:51 -0500)] 
Add flag -fno-it

This flag stops ghci creating the special variable `it`
after evaluating an expression. This stops ghci leaking
as much memory when evaluating expressions. See #14336

Reviewers: bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #14336

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

23 months agoFix hash in haddock of ghc-prim.
HE, Tao [Mon, 15 Jan 2018 18:51:15 +0000 (13:51 -0500)] 
Fix hash in haddock of ghc-prim.

Reviewers: bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #14653

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

23 months agoCoreLint: typo in a comment
Ömer Sinan Ağacan [Mon, 15 Jan 2018 18:51:02 +0000 (13:51 -0500)] 
CoreLint: typo in a comment

Reviewers: bgamari, goldfire

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

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