4 years agoAdd Linting for Rules
Simon Peyton Jones [Mon, 13 Jul 2015 09:40:44 +0000 (10:40 +0100)] 
Add Linting for Rules

4 years agoDo not optimise RULE lhs in substRule
Simon Peyton Jones [Mon, 13 Jul 2015 09:29:18 +0000 (10:29 +0100)] 
Do not optimise RULE lhs in substRule

This was causing Trac #10627.
See Note [Substitute lazily] in CoreSubst.

The bug was introduced by
   commit 30c17e7096919c55218083c8fcb98e6287552058
    Author: <unknown>
    Date:   Thu Nov 25 17:23:56 2010 +0000
    Substitution should just substitute, not optimise

The fix is not to optimise the RHS as well as not-optimising the LHS!
The simplifier does the right thing in Simplify.simplRule

4 years agoT9872d: Update 32-bit allocations
Ben Gamari [Sat, 11 Jul 2015 11:07:34 +0000 (13:07 +0200)] 
T9872d: Update 32-bit allocations

4 years agoperf/compiler: Switch to -G1 and update performance metrics
Ben Gamari [Sat, 11 Jul 2015 10:53:40 +0000 (10:53 +0000)] 
perf/compiler: Switch to -G1 and update performance metrics

4 years agoT876 (32-bit): Update bytes allocated
Ben Gamari [Sat, 11 Jul 2015 10:42:14 +0000 (12:42 +0200)] 
T876 (32-bit): Update bytes allocated

This seems to have improved by a bit

4 years agoT1969: Update max_bytes_used
Ben Gamari [Sat, 11 Jul 2015 10:27:20 +0000 (12:27 +0200)] 
T1969: Update max_bytes_used

b5e1944e2b069a7df3444e57bae0b4ee15bde73c started using a single GC
generation yet didn't update this.

4 years agoFix self-contained handling of ASCII encoding
Ben Gamari [Fri, 10 Jul 2015 17:49:29 +0000 (19:49 +0200)] 
Fix self-contained handling of ASCII encoding

D898 was primarily intended to fix hangs in the event that iconv was
unavailable (namely #10298 and #7695). In addition to this fix, it also
introduced self-contained handling of ANSI terminals to allow compiled
executables to run in minimal environments lacking iconv.

However, the behavior that the patch introduced is highly suspicious.
Specifically, it gives the user a UTF-8 encoding even if they requested

This has the potential to break quite a lot of code. At very least it
breaks GHC's Unicode terminal detection logic, which attempts to catch
an invalid character when encoding a pair of smart-quotes. Of course,
this exception will never be thrown if a UTF-8 encoder is used.

Here we use the `char8` encoding to handle requests for ASCII encodings
in the event that we find iconv to be non-functional.

Fixes #10623.

Test Plan: Validate with T8959a

Reviewers: rwbarton, hvr, austin, hsyl20

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #10623

4 years agoDelete the WayPar way
Thomas Miedema [Wed, 8 Jul 2015 19:09:33 +0000 (21:09 +0200)] 
Delete the WayPar way

Also remove 't' and 's' from ALL_WAYS; they don't exist.

Differential Revision:

4 years agoImprove error message for fundeps
Simon Peyton Jones [Fri, 10 Jul 2015 15:24:46 +0000 (16:24 +0100)] 
Improve error message for fundeps

Improve error message fundeps, especially when PolyKinds means that
the un-determined variables are (invisible) kind variables.

See Trac #10570.

4 years agoUpdate .mailmap [skip ci]
Thomas Miedema [Fri, 10 Jul 2015 15:05:08 +0000 (17:05 +0200)] 
Update .mailmap [skip ci]

4 years agoBetter type wildcard errors
Simon Peyton Jones [Fri, 10 Jul 2015 11:53:53 +0000 (12:53 +0100)] 
Better type wildcard errors

Adopts sugggestion in Trac #10224, comment:3

4 years agoComments only
Simon Peyton Jones [Fri, 10 Jul 2015 11:52:50 +0000 (12:52 +0100)] 
Comments only

4 years agoMake mkQualPackage more robust when package key is bad.
Edward Z. Yang [Thu, 9 Jul 2015 17:21:51 +0000 (10:21 -0700)] 
Make mkQualPackage more robust when package key is bad.

Signed-off-by: Edward Z. Yang <>
Test Plan: validate

Reviewers: bgamari, austin

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #10624

4 years agoAdd testcase for #10602
Ben Gamari [Thu, 9 Jul 2015 09:12:05 +0000 (05:12 -0400)] 
Add testcase for #10602

4 years agousers_guide: Fix errant "a" in RULES/class methods docs
Ben Gamari [Thu, 9 Jul 2015 12:08:20 +0000 (14:08 +0200)] 
users_guide: Fix errant "a" in RULES/class methods docs

4 years agoInfer types with flexible contexts
Simon Peyton Jones [Thu, 9 Jul 2015 12:03:34 +0000 (13:03 +0100)] 
Infer types with flexible contexts

Responding to Trac #10608 and Trac #10351, I've reverted
to making type inference infer structured constraint like
    f :: C [t] => t -> t
even if -XFlexibleContexts is not set.  That elicits an
error message suggesting the flag.  The result is more
helpful than the error message you get otherwise.

4 years agoWhite space only
Simon Peyton Jones [Thu, 9 Jul 2015 12:00:59 +0000 (13:00 +0100)] 
White space only

4 years agoDocument RULES and class methods
Simon Peyton Jones [Thu, 9 Jul 2015 11:46:58 +0000 (12:46 +0100)] 
Document RULES and class methods

Relates to Trac #10595

4 years agoBitmap: Fix thunk explosion
Ben Gamari [Thu, 9 Jul 2015 00:08:01 +0000 (02:08 +0200)] 
Bitmap: Fix thunk explosion

Previously we would build up another `map (-N)` thunk
for every word in the bitmap. Now we strictly accumulate the position
and carry out a single ``map (`subtract` accum)``.

`Bitmap.intsToBitmap` showed up in the profile while compiling a
testcase of #7450 (namely a program containing a record type with large
number of fields which derived `Read`). The culprit was
`CmmBuildInfoTables.procpointSRT.bitmap`. On the testcase (with 4096
fields), the profile previously looked like,

