ghc.git
23 months agoCollect CCs in CorePrep, including CCs in unfoldings
Ömer Sinan Ağacan [Tue, 13 Feb 2018 06:03:57 +0000 (09:03 +0300)] 
Collect CCs in CorePrep, including CCs in unfoldings

This patch includes two changes:

1. Move cost centre collection from `SCCfinal` to `CorePrep`, to be able
   to collect cost centres in unfoldings. `CorePrep` drops unfoldings, so
   that's the latest stage in the compilation pipeline for this.

   After this change `SCCfinal` no longer collects all cost centres, but
   it still generates & collects CAF cost centres + updates cost centre
   stacks of `StgRhsClosure` and `StgRhsCon`s.

   This fixes #5889.

2. Initialize cost centre stack fields of `StgRhs` in `coreToStg`. With
   this we no longer need to update cost centre stack fields in
   `SCCfinal`, so that module is removed.

   Cost centre initialization explained in Note [Cost-centre
   initialization plan].

   Because with -fcaf-all we need to attach a new cost-centre to each
   CAF, `coreTopBindToStg` now returns `CollectedCCs`.

Test Plan: validate

Reviewers: simonpj, bgamari, simonmar

Reviewed By: simonpj, bgamari

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #5889

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

23 months agoMake ($!) representation-polymorphic
David Feuer [Tue, 13 Feb 2018 01:01:56 +0000 (20:01 -0500)] 
Make ($!) representation-polymorphic

Now that `($)` is representation-polymorphic, `($!)` should
surely follow suit.

Reviewers: hvr, bgamari, simonpj

Reviewed By: bgamari, simonpj

Subscribers: simonpj, rwbarton, thomie, carter

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

23 months agoEvac.c: remove unused CPP guard
Ömer Sinan Ağacan [Mon, 12 Feb 2018 11:33:25 +0000 (14:33 +0300)] 
Evac.c: remove unused CPP guard

`NO_PROMOTE_THUNKS` is never defined

23 months agoSimplify Foreign.Marshal.Alloc functions with ScopedTypeVariables
Ömer Sinan Ağacan [Sat, 10 Feb 2018 06:12:42 +0000 (09:12 +0300)] 
Simplify Foreign.Marshal.Alloc functions with ScopedTypeVariables

Reviewers: hvr, bgamari, RyanGlScott

Reviewed By: RyanGlScott

Subscribers: RyanGlScott, rwbarton, thomie, carter

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

23 months agoFix isDroppableCt (Trac #14763)
Simon Peyton Jones [Thu, 8 Feb 2018 14:24:11 +0000 (14:24 +0000)] 
Fix isDroppableCt (Trac #14763)

When finishing up an implication constraint, it's a bit tricky to
decide which Derived constraints to retain (for error reporting) and
which to discard.  I got this wrong in commit
   f20cf982f126aea968ed6a482551550ffb6650cf
   (Remove wc_insol from WantedConstraints)

The particular problem in Trac #14763 was that we were reporting as an
error a fundep-generated constraint
  (ex ~ T)
where 'ex' is an existentially-bound variable in a pattern match.
But this isn't really an error at all.

This patch fixes the problem. Indeed, since I had to understand
this rather tricky code, I took the opportunity to clean it up
and document better.  See
  isDroppableCt :: Ct -> Bool
and Note [Dropping derived constraints]

I also removed wl_deriv altogether from the WorkList data type.  It
was there in the hope of gaining efficiency by not even processing
lots of derived constraints, but it has turned out that most derived
constraints (notably equalities) must be processed anyway; see
Note [Prioritise equalities] in TcSMonad.

The two are coupled because to decide which constraints to put in
wl_deriv I was using another variant of isDroppableCt.  Now it's much
simpler -- and perhaps even more efficient too.

23 months agorts: fix barf format attribute
Douglas Wilson [Thu, 8 Feb 2018 00:03:28 +0000 (00:03 +0000)] 
rts: fix barf format attribute

Summary: See definition of PRINTF above the change

Reviewers: bgamari, erikd, simonmar, Phyx

Reviewed By: Phyx

Subscribers: Phyx, rwbarton, thomie, carter

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

23 months agoUse SPDX syntax in rts/package.conf.in
Herbert Valerio Riedel [Wed, 7 Feb 2018 17:36:13 +0000 (18:36 +0100)] 
Use SPDX syntax in rts/package.conf.in

This was an oversight from 2671cccde749ed64129097358f81bff43480cdb9
as it wasn't obvious to assume one would go the trouble to manually
construct the pkg-db entries... :-)

23 months agoFix solveOneFromTheOther for RecursiveSuperclasses
Simon Peyton Jones [Wed, 7 Feb 2018 11:57:40 +0000 (11:57 +0000)] 
Fix solveOneFromTheOther for RecursiveSuperclasses

This patch fixes the redundant superclass expansion
in Trac #14774.

The main change is to fix TcInterac.solveOneFromTheOther, so
that it does not prefer a work-item with a binding if that binding
transitively depends on the inert item we are comparing it with.

Explained in Note [Replacement vs keeping] in TcInert, esp
item (c) of the "Constraints coming from the same level" part.

To make this work I refactored out a new function
TcEvidence.findNeededEvVars, which was previously buried
inside TcSimplify.neededEvVars.

I added quite a few more comments and signposts about superclass
expansion.

23 months agoComments only
Simon Peyton Jones [Wed, 7 Feb 2018 11:56:58 +0000 (11:56 +0000)] 
Comments only

23 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!

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

23 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

23 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

23 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

23 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

23 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

23 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

23 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

23 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

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

23 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

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

23 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.

23 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

23 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

23 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

23 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

23 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

23 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

23 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

23 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.

23 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

23 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

23 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!

23 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

23 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.

23 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

23 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

23 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

23 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

23 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

23 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

23 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

23 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

23 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.

23 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.

23 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.

23 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.

23 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

23 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.

23 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.

23 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.

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

23 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.

23 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

23 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

23 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

23 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

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

23 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

23 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

23 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

23 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

23 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

23 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

23 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

23 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

23 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

23 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

23 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

23 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

23 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

23 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

23 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

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

23 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%

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

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

23 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.

23 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

23 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.

23 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

23 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

23 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.

23 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.

23 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

23 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

23 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

23 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

23 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

23 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

23 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

2 years 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

2 years 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

2 years 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

2 years 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

2 years 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.

2 years 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.

2 years 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

2 years 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