total time  =      307.94 secs   (307943 ticks @ 1000 us, 1
total alloc = 336,797,868,056 bytes  (excludes profiling

COST CENTRE              MODULE              %time %alloc

lintAnnots               CoreLint             17.2   25.8
procpointSRT.bitmap      CmmBuildInfoTables   11.3   25.2
FloatOutwards            SimplCore             7.5    1.6
flatten.lookup           CmmBuildInfoTables    4.0    3.9

After this fix it looks like,
total time  =      256.88 secs   (256876 ticks @ 1000 us, 1
total alloc = 255,033,667,448 bytes  (excludes profiling

COST CENTRE              MODULE              %time %alloc

lintAnnots               CoreLint             20.3   34.1
FloatOutwards            SimplCore             9.1    2.1
flatten.lookup           CmmBuildInfoTables    4.8    5.2
pprNativeCode            AsmCodeGen            3.7    4.3
simplLetUnfolding        Simplify              3.6    2.2
StgCmm                   HscMain               3.6    2.1

Signed-off-by: Ben Gamari <>
Test Plan: Validate

Reviewers: austin, simonpj

Reviewed By: simonpj

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #7450

4 years agoFix Trac #10618 (out of scope operator)
Simon Peyton Jones [Wed, 8 Jul 2015 22:42:28 +0000 (23:42 +0100)] 
Fix Trac #10618 (out of scope operator)

Out of scope variables now generate HsUnboundVar,
and the fixity re-jigging wasn't taking this into

4 years agoComments only
Simon Peyton Jones [Wed, 8 Jul 2015 22:19:42 +0000 (23:19 +0100)] 
Comments only

4 years agoBroaden Outputable instance for Termination
Simon Peyton Jones [Thu, 2 Jul 2015 21:56:14 +0000 (22:56 +0100)] 
Broaden Outputable instance for Termination

4 years agoDelete duplicate "Note [Unpack equality predicates]"
Thomas Miedema [Wed, 8 Jul 2015 14:31:02 +0000 (16:31 +0200)] 
Delete duplicate "Note [Unpack equality predicates]"

The other one is MkId.hs.

4 years agoUnbreak Windows build: delete unusud throwIOIO
Thomas Miedema [Wed, 8 Jul 2015 13:30:30 +0000 (15:30 +0200)] 
Unbreak Windows build: delete unusud throwIOIO

Should have been part of 9aa0e4b23d074af44363236fb0f120f07c6e0067.

4 years agoholePackageKey and isHoleModule utility functions.
Edward Z. Yang [Tue, 23 Jun 2015 20:31:15 +0000 (13:31 -0700)] 
holePackageKey and isHoleModule utility functions.

Signed-off-by: Edward Z. Yang <>
4 years agoBackpack: Flesh out more Cabal details
Edward Z. Yang [Wed, 8 Jul 2015 02:49:32 +0000 (19:49 -0700)] 
Backpack: Flesh out more Cabal details

Signed-off-by: Edward Z. Yang <>
4 years agoExport more types from GHC.RTS.Flags (#9970)
RyanGlScott [Tue, 7 Jul 2015 19:20:07 +0000 (21:20 +0200)] 
Export more types from GHC.RTS.Flags (#9970)

Export the data types `GiveGCStats`, `DoCostCentres`, `DoHeapProfiles`,
and `DoTrace`, as well as the type synonyms `Time` and `RtsNat`. The
above data types appear as fields in the `-Stats` data types in
`GHC.RTS.Flags`, but since they only have `Show` instances, it is
practically impossible to due anything useful with the above types
unless they are exported.

Reviewers: hvr, ekmett, austin, ezyang, bgamari

Reviewed By: bgamari

Subscribers: thomie, bgamari

Differential Revision:

GHC Trac Issues: #9970

4 years agoFix #10596 by looking up 'Int' not 'Maybe Int' in the map.
Edward Z. Yang [Tue, 7 Jul 2015 19:19:54 +0000 (21:19 +0200)] 
Fix #10596 by looking up 'Int' not 'Maybe Int' in the map.

Test Plan: validate

Reviewers: goldfire, austin, simonpj, bgamari

Reviewed By: bgamari

Subscribers: simonpj, rwbarton, thomie, bgamari

Differential Revision:

GHC Trac Issues: #10596

4 years agoalways use -fPIC on OpenBSD/AMD64 platform
Karel Gardas [Tue, 7 Jul 2015 16:35:09 +0000 (18:35 +0200)] 
always use -fPIC on OpenBSD/AMD64 platform

This patch switches -fPIC on for every invocation of GHC
on OpenBSD/AMD64 platform. The reason is OpenBSD's support
for PIE (PIC for executables) hence -fPIC is also needed
for GHC compiled code.

Fixes #10597

Reviewers: austin

Subscribers: thomie, bgamari

Differential Revision:

4 years agoGeneralize `Control.Monad.forever`
Ben Gamari [Tue, 7 Jul 2015 15:07:06 +0000 (17:07 +0200)] 
Generalize `Control.Monad.forever`

This generalizes forever to depend on Applicative, rather than Monad.

This was proposed a month ago

Differential Revision:

4 years agofix EBADF unqueueing in select backend (Trac #10590)
Sergei Trofimovich [Tue, 7 Jul 2015 15:00:23 +0000 (17:00 +0200)] 
fix EBADF unqueueing in select backend (Trac #10590)

Alexander found a interesting case:
1. We have a queue of two waiters in a blocked_queue
2. first file descriptor changes state to RUNNABLE,
   second changes to INVALID
3. awaitEvent function dequeued RUNNABLE thread to a
   run queue and attempted to dequeue INVALID descriptor
   to a run queue.

Unqueueing INVALID fails thusly:
        #3  0x000000000045cf1c in barf (s=0x4c1cb0 "removeThreadFromDeQueue: not found")
                               at rts/RtsMessages.c:42
        #4  0x000000000046848b in removeThreadFromDeQueue (...) at rts/Threads.c:249
        #5  0x000000000049a120 in removeFromQueues (...) at rts/RaiseAsync.c:719
        #6  0x0000000000499502 in throwToSingleThreaded__ (...) at rts/RaiseAsync.c:67
        #7  0x0000000000499555 in throwToSingleThreaded (..) at rts/RaiseAsync.c:75
        #8  0x000000000047c27d in awaitEvent (wait=rtsFalse) at rts/posix/Select.c:415

The problem here is a throwToSingleThreaded function that tries
to unqueue a TSO from blocked_queue, but awaitEvent function
leaves blocked_queue in a inconsistent state while traverses
over blocked_queue:

      case RTS_FD_IS_READY:
              debugBelch("Waking up blocked thread %lu\n",
                         (unsigned long)tso->id));
          tso->why_blocked = NotBlocked;
          tso->_link = END_TSO_QUEUE;              // Here we break the queue head

Signed-off-by: Sergei Trofimovich <>
Test Plan: tested on a sample from T10590

Reviewers: austin, bgamari, simonmar

Reviewed By: bgamari, simonmar

Subscribers: qnikst, thomie, bgamari

Differential Revision:

GHC Trac Issues: #10590, #4934

4 years agoDeferred type errors now throw TypeError (#10284)
David Kraeutmann [Tue, 7 Jul 2015 14:59:52 +0000 (16:59 +0200)] 
Deferred type errors now throw TypeError (#10284)

Depends on D864.

Previous behaviour was ErrorCall, which might mask issues in tests
using -fdefer-type-errors

Signed-off-by: David Kraeutmann <>
Test Plan: Test whether the error thrown is indeed TypeError and not

Reviewers: hvr, nomeata, austin

Reviewed By: nomeata, austin

Subscribers: nomeata, simonpj, thomie

Differential Revision:

GHC Trac Issues: #10284

4 years agoFix todo in compiler/nativeGen: Rename Size to Format
markus [Tue, 7 Jul 2015 14:59:40 +0000 (16:59 +0200)] 
Fix todo in compiler/nativeGen: Rename Size to Format

This commit renames the Size module in the native code generator to
Format, as proposed by a todo, as well as adjusting parameter names in
other modules that use it.

Test Plan: validate

Reviewers: austin, simonmar, bgamari

Reviewed By: simonmar, bgamari

Subscribers: bgamari, simonmar, thomie

Projects: #ghc

Differential Revision:

4 years agoAllow deferred type error warnings to be suppressed
David Kraeutmann [Tue, 7 Jul 2015 14:59:34 +0000 (16:59 +0200)] 
Allow deferred type error warnings to be suppressed

Adds a flag -fwarn-deferred-type-errors similar to -fwarn-typed-holes.
Changes the boolean flag of -fdefer-type-errors to a 3-state flag
similar to the one used by -fdefer-typed-holes/-fwarn-typed-holes.

Test Plan: Since only the absence of deferred type error warnings when
-fno-warn-deferred-type-errors is passed has to be tested, I duplicated
a test case checking -fdefer-type-errors and adjusted it accordingly.

Reviewers: nomeata, simonpj, austin, thomie, bgamari, hvr

Reviewed By: nomeata, simonpj, austin, thomie, bgamari, hvr

Subscribers: bgamari, simonpj, nomeata, thomie

Projects: #ghc

Differential Revision:

GHC Trac Issues: #10283

4 years agoUpdate comments around blackholes
Simon Marlow [Tue, 7 Jul 2015 07:52:53 +0000 (08:52 +0100)] 
Update comments around blackholes

Test Plan: validate

Reviewers: austin, bgamari

Subscribers: thomie

Differential Revision:

4 years agoFix word repetitions in comments
Gabor Greif [Tue, 7 Jul 2015 13:52:57 +0000 (15:52 +0200)] 
Fix word repetitions in comments

4 years agoBuild system: don't set GhcLibWays explicitly in (#10536)
Thomas Miedema [Mon, 29 Jun 2015 20:42:42 +0000 (22:42 +0200)] 
Build system: don't set GhcLibWays explicitly in (#10536)

We used to have the following in mk/

  GhcLibWays = $(if $(filter $(DYNAMIC_GHC_PROGRAMS),YES),v dyn,v)

This commit removes that statement for the following reasons:

  1) It depends on the variable DYNAMIC_GHC_PROGRAMS, which is set later
     in the file for some BuildFlavours. Although this works because
     `make` does multiple passes when reading Makefiles, it is confusing
     to users [1]. Instead, test for DYNAMIC_GHC_PROGRAMS in

  2) Although it looks like that line is about compiling the `dyn` way,
     its purpose is really to not build the `prof` way. This commit
     introduces the variable BUILD_PROF_LIBS, to make this more

This simplifies mk/ and mk/

Note that setting GhcLibWays explicitly still works, and
DYNAMIC_GHC_PROGRAMS=NO in does not build the `dyn` way.


Differential Revision:

4 years agoAdd Note [Warnings in code generated by Alex]
Thomas Miedema [Mon, 6 Jul 2015 18:28:04 +0000 (20:28 +0200)] 
Add Note [Warnings in code generated by Alex]

Differential Revision:

4 years agoFix "CPP directive" in comment
Ben Gamari [Tue, 7 Jul 2015 09:50:48 +0000 (11:50 +0200)] 
Fix "CPP directive" in comment

4 years agoAdd more discussion of black-holing logic for #10414
Ben Gamari [Mon, 6 Jul 2015 17:29:21 +0000 (19:29 +0200)] 
Add more discussion of black-holing logic for #10414

Signed-off-by: Ben Gamari <>
4 years agoDon't eagerly blackhole single-entry thunks (#10414)
Reid Barton [Mon, 6 Jul 2015 17:24:31 +0000 (19:24 +0200)] 
Don't eagerly blackhole single-entry thunks (#10414)

In a parallel program they can actually be entered more than once,
leading to deadlock.

Reviewers: austin, simonmar

Subscribers: michaelt, thomie, bgamari

Differential Revision:

GHC Trac Issues: #10414

4 years agoFix offset calculation in __stg_gc_fun
Simon Marlow [Mon, 6 Jul 2015 13:09:50 +0000 (14:09 +0100)] 
Fix offset calculation in __stg_gc_fun

We were not treating the offset as a signed field in this rare case,
so it would blow up if the offset was negative.

Test Plan: Looked at the assembly

Reviewers: austin, bgamari, rwbarton

Subscribers: thomie

Differential Revision:

4 years agoSpelling in comments
Gabor Greif [Tue, 23 Jun 2015 14:35:20 +0000 (16:35 +0200)] 
Spelling in comments

4 years agoRemove warnings for -fwarn-incomplete-patterns
Alan Zimmerman [Mon, 6 Jul 2015 09:13:05 +0000 (11:13 +0200)] 
Remove warnings for -fwarn-incomplete-patterns

And remove one unused bind.

for concerns raised prompting this change.

4 years agoSpecialise: Avoid unnecessary recomputation of free variable information
Ben Gamari [Mon, 6 Jul 2015 08:46:21 +0000 (10:46 +0200)] 
Specialise: Avoid unnecessary recomputation of free variable information

When examining compile times for code with large ADTs (particularly those with
many record constructors), I found that the specialiser contributed
disproportionately to the compiler runtime. Some profiling suggested that
the a great deal of time was being spent in `pair_fvs` being called from

@simonpj pointed out that `flattenDictBinds` as called by `specBind` was
unnecessarily discarding cached free variable information, which then needed to
be recomputed by `pair_fvs`.

Here I refactor the specializer to retain the free variable cache whenever

**Open Qustions**

 * I used `fst` in a couple of places to extract the bindings from a `DictBind`.
   Perhaps this is a sign that `DictBind` has outgrown its type synonym status?

Test Plan: validate

Reviewers: austin, simonpj

Reviewed By: simonpj

Subscribers: thomie, bgamari, simonpj

Differential Revision:

GHC Trac Issues: #7450

4 years agoRemove all *.stderr/stdout-hugs files
Thomas Miedema [Sat, 4 Jul 2015 14:13:11 +0000 (16:13 +0200)] 
Remove all *.stderr/stdout-hugs files

4 years agoRemove Hugs specific test setups (omit_compiler_type)
Thomas Miedema [Sat, 4 Jul 2015 14:11:17 +0000 (16:11 +0200)] 
Remove Hugs specific test setups (omit_compiler_type)

4 years agorts: fix incorrect checking start for -x arguments (#9839)
Nikita Kartashov [Sun, 5 Jul 2015 23:09:26 +0000 (01:09 +0200)] 
rts: fix incorrect checking start for -x arguments (#9839)

After previous fix, flag combinations such as -xt and -xc
resulted in an error due to the fact that the checking started from
index 2, which was always 'x' in that case.
Now they are correctly processed.

Differential Revision:

4 years agoFix typo [skip ci] (#10605)
Thomas Miedema [Sun, 5 Jul 2015 10:37:33 +0000 (12:37 +0200)] 
Fix typo [skip ci] (#10605)

4 years agoEasy way to defer type errors (implements #8353)
Benjamin Bykowski [Sat, 4 Jul 2015 23:38:22 +0000 (01:38 +0200)] 
Easy way to defer type errors (implements #8353)

Added load! and reload! commands, effectively setting
"-fdefer-type-errors" before loading a file and
unsetting it after loading if it has not been set before.

Differential Revision:

4 years agoLexer.x and Parser.y: delete dead code
Thomas Miedema [Sat, 4 Jul 2015 21:06:06 +0000 (23:06 +0200)] 
Lexer.x and Parser.y: delete dead code

4 years agoUse -fno-warn-unused-imports instead of hiding `ord`
Thomas Miedema [Sat, 4 Jul 2015 16:20:06 +0000 (18:20 +0200)] 
Use -fno-warn-unused-imports instead of hiding `ord`

This is more future proof. Maybe later versions of Alex won't `import
Data.Char (ord)` anymore.

4 years agoComments only [skip ci]
Thomas Miedema [Sat, 4 Jul 2015 09:57:44 +0000 (11:57 +0200)] 
Comments only [skip ci]

Follow up to 124f3999d78d8ef6b093e4f1bb1dcef87e4283da.

4 years agoLexer: remove -fno-warn-unused-do-bind
Thomas Miedema [Sat, 4 Jul 2015 13:20:04 +0000 (15:20 +0200)] 
Lexer: remove -fno-warn-unused-do-bind

4 years agoRemove dead code / overlapping pattern (#9723)
Thomas Miedema [Sat, 4 Jul 2015 13:27:45 +0000 (15:27 +0200)] 
Remove dead code / overlapping pattern (#9723)

4 years agoTestsuite: add -ignore-dot-ghci to some tests
Thomas Miedema [Sat, 4 Jul 2015 09:57:44 +0000 (11:57 +0200)] 
Testsuite: add -ignore-dot-ghci to some tests

Since T10408A and T10408B would become the same now, delete T10408A and
rename T10408B to T10408. The test without -ignore-dot-ghci (T10408A)
didn't add anything (#10408).

4 years agoSupport MO_{Add,Sub}IntC and MO_Add2 in the LLVM backend
Michal Terepeta [Sat, 4 Jul 2015 10:52:02 +0000 (12:52 +0200)] 
Support MO_{Add,Sub}IntC and MO_Add2 in the LLVM backend

This includes:

- Adding new LlvmType called LMStructP that represents an unpacked
  struct (this is necessary since LLVM's instructions the
  llvm.sadd.with.overflow.* return an unpacked struct).

- Modifications to LlvmCodeGen.CodeGen to generate the LLVM
  instructions for the primops.

- Modifications to StgCmmPrim to actually use those three instructions
  if we use the LLVM backend (so far they were only used for NCG).

Test Plan: validate

Reviewers: austin, rwbarton, bgamari

Reviewed By: bgamari

Subscribers: thomie, bgamari

Differential Revision:

GHC Trac Issues: #9430

4 years agoReplace usages of `-w` by `-fno-warn`s
Thomas Miedema [Thu, 2 Jul 2015 23:19:59 +0000 (01:19 +0200)] 
Replace usages of `-w` by `-fno-warn`s

And remove unused imports and language pragmas.

I checked that the minimum Happy and Alex version requirements, as
listed in aclocal.m4, don't have to change. Before building ghc, I ran:
  - cabal install happy==1.19.4 --with-ghc=ghc-7.8.4
  - cabal install alex==3.1.0 --with-ghc=ghc-7.6.3

Differential Revision:

4 years agoFix some validation errors.
Richard Eisenberg [Sat, 4 Jul 2015 07:38:59 +0000 (09:38 +0200)] 
Fix some validation errors.

This fixes test cases T10019 and T10534

The patch for T10019 should be back-ported to master as well.

Posting via Phab as a way to distribute a patch against the
ghc-7.10 branch, which I don't have push access to.

Test Plan: validate

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: thomie, bgamari, mzero

Differential Revision:

4 years agoparser: Allow Lm (MODIFIER LETTER) category in identifiers
Thomas Miedema [Fri, 3 Jul 2015 20:37:18 +0000 (22:37 +0200)] 
parser: Allow Lm (MODIFIER LETTER) category in identifiers

Easy fix in the parser to stop regressions, due to Unicode 7.0 changing
the classification of some prior code points.

Signed-off-by: Austin Seipp <>
Test Plan: `tests/parser/should_compile/T10196.hs`

Reviewers: hvr, austin, bgamari

Reviewed By: austin, bgamari

Subscribers: thomie, bgamari

Differential Revision:

GHC Trac Issues: #10196

4 years agoGeneralize traceM, traceShowM (fixes #10023)
RyanGlScott [Fri, 3 Jul 2015 17:37:06 +0000 (19:37 +0200)] 
Generalize traceM, traceShowM (fixes #10023)

This generalizes the type signatures of `traceM` and `traceShowM` to
use `Applicative` rather than `Monad`.

Reviewers: austin, ekmett, hvr, bgamari

Reviewed By: ekmett, hvr, bgamari

Subscribers: thomie, bgamari

Differential Revision:

GHC Trac Issues: #10023

4 years agoAdd "since" column for LANGUAGE extensions in user guide
Alexey Shmalko [Fri, 3 Jul 2015 17:36:56 +0000 (19:36 +0200)] 
Add "since" column for LANGUAGE extensions in user guide

Reviewers: austin

Reviewed By: austin

Subscribers: thomie, bgamari

Differential Revision:

GHC Trac Issues: #9665

4 years agoRemove redundant parser entry point
Matthew Pickering [Fri, 3 Jul 2015 17:36:48 +0000 (19:36 +0200)] 
Remove redundant parser entry point

`parseFullStmt` and `parseStatement` exposed the same parser entry

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: gibiansky, alanz, thomie, bgamari

Differential Revision:

4 years agousers_guide: Describe order-dependence of -f and -O flags
Ben Gamari [Fri, 3 Jul 2015 17:36:12 +0000 (19:36 +0200)] 
users_guide: Describe order-dependence of -f and -O flags

The behavior of the -f and -O options can be quite surprising.
Document this fact. At some point this behavior should likely be changed.

Test Plan: documentation only

Reviewers: austin, trofi

Reviewed By: austin, trofi

Subscribers: thomie, bgamari

Differential Revision:

GHC Trac Issues: #10560

4 years agoRemove unnecessary OrdList from decl parser.
Matthew Pickering [Fri, 3 Jul 2015 17:35:45 +0000 (19:35 +0200)] 
Remove unnecessary OrdList from decl parser.

Each production produced a singleton list.

Similar treatment is applied to the decl_cls parser.

This changes the type of the parseDeclaration entry point to

`parseDeclaration :: P (LHsDecl RdrName)`


`parseTypeSignature :: P (LHsDecl RdrName)`

which is in line with the other parser entry points.

This patch also updates the conflict commentary.  There were 4 reduce/reduce
conflicts introduced by `ffc21506894c7887d3620423aaf86bc6113a1071` which
refactored tuple constraints.

Reviewers: austin

Reviewed By: austin

Subscribers: thomie, bgamari

Differential Revision:

4 years agoFix Trac #10519
Thomas Winant [Fri, 3 Jul 2015 17:35:29 +0000 (19:35 +0200)] 
Fix Trac #10519

Look through nested foralls when checking the validity of a partial type
signature. The combination of D836 and D613 prompts this change.

Test Plan: The test T10519 must pass

Reviewers: simonpj, alanz, austin

Reviewed By: simonpj, alanz, austin

Subscribers: thomie, bgamari

Differential Revision:

GHC Trac Issues: #10519

4 years agoEnable using qualified field of constructor in GHCi
Zejun Wu [Fri, 3 Jul 2015 17:31:25 +0000 (19:31 +0200)] 
Enable using qualified field of constructor in GHCi

The -fimplicit-import-qualified made it possible to uses qualifed names
in GHCi without explicitly import the modules. But it didn't work for
field of constructor, this patch fixed this issue.

Test Plan:
cd testsuite/tests/rename/ && make
cd testsuite/tests/ghci/ && make

Reviewers: austin, simonpj

Reviewed By: austin, simonpj

Subscribers: bgamari, thomie

Differential Revision:

GHC Trac Issues: #10439

4 years agoUse `+RTS -G1` for more stable residency measurements (#9675)
Ben Gamari [Fri, 3 Jul 2015 19:30:31 +0000 (21:30 +0200)] 
Use `+RTS -G1` for more stable residency measurements (#9675)

Reviewers: ezyang, austin, thomie

Subscribers: thomie, bgamari

Differential Revision:

GHC Trac Issues: #10557

4 years agoImplement PowerPC 64-bit native code backend for Linux
Peter Trommler [Fri, 3 Jul 2015 17:09:06 +0000 (19:09 +0200)] 
Implement PowerPC 64-bit native code backend for Linux

Extend the PowerPC 32-bit native code generator for "64-bit
PowerPC ELF Application Binary Interface Supplement 1.9" by
Ian Lance Taylor and "Power Architecture 64-Bit ELF V2 ABI Specification --
OpenPOWER ABI for Linux Supplement" by IBM.
The latter ABI is mainly used on POWER7/7+ and POWER8
Linux systems running in little-endian mode. The code generator
supports both static and dynamic linking. PowerPC 64-bit
code for ELF ABI 1.9 and 2 is mostly position independent
anyway, and thus so is all the code emitted by the code
generator. In other words, -fPIC does not make a difference.

rts/stg/SMP.h support is implemented.

Following the spirit of the introductory comment in
PPC/CodeGen.hs, the rest of the code is a straightforward
extension of the 32-bit implementation.

* Code is generated only in the medium code model, which
  is also gcc's default
* Local symbols are not accessed directly, which seems to
  also be the case for 32-bit
* LLVM does not work, but this does not work on 32-bit either
* Must use the system runtime linker in GHCi, because the
  GHC linker for "static" object files (rts/Linker.c) for
  PPC 64-bit is not implemented. The system runtime
  (dynamic) linker works.
* The handling of the system stack (register 1) is not ELF-
  compliant so stack traces break. Instead of allocating a new
  stack frame, spill code should use the "official" spill area
  in the current stack frame and deallocation code should restore
  the back chain
* DWARF support is missing

Fixes #9863

Test Plan: validate (on powerpc, too)

Reviewers: simonmar, trofi, erikd, austin

Reviewed By: trofi

Subscribers: bgamari, arnons1, kgardas, thomie

Differential Revision:

GHC Trac Issues: #9863

4 years agoBuild system: rename bindist to bindist-list...
Thomas Miedema [Thu, 2 Jul 2015 19:48:56 +0000 (21:48 +0200)] 
Build system: rename bindist to bindist-list... prevent accidental use of `make bindist`, when `make binary-dist`
is called for.

4 years agobin-package-db: copy paste writeFileAtomic from Cabal
Thomas Miedema [Sat, 13 Jun 2015 14:53:28 +0000 (16:53 +0200)] 
bin-package-db: copy paste writeFileAtomic from Cabal

renameFile on Windows calls `Win32.mOVEFILE_REPLACE_EXISTING`
nowadays, which doesn't fail when the targetPath already exists.

4 years agoghc-pkg: use read/writeUTF8File from Cabal
Thomas Miedema [Sat, 13 Jun 2015 14:44:18 +0000 (16:44 +0200)] 
ghc-pkg: use read/writeUTF8File from Cabal

Use writeUTF8File and readUTF8File from Distribution.Simple.Utils,
instead of our own buggy copies. Refactoring only.

4 years agodisable check for .init_array section on OpenBSD
Karel Gardas [Tue, 30 Jun 2015 22:02:52 +0000 (00:02 +0200)] 
disable check for .init_array section on OpenBSD

The patch disables check for .init_array section on OpenBSD.
It is provided in OpenBSD ports tree and was done by Matthias Kilian.

Reviewers: austin

Subscribers: thomie, bgamari

Differential Revision:

4 years agoBuild system: prevent "warning: overriding commands for target..."
Thomas Miedema [Tue, 30 Jun 2015 10:00:43 +0000 (12:00 +0200)] 
Build system: prevent "warning: overriding commands for target..."

This happened because the dyn way was listed twice in GhcLibWays for

4 years agoTestsuite: put extra_run_opts last on command line
Thomas Miedema [Tue, 30 Jun 2015 08:57:19 +0000 (10:57 +0200)] 
Testsuite: put extra_run_opts last on command line

Some tests use the format: extra_run_opts('+RTS foo') (without closing
-RTS). Make it clear in that this should work.

4 years agoTestsuite: accept T2592.stderr (minor changes)
Thomas Miedema [Tue, 30 Jun 2015 08:55:17 +0000 (10:55 +0200)] 
Testsuite: accept T2592.stderr (minor changes)

4 years agoBuild system: remove unused variable CHECK_PACKAGES
Thomas Miedema [Tue, 30 Jun 2015 01:12:32 +0000 (03:12 +0200)] 
Build system: remove unused variable CHECK_PACKAGES

4 years agoCorrect BangPat SrcSpan calculation
Matthew Pickering [Mon, 29 Jun 2015 19:11:17 +0000 (21:11 +0200)] 
Correct BangPat SrcSpan calculation

Previously when the split was performed in splitBang, `BangPat` was given the
same SrcSpan as the whole of the LHS of the declaration. This patch
correctly calculates the value.

Reviewers: alanz, austin

Reviewed By: alanz, austin

Subscribers: thomie, bgamari

Differential Revision:

GHC Trac Issues: #10588

4 years agoUpdate performance numbers due to #10482
Joachim Breitner [Mon, 29 Jun 2015 13:59:17 +0000 (15:59 +0200)] 
Update performance numbers due to #10482

The fix in 0b7e538a has regressed these benchmarks. I have recentered
them rather than marking them as broken(10482), because nobody
systematically watches the broken test cases, and we want to catch
future regressions (or improvements!). #10482 is currently still open,
presumably because this needs investigating.

4 years agoMask to avoid uncaught ^C exceptions
Simon Marlow [Thu, 25 Jun 2015 13:21:44 +0000 (14:21 +0100)] 
Mask to avoid uncaught ^C exceptions

Summary: It was possible to kill GHCi with a carefully-timed ^C

Test Plan: The bug in #10017 exposed this

Reviewers: bgamari, austin

Reviewed By: austin

Subscribers: thomie, bgamari

Differential Revision:

GHC Trac Issues: #10017

4 years agoAdd -fcross-module-specialise flag
Ben Gamari [Sun, 28 Jun 2015 16:32:07 +0000 (18:32 +0200)] 
Add -fcross-module-specialise flag

As of 7.10.1 we specialize INLINEABLE identifiers defined in other
modules. This can expose issues (compiler bugs or otherwise) in some cases
(e.g. Trac #10491) and therefore we now provide a way for the user to disable
this optimization.

Test Plan: Successfully compile Splice.hs from Trac #10491.

Reviewers: simonpj, austin

Reviewed By: simonpj

Subscribers: simonpj, thomie, bgamari

Differential Revision:

GHC Trac Issues: #10491

4 years agoAdd -fcross-module-specialise flag
Ben Gamari [Sun, 28 Jun 2015 16:26:42 +0000 (18:26 +0200)] 
Add -fcross-module-specialise flag

As of 7.10.1 we specialize INLINEABLE identifiers defined in other
modules. This can expose issues (compiler bugs or otherwise) in some cases
(e.g. Trac #10491) and therefore we now provide a way for the user to disable
this optimization.

Test Plan: Successfully compile Splice.hs from Trac #10491.

Reviewers: simonpj, austin

Reviewed By: simonpj

Subscribers: simonpj, thomie, bgamari

Differential Revision:

GHC Trac Issues: #10491

4 years agoTest #10582
Richard Eisenberg [Sat, 27 Jun 2015 14:51:58 +0000 (10:51 -0400)] 
Test #10582

4 years agoTest Trac #10524
Simon Peyton Jones [Fri, 26 Jun 2015 15:00:45 +0000 (16:00 +0100)] 
Test Trac #10524

4 years agoImprove error message for Typeable k (T k)
Simon Peyton Jones [Fri, 26 Jun 2015 15:00:19 +0000 (16:00 +0100)] 
Improve error message for Typeable k (T k)

GHC can't yest build a TypeRep for a type involving kind variables.
(We await kinds = types for that.)  But the error message was terrible,
as fixing #10524 reminded me.

This improves it a lot.

4 years agoBetter tracing and tiny refactoring
Simon Peyton Jones [Fri, 26 Jun 2015 14:57:28 +0000 (15:57 +0100)] 
Better tracing and tiny refactoring

4 years agoMake fvType ignore kinds
Simon Peyton Jones [Fri, 26 Jun 2015 14:56:35 +0000 (15:56 +0100)] 
Make fvType ignore kinds

TcValidity.fvTypes works in partnership with sizeTypes, and
hence should ignore kinds in exactly the same way.  It wasn't
doing so, which meant that validDerivPred said "No" when it
should have said "Yes". That led to the bug reported in
Trac #10524 comment:7.

The error message is pretty terrible
  No instance for (Typeable T)
but I'll fix that next

4 years agoKill off sizePred
Simon Peyton Jones [Fri, 26 Jun 2015 13:34:42 +0000 (14:34 +0100)] 
Kill off sizePred

It really isn't needed, and life is simpler without

4 years agocloseOverKinds *before* oclose in coverage check
Simon Peyton Jones [Fri, 26 Jun 2015 13:28:45 +0000 (14:28 +0100)] 
closeOverKinds *before* oclose in coverage check

Combining functional dependencies with kind-polymorphism is
devilishly tricky!  It's all documented in
    Note [Closing over kinds in coverage]

Fixes Trac #10564

4 years agoImprove CPR behavior for strict constructors
Simon Peyton Jones [Fri, 26 Jun 2015 10:40:01 +0000 (11:40 +0100)] 
Improve CPR behavior for strict constructors

When working on Trac #10482 I noticed that we could give constructor
arguments the CPR property if they are use strictly.

This is documented carefully in
    Note [CPR in a product case alternative]
and also
    Note [Initial CPR for strict binders]

There are a bunch of intersting examples in
    Note [CPR examples]
which I have added to the test suite as T10482a.

I also added a test for #10482 itself.

4 years agoSmall doc fixes
Simon Peyton Jones [Fri, 26 Jun 2015 10:36:02 +0000 (11:36 +0100)] 
Small doc fixes

4 years agoComments only
Simon Peyton Jones [Fri, 26 Jun 2015 07:35:11 +0000 (08:35 +0100)] 
Comments only

4 years agoGHCi docs: layout rule is respected inside :{ :}
Thomas Miedema [Wed, 24 Jun 2015 10:52:16 +0000 (12:52 +0200)] 
GHCi docs: layout rule is respected inside :{ :}

I don't know if or when this changed, but the documentation on :{ :}
(multiline input) seems out of date. Layout rule works fine. I added a
regression test.

Reviewers: austin

Subscribers: thomie, bgamari

Differential Revision:

4 years agoFix deadlock (#10545)
Simon Marlow [Fri, 19 Jun 2015 14:12:24 +0000 (15:12 +0100)] 
Fix deadlock (#10545)

yieldCapability() was not prepared to be called by a Task that is not
either a worker or a bound Task.  This could happen if we ended up in
yieldCapability via this call stack:


and there were a few other ways this could happen via requestSync.
The fix is to handle this case in yieldCapability(): when the Task is
not a worker or a bound Task, we put it on the returning_workers
queue, where it will be woken up again.

Summary of changes:

* `yieldCapability`: factored out subroutine waitForWorkerCapability`
* `waitForReturnCapability` renamed to `waitForCapability`, and
  factored out subroutine `waitForReturnCapability`
* `releaseCapabilityAndQueue` worker renamed to `enqueueWorker`, does
  not take a lock and no longer tests if `!isBoundTask()`
* `yieldCapability` adjusted for refactorings, only change in behavior
  is when it is not a worker or bound task.

Test Plan:
* new test concurrent/should_run/performGC
* validate

Reviewers: niteria, austin, ezyang, bgamari

Subscribers: thomie, bgamari

Differential Revision:

GHC Trac Issues: #10545

4 years agoFix for crash in setnumcapabilities001
Simon Marlow [Fri, 19 Jun 2015 13:41:32 +0000 (14:41 +0100)] 
Fix for crash in setnumcapabilities001

getNewNursery() was unconditionally incrementing next_nursery, which
is normally fine but it broke an assumption in
storageAddCapabilities().  This manifested as an occasional crash in
the setnumcapabilities001 test.

4 years agoTiny refactor plus comments
Simon Peyton Jones [Fri, 26 Jun 2015 07:31:37 +0000 (08:31 +0100)] 
Tiny refactor plus comments

4 years agoError message wibbles from out-of-scope changes
Simon Peyton Jones [Thu, 25 Jun 2015 08:25:39 +0000 (09:25 +0100)] 
Error message wibbles from out-of-scope changes

The patch "Treat out-of-scope variables as holes" makes
lots of error messages change a bit. This patch has all
the change.

4 years agoTreat out-of-scope variables as holes
Simon Peyton Jones [Wed, 24 Jun 2015 22:27:59 +0000 (23:27 +0100)] 
Treat out-of-scope variables as holes

This patch implements the idea in Trac #10569.

* An out-of-scope variable is treated as a typed expression

* That is, we don't report it in the type checker, not the
  renamer, and we when we do report it, we give its type.

* Moreover, we can defer the error to runtime with

In implementation terms:

* The renamer turns an unbound variable into a HsUnboundVar

* The type checker emits a Hole constraint for a
  HsUnboundVar, and turns it back into a HsVar

It was a bit painful to implement because a whole raft of
error messages change slightly.  But there was absolutely
nothing hard in principle.

Holes are reported with a bunch of possibly-useful context,
notably the "relevant bindings".  I found that this was
distracting clutter in the very common case of a mis-typed
variable that is only accidentally not in scope, so I've
arranged to print the context information only for true holes,
that is ones starting with an underscore.

Unbound data constructors use in patterns, like
  f (D x) = x
are still reportd by the renamer, and abort compilation
before type checking.

4 years agoGet rid of irrelevant impredicative polymoprhism
Simon Peyton Jones [Thu, 25 Jun 2015 08:21:13 +0000 (09:21 +0100)] 
Get rid of irrelevant impredicative polymoprhism

These tests aren't about impredicativity

4 years agoGet rid of irrlevant result type signature
Simon Peyton Jones [Thu, 25 Jun 2015 08:17:27 +0000 (09:17 +0100)] 
Get rid of irrlevant result type signature

Result type-sigs are now illegal, but that's not what this test
is about