3 years agofix compilation failure on OpenBSD with system supplied GNU C 4.2.1
Karel Gardas [Sat, 13 Aug 2016 16:46:43 +0000 (18:46 +0200)] 
fix compilation failure on OpenBSD with system supplied GNU C 4.2.1

This patch fixes compilation failure on OpenBSD. The OpenBSD's
GNU C compiler is of 4.2.1 version and problematic __builtin_unreachable
was added in GNU C 4.5 release. Let's use pure abort() call
on OpenBSD instead of __builtin_unreachable

Reviewers: bgamari, austin, erikd, simonmar

Subscribers: thomie

Differential Revision:

3 years agoFix configure detection.
Tamar Christina [Sat, 13 Aug 2016 15:27:30 +0000 (16:27 +0100)] 
Fix configure detection.

GHC's configure script seems to normalize the values returned from config.guess.
So for Windows it turns x86_64-pc-mingw64 into x86_64-unknown-mingw32.
These mangled names are stored in the values $BuildPlatform, $HostPlatform
and $TargetPlatform.

However further down the file when the comparison is done between the stage0
compiler and the host the normalized versions are not used.
So when normalization actually changes the triple this check will fail.

Not sure why it's worked for all this time.. Nor if this is the right fix?
Does it still work for cross compiling correctly?

Test Plan: ./configure

Reviewers: hvr, austin, thomie, bgamari, erikd

Reviewed By: erikd

Subscribers: erikd, #ghc_windows_task_force

Differential Revision:

GHC Trac Issues: #12487

3 years agoMisspellings in comments [skip ci]
Gabor Greif [Sun, 14 Aug 2016 11:03:23 +0000 (13:03 +0200)] 
Misspellings in comments [skip ci]

3 years agoUpdate `nofib` submodule to newest commit
Gabor Greif [Sun, 14 Aug 2016 07:50:49 +0000 (09:50 +0200)] 
Update `nofib` submodule to newest commit

3 years agoFix GHCi perf-llvm build on x86_64
Erik de Castro Lopo [Sat, 13 Aug 2016 21:23:35 +0000 (07:23 +1000)] 
Fix GHCi perf-llvm build on x86_64

With BuildFlavour set to `perf-llvm`, GHCi would fail as soon as it
was run with:

  ghc-stage2: .../ghc-prim/dist-install/build/HSghc-prim-
  unknown symbol `__udivti3'
  ghc-stage2: unable to load package `ghc-prim-'

Fix this by adding `__udivti3` and `__umodti3` to RtsSymbols.c.

Test Plan: Validate

Reviewers: simonmar, austin, bgamari, Phyx, trofi

Reviewed By: Phyx, trofi

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #11981

3 years agoImprove missing-sig warning
Simon Peyton Jones [Fri, 12 Aug 2016 14:52:07 +0000 (15:52 +0100)] 
Improve missing-sig warning

Fixes Trac #12484

3 years agoRemove StgRubbishArg and CmmArg
Ömer Sinan Ağacan [Wed, 10 Aug 2016 16:47:47 +0000 (16:47 +0000)] 
Remove StgRubbishArg and CmmArg

The idea behind adding special "rubbish" arguments was in unboxed sum types
depending on the tag some arguments are not used and we don't want to move some
special values (like 0 for literals and some special pointer for boxed slots)
for those arguments (to stack locations or registers). "StgRubbishArg" was an
indicator to the code generator that the value won't be used. During Stg-to-Cmm
we were then not generating any move or store instructions at all.

This caused problems in the register allocator because some variables were only
initialized in some code paths. As an example, suppose we have this STG: (after

    Lib.$WT =
        \r [dt_sit]
                case dt_sit of {
                  Lib.F dt_siv [Occ=Once] ->
                      (#,,#) [1# dt_siv StgRubbishArg::GHC.Prim.Int#];
                  Lib.I dt_siw [Occ=Once] ->
                      (#,,#) [2# StgRubbishArg::GHC.Types.Any dt_siw];
            { (#,,#) us_giC us_giD us_giE -> Lib.T [us_giC us_giD us_giE];

This basically unpacks a sum type to an unboxed sum with 3 fields, and then
moves the unboxed sum to a constructor (`Lib.T`).

This is the Cmm for the inner case expression (case expression in the scrutinee
position of the outer case):

        -- look at dt_sit's tag
        if (_ciT::P64 != 1) goto ciS; else goto ciR;
    ciS: -- Tag is 2, i.e. Lib.F
        _siw::I64 = I64[_siu::P64 + 6];
        _giE::I64 = _siw::I64;
        _giD::P64 = stg_RUBBISH_ENTRY_info;
        _giC::I64 = 2;
        goto ciU;
    ciR: -- Tag is 1, i.e. Lib.I
        _siv::P64 = P64[_siu::P64 + 7];
        _giD::P64 = _siv::P64;
        _giC::I64 = 1;
        goto ciU;

Here one of the blocks `ciS` and `ciR` is executed and then the execution
continues to `ciR`, but only `ciS` initializes `_giE`, in the other branch
`_giE` is not initialized, because it's "rubbish" in the STG and so we don't
generate an assignment during code generator. The code generator then panics
during the register allocations:

    ghc-stage1: panic! (the 'impossible' happened)
      (GHC version 8.1.20160722 for x86_64-unknown-linux):
            LocalReg's live-in to graph ciY {_giE::I64}

(`_giD` is also "rubbish" in `ciS`, but it's still initialized because it's a
pointer slot, we have to initialize it otherwise garbage collector follows the
pointer to some random place. So we only remove assignment if the "rubbish" arg
has unboxed type.)

This patch removes `StgRubbishArg` and `CmmArg`. We now always initialize
rubbish slots. If the slot is for boxed types we use the existing `absentError`,
otherwise we initialize the slot with literal 0.

Reviewers: simonpj, erikd, austin, simonmar, bgamari

Reviewed By: erikd

Subscribers: thomie

Differential Revision:

3 years agoFix a bug in unboxed sum layout generation
Ömer Sinan Ağacan [Tue, 9 Aug 2016 22:30:56 +0000 (22:30 +0000)] 
Fix a bug in unboxed sum layout generation

We need to maintain the invariant that the layout fields are always sorted.

Two tests that were previously broken are added.

3 years agoActually update haddock.Cabal stats.
Edward Z. Yang [Mon, 8 Aug 2016 23:06:45 +0000 (16:06 -0700)] 
Actually update haddock.Cabal stats.

Signed-off-by: Edward Z. Yang <>
3 years agoCabal submodule update.
Edward Z. Yang [Wed, 4 May 2016 21:55:59 +0000 (14:55 -0700)] 
Cabal submodule update.

There's a substantial bump to the haddock.Cabal allocation
stats, because we added 50% more modules, so of course allocations
are going to increase 50%. (But perhaps this is indicative of
some bad constant factor in Haddock related to modules.)

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

Reviewers: ggreif, austin, bgamari

Subscribers: thomie

Differential Revision:

3 years agoFix typo in Data.Bitraversable Haddocks
Ryan Scott [Mon, 8 Aug 2016 16:59:17 +0000 (12:59 -0400)] 
Fix typo in Data.Bitraversable Haddocks

[ci skip]

3 years agoT1969: Enable it again but bump the max residency temporarily
Ömer Sinan Ağacan [Sun, 7 Aug 2016 15:19:01 +0000 (15:19 +0000)] 
T1969: Enable it again but bump the max residency temporarily

T1969 was broken by 714beb (which actually reduced allocations but
residency was increased). Instead of disabling it completely, just bump
the number a little bit to avoid making things even worse in the
meantime. See also #12437.

3 years Remove checks for bug 9439
Erik de Castro Lopo [Sat, 6 Aug 2016 22:24:16 +0000 (08:24 +1000)] Remove checks for bug 9439

Bug #9439 only affects some ghc 7.8 versions of the compiler and since
git HEAD no longer builds with ghc-7.8 we can drop this check.

Test Plan: Works here!

Reviewers: hvr, austin, bgamari

Reviewed By: bgamari

Subscribers: thomie

Differential Revision:

3 years agoUse Data.Functor.Const to implement Data.Data internals
Ryan Scott [Sat, 6 Aug 2016 15:08:31 +0000 (11:08 -0400)] 
Use Data.Functor.Const to implement Data.Data internals

`Data.Data` uses an internal datatype `CONST`, which can be replaced
completely by `Const` from `Data.Functor.Const`.

Reviewers: austin, bgamari, hvr

Subscribers: thomie

Differential Revision:

3 years agoRegAlloc: Use IntSet/IntMaps instead of generic Set/Maps
Ömer Sinan Ağacan [Sat, 6 Aug 2016 13:10:03 +0000 (13:10 +0000)] 
RegAlloc: Use IntSet/IntMaps instead of generic Set/Maps

3 years agoRegAlloc: Remove duplicate seqList (use seqList from Util)
Ömer Sinan Ağacan [Sat, 6 Aug 2016 12:56:50 +0000 (12:56 +0000)] 
RegAlloc: Remove duplicate seqList (use seqList from Util)

3 years agoAsmCodeGen: Give linear-scan and coloring reg. allocators different cc names
Ömer Sinan Ağacan [Sat, 6 Aug 2016 12:55:54 +0000 (12:55 +0000)] 
AsmCodeGen: Give linear-scan and coloring reg. allocators different cc names

3 years agorts/Printer.h: fix constness of argument declaration
Sergei Trofimovich [Sat, 6 Aug 2016 10:55:14 +0000 (11:55 +0100)] 
rts/Printer.h: fix constness of argument declaration

Noticed on today's build failure:

  rts/Printer.c:659:13: error:
     error: conflicting types for 'DEBUG_LoadSymbols'
     extern void DEBUG_LoadSymbols( const char *name )

  In file included from rts/Printer.c:17:0: error:

  rts/Printer.h:29:13: error:
     note: previous declaration of 'DEBUG_LoadSymbols' was here
     extern void DEBUG_LoadSymbols( char *name );

Signed-off-by: Sergei Trofimovich <>
3 years agoUtil.count: Implement as a left-fold instead of a right-fold
Joachim Breitner [Sat, 6 Aug 2016 01:39:07 +0000 (21:39 -0400)] 
Util.count: Implement as a left-fold instead of a right-fold

3 years agoReplace some `length . filter` with `count`
Ömer Sinan Ağacan [Fri, 5 Aug 2016 20:58:02 +0000 (20:58 +0000)] 
Replace some `length . filter` with `count`

3 years agoStgCmm: Remove unused Bool field of Return sequel
Ömer Sinan Ağacan [Fri, 5 Aug 2016 18:52:46 +0000 (18:52 +0000)] 
StgCmm: Remove unused Bool field of Return sequel

3 years agoTemporarily mark T1969 perf test as broken (#12437)
Ömer Sinan Ağacan [Fri, 5 Aug 2016 15:28:26 +0000 (15:28 +0000)] 
Temporarily mark T1969 perf test as broken (#12437)

3 years agoBump `hoopl` submodule, mostly cosmetics
Gabor Greif [Fri, 5 Aug 2016 10:39:21 +0000 (12:39 +0200)] 
Bump `hoopl` submodule, mostly cosmetics

3 years agoAnother try to get thread migration right
Simon Marlow [Thu, 4 Aug 2016 14:59:43 +0000 (15:59 +0100)] 
Another try to get thread migration right

This is surprisingly tricky.  There were linked list bugs in the
previous version (D2430) that showed up as a test failure in
setnumcapabilities001 (that's a great stress test!).

This new version uses a different strategy that doesn't suffer from
the problem that @ezyang pointed out in D2430.  We now pre-calculate
how many threads to keep for this capability, and then migrate any
surplus threads off the front of the queue, taking care to account for
threads that can't be migrated.

Test Plan:
1. setnumcapabilities001 stress test with sanity checking (+RTS -DS) turned on:

cd testsuite/tests/concurrent/should_run
make TEST=setnumcapabilities001 WAY=threaded1 EXTRA_HC_OPTS=-with-rtsopts=-DS CLEANUP=0
while true; do ./ 4 9 2000 || break; done

2. The test case from #12419

Reviewers: niteria, ezyang, rwbarton, austin, bgamari, erikd

Subscribers: thomie, ezyang

Differential Revision:

GHC Trac Issues: #12419

3 years agoFix an assertion that could randomly fail
Simon Marlow [Thu, 4 Aug 2016 14:57:37 +0000 (15:57 +0100)] 
Fix an assertion that could randomly fail

returning_tasks queue, but that requires cap->lock to access safely.
This assertion would randomly fail if stressed enough.

Instead I've removed it from the catch-all
ASSERT_PARTIAL_CAPABILITIY_INVARIANTS and made it a separate assertion
only called under cap->lock.

Test Plan:
cd testsuite/tests/concurrent/should_run
make TEST=setnumcapabilities001 WAY=threaded1 EXTRA_HC_OPTS=-with-rtsopts=-DS CLEANUP=0
while true; do ./ 4 9 2000 || break; done

Reviewers: niteria, bgamari, ezyang, austin, erikd

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #10860

3 years agoExpanded abbreviations in Haddock documentation
Ben Gamari [Thu, 4 Aug 2016 12:36:09 +0000 (14:36 +0200)] 
Expanded abbreviations in Haddock documentation

This adds notes to the Haddock documentation for various core datatypes
expanding abbreviations.

Reviewers: bgamari, thomie

Differential Revision:

GHC Trac Issues: #12405

3 years agocodeGen: Remove binutils<2.17 hack, fixes T11758
Alex Dzyoba [Thu, 4 Aug 2016 11:42:21 +0000 (13:42 +0200)] 
codeGen: Remove binutils<2.17 hack, fixes T11758

There was a complication on the x86_64 platform, where pointers were 64
bits, but the tools didn't support 64-bit relative relocations.  This
was true before binutils 2.17, which nowadays is quite standart (even
CentOs 5 is shipped with 2.17).

Hacks were removed from x86 genSwitch and asm pretty printer. Also
[x86-64-relative] note was dropped from
includes/rts/storage/InfoTables.h as it's not referenced anywhere now.

Reviewers: austin, simonmar, rwbarton, erikd, bgamari

Reviewed By: simonmar, erikd, bgamari

Subscribers: thomie

Differential Revision:

3 years agocheck that the number of parallel build is greater than 0
Ruey-Lin Hsu [Thu, 4 Aug 2016 11:41:57 +0000 (13:41 +0200)] 
check that the number of parallel build is greater than 0

Fixes #12062.

Reviewers: bgamari, thomie, austin, simonmar

Reviewed By: bgamari, thomie, simonmar

Subscribers: simonmar, thomie

Differential Revision:

GHC Trac Issues: #12062

3 years agoRemove identity update of field componentsConfigs
Gabor Greif [Fri, 5 Aug 2016 07:52:26 +0000 (09:52 +0200)] 
Remove identity update of field componentsConfigs

... in LocalBuildInfo, getting rid of a TODO in the
process. Turns out that componentsConfigs won't be
a field in Cabal 2.0 any more, so this can be seen
as a preparation for it.

3 years agoTrim all spaces after 'version:'
Gabor Greif [Fri, 5 Aug 2016 07:42:09 +0000 (09:42 +0200)] 
Trim all spaces after 'version:'

... that we grep out of libraries/Cabal/Cabal/Cabal.cabal

This is necessary because the file got reformatted
in the 'master' branch.

3 years agoFix omission in haddock instance head
Gabor Greif [Fri, 5 Aug 2016 07:00:51 +0000 (09:00 +0200)] 
Fix omission in haddock instance head

3 years agoReplace an unsafeCoerce with coerce
Ryan Scott [Thu, 4 Aug 2016 14:25:10 +0000 (10:25 -0400)] 
Replace an unsafeCoerce with coerce

This matches the implementations of `castPtr` and `castFunPtr`.

3 years agoCmmLayoutStack: Minor simplification
Ömer Sinan Ağacan [Thu, 4 Aug 2016 10:10:41 +0000 (10:10 +0000)] 
CmmLayoutStack: Minor simplification

3 years agoCmmLive: Remove some redundant exports
Ömer Sinan Ağacan [Thu, 4 Aug 2016 10:09:56 +0000 (10:09 +0000)] 
CmmLive: Remove some redundant exports

3 years agoClarify comment on makeCorePair
Matthew Pickering [Wed, 3 Aug 2016 16:06:42 +0000 (17:06 +0100)] 
Clarify comment on makeCorePair

3 years agoRemove `setUnfoldingInfoLazily`
Matthew Pickering [Wed, 3 Aug 2016 13:22:21 +0000 (14:22 +0100)] 
Remove `setUnfoldingInfoLazily`

The definition of `setUnfoldingInfoLazily` is exactly the same as
`setUnfoldingInfo` and is only used in one place, `TcIface`.

They were made equivalent in 2010 in
2ff2497dc374175b8ed81446258baf208d1f3e6e with the commit message.

commit 2ff2497dc374175b8ed81446258baf208d1f3e6e
Author: Ian Lynagh <>  Wed Oct 20 15:37:10 2010
Committer:      Ian Lynagh <>  Wed Oct 20 15:37:10 2010
Original File:  compiler/basicTypes/IdInfo.lhs

Don't seq unfoldings
We generate intermediate unfoldings which are just thrown away, so
evaluating them is a waste of time.

Closes #12453

3 years agoTypo in comment [skip ci]
Matthew Pickering [Wed, 3 Aug 2016 13:06:57 +0000 (14:06 +0100)] 
Typo in comment [skip ci]

3 years agoMore comments about InlinePragmas
Matthew Pickering [Wed, 3 Aug 2016 13:04:53 +0000 (14:04 +0100)] 
More comments about InlinePragmas

Just pointers about where to look in the source code.

3 years agoUpdate old comment InlinePragma
Matthew Pickering [Wed, 3 Aug 2016 10:37:05 +0000 (11:37 +0100)] 
Update old comment InlinePragma

3 years agoAdd comment about lexing of INLINE and INLINABLE pragma
Matthew Pickering [Wed, 3 Aug 2016 10:29:26 +0000 (11:29 +0100)] 
Add comment about lexing of INLINE and INLINABLE pragma

3 years agoStgSyn: Remove unused StgLiveVars types
Ömer Sinan Ağacan [Wed, 3 Aug 2016 08:50:31 +0000 (08:50 +0000)] 
StgSyn: Remove unused StgLiveVars types

3 years agoRemove the DEBUG_<blah> variables, use RtsFlags directly
Simon Marlow [Tue, 2 Aug 2016 12:09:32 +0000 (13:09 +0100)] 
Remove the DEBUG_<blah> variables, use RtsFlags directly

3 years agoOnly trace cap/capset events if we're tracing anything else
Simon Marlow [Tue, 2 Aug 2016 08:57:19 +0000 (09:57 +0100)] 
Only trace cap/capset events if we're tracing anything else

I was getting annoyed by cap/capset messages when using +RTS -DS, which
doesn't cause any other trace messages to be emitted.  This makes it
possible to add --with-rtsopts=-DS when running tests, and not have all
the tests fail due to spurious trace messages.

Test Plan: validate

Reviewers: duncan, bgamari, ezyang, austin, erikd

Subscribers: thomie

Differential Revision:

3 years agoFix to thread migration
Simon Marlow [Wed, 27 Jul 2016 15:00:08 +0000 (16:00 +0100)] 
Fix to thread migration

If we had 2 threads on the run queue, say [A,B], and B is bound to the
current Task, then we would fail to migrate any threads.  This fixes it
so that we would migrate A in that case.

This will help parallelism a bit in programs that have lots of bound

Test Plan:
Test program in #12419, which is actually not a great program but it
does behave a bit better after this change.

Reviewers: ezyang, niteria, bgamari, austin, erikd

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #12419

3 years agoTrack the lengths of the thread queues
Simon Marlow [Tue, 2 Aug 2016 08:55:31 +0000 (09:55 +0100)] 
Track the lengths of the thread queues

Knowing the length of the run queue in O(1) time is useful: for example
we don't have to traverse the run queue to know how many threads we have
to migrate in schedulePushWork().

Test Plan: validate

Reviewers: ezyang, erikd, bgamari, austin

Subscribers: thomie

Differential Revision:

3 years agoForeignCall.hs: Remove DrIFT directives
Ömer Sinan Ağacan [Tue, 2 Aug 2016 13:03:32 +0000 (13:03 +0000)] 
ForeignCall.hs: Remove DrIFT directives

3 years agoTypo in comment
Gabor Greif [Mon, 1 Aug 2016 13:25:10 +0000 (15:25 +0200)] 
Typo in comment

3 years agoUse MO_Cmpxchg in Primops.cmm instead of ccall cas(..)
alexbiehl [Mon, 1 Aug 2016 08:46:29 +0000 (18:46 +1000)] 
Use MO_Cmpxchg in Primops.cmm instead of ccall cas(..)

Adjust `CmmParse.y` to parse the `cmpxchg{8, 16, 32, 64}` instructions
and use the 32 respectively the 64 bit variant in `Primops.cmm`. This
effectively eliminates the compare-and-swap ccall to the rts.

Based off the mailing list question from @osa1

Reviewers: simonmar, austin, erikd, bgamari, trommler

Reviewed By: erikd, bgamari, trommler

Subscribers: carter, trommler, osa1, thomie

Differential Revision:

3 years agoRelevant Bindings no longer reports shadowed bindings (fixes #12176)
Annie Cherkaev [Mon, 1 Aug 2016 06:30:42 +0000 (23:30 -0700)] 
Relevant Bindings no longer reports shadowed bindings (fixes #12176)

Summary: Modified the RelevantBindings method in TcErrors.hs to only search over
non-shadowed bindings.

Test Plan: Wrote 2 simple test cases, verified that it worked with multiple
shadowed bindings, and also non-shadowed bindings.

Reviewers: austin, bgamari, ezyang

Reviewed By: ezyang

Subscribers: ezyang, thomie

Differential Revision:

GHC Trac Issues: #12177

3 years agoAdd atomic operations to
alexbiehl [Sat, 30 Jul 2016 07:22:54 +0000 (17:22 +1000)] 
Add atomic operations to

This patch resulted from the discussion in D2431 and should be merged

@erikd and @trommler reported errors like

): In function `c14_info':
(.text+0x2b8): undefined reference to `hs_cmpxchg32'
): In function `c5e_info':
(.text+0xac4): undefined reference to `hs_cmpxchg32'
): In function `c8b_info':
(.text+0x1198): undefined reference to `hs_cmpxchg32'
): In function `c8b_info':
(.text+0x122c): undefined reference to `hs_cmpxchg32'
): In function `c8b_info':
(.text+0x12ec): undefined reference to `hs_cmpxchg32'

on PowerPC. @simonmar suggests to add the specific exports to
`rts/`. This patch does exactly that, including all
other atomic ops as they probably (maybe someone can verify?) suffer
from the same problem on PPC.

Test Plan: Please make sure to build on PPC.

Reviewers: erikd, austin, bgamari, simonmar, trommler

Reviewed By: erikd, trommler

Subscribers: thomie

Differential Revision:

3 years agoMake Unique a newtype
Ömer Sinan Ağacan [Thu, 28 Jul 2016 15:13:54 +0000 (15:13 +0000)] 
Make Unique a newtype

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: thomie

Differential Revision:

3 years agoMove stat_startGCSync
Bartosz Nitka [Wed, 27 Jul 2016 15:25:59 +0000 (08:25 -0700)] 
Move stat_startGCSync

@simonmar told me that it makes more sense this way.

Test Plan: it still builds

Reviewers: bgamari, austin, simonmar, erikd

Reviewed By: simonmar, erikd

Subscribers: thomie, simonmar

Differential Revision:

3 years agoAdd mblocks_allocated to GC stats API
Bartosz Nitka [Wed, 27 Jul 2016 15:24:40 +0000 (08:24 -0700)] 
Add mblocks_allocated to GC stats API

This exposes mblocks_allocated in the GCStats struct.

Test Plan: it builds

Reviewers: bgamari, simonmar, austin, hvr, erikd

Reviewed By: erikd

Subscribers: thomie

Differential Revision:

3 years agoCompute boot-defined TyCon names from ModIface.
Edward Z. Yang [Sun, 3 Jul 2016 01:08:55 +0000 (18:08 -0700)] 
Compute boot-defined TyCon names from ModIface.

Three things in this commit:

    1. Get rid of sb_ids; we are not going to use them
    to avoid infinite unfoldings in hs-boot files.

    2. Compute sb_tcs from ModIface rather than ModDetails.
    This means that the typechecker can look at this field
    without forcing the boot ModDetails, which would be
    bad if the ModDetails is not available yet (due to
    knot tying.)

    3. A big honking comment explaining what is going on

Signed-off-by: Edward Z. Yang <>
Reviewers: simonpj, austin, bgamari

Subscribers: thomie

Differential Revision:

3 years agoAccept better stats for T9675
Simon Marlow [Tue, 26 Jul 2016 15:01:58 +0000 (08:01 -0700)] 
Accept better stats for T9675

3 years agoFix productivity calculation (#12424)
Simon Marlow [Tue, 26 Jul 2016 14:55:37 +0000 (07:55 -0700)] 
Fix productivity calculation (#12424)

3 years agoMonadUtils: Typos in comments
Ömer Sinan Ağacan [Tue, 26 Jul 2016 14:47:43 +0000 (14:47 +0000)] 
MonadUtils: Typos in comments

3 years agoSome typos in comments
Gabor Greif [Mon, 25 Jul 2016 22:34:48 +0000 (00:34 +0200)] 
Some typos in comments

3 years agoTestsuite: fix T10482a
Thomas Miedema [Sun, 24 Jul 2016 23:36:20 +0000 (01:36 +0200)] 
Testsuite: fix T10482a

3 years agoFix the non-Linux build
Erik de Castro Lopo [Fri, 22 Jul 2016 12:59:44 +0000 (14:59 +0200)] 
Fix the non-Linux build

The recent Compact Regions commit (cf989ffe49) builds fine on Linux
but doesn't build on OS X r Windows.

* rts/sm/CNF.c: Drop un-needed #includes.
* Fix parenthesis usage with CPP ASSERT macro.
* Fix format string in debugBelch messages.
* Use stg_max() instead hand rolled inline max() function.

Test Plan: Build on Linux, OS X and Windows

Reviewers: gcampax, simonmar, austin, bgamari

Subscribers: thomie

Differential Revision:

3 years agoUNPACK the size field of SizedSeq
Simon Marlow [Thu, 21 Jul 2016 12:47:47 +0000 (05:47 -0700)] 
UNPACK the size field of SizedSeq

3 years ago-fprof-auto-top
Simon Marlow [Thu, 21 Jul 2016 11:33:44 +0000 (04:33 -0700)] 

3 years agoSquash space leaks in the result of byteCodeGen
Simon Marlow [Thu, 21 Jul 2016 11:51:05 +0000 (04:51 -0700)] 
Squash space leaks in the result of byteCodeGen

When loading a large number of modules into GHCi, we collect
CompiledByteCode for every module and then link it all at the end.
Space leaks in the CompiledByteCode linger until we traverse it all for
linking, and possibly longer, if there are bits we don't look at.

This is the nuke-it-from-orbit approach: we deepseq the whole thing
after code generation. It's the only way to be sure.

Test Plan:
Heap profile of GHCi while loading nofib/real/anna into GHCi, this patch
reduces the peak heap usage from ~100M to ~50M.

Reviewers: hvr, austin, bgamari, erikd

Subscribers: thomie

Differential Revision:

3 years agoAdd deepseq dependency and a few NFData instances
Simon Marlow [Thu, 21 Jul 2016 11:32:55 +0000 (04:32 -0700)] 
Add deepseq dependency and a few NFData instances

I needed to rnf a data structure (CompiledByteCode) but we don't have
any good deepseq infrastructure in the compiler yet.  There are bits and
pieces, but nothing consistent, so this is a start.

We already had a dependency on deepseq indirectly via other packages
(e.g. containers).

Includes an update to the haddock submodule, to remove orphan NFData
instances in there.

Test Plan: validate

Reviewers: austin, bgamari, erikd, hvr

Subscribers: thomie

Differential Revision:

3 years agoStgCmmBind: Some minor simplifications
Ömer Sinan Ağacan [Fri, 22 Jul 2016 09:48:42 +0000 (09:48 +0000)] 
StgCmmBind: Some minor simplifications

3 years agoUnboxed sums: More unit tests
Ömer Sinan Ağacan [Fri, 22 Jul 2016 08:37:56 +0000 (08:37 +0000)] 
Unboxed sums: More unit tests

3 years agoRevert "Cleanup PosixSource.h"
Ben Gamari [Fri, 22 Jul 2016 07:45:36 +0000 (09:45 +0200)] 
Revert "Cleanup PosixSource.h"

This reverts commit cac3fb06f4b282eee21159c364c4d08e8fdedce9.

This breaks OS X and Windows.

3 years agoMore typos in comments
Gabor Greif [Thu, 21 Jul 2016 22:32:28 +0000 (00:32 +0200)] 
More typos in comments

3 years agoCorrect a few mistyped words in prose/comments
Gabor Greif [Thu, 21 Jul 2016 22:10:32 +0000 (00:10 +0200)] 
Correct a few mistyped words in prose/comments

3 years agoFix and document Unique generation for sum TyCon and DataCons
Ömer Sinan Ağacan [Thu, 21 Jul 2016 19:59:05 +0000 (19:59 +0000)] 
Fix and document Unique generation for sum TyCon and DataCons

Test Plan: validate

Reviewers: bgamari, austin

Reviewed By: bgamari

Subscribers: thomie

Differential Revision:

3 years agoBump Haddock submodule
Ömer Sinan Ağacan [Thu, 21 Jul 2016 12:26:44 +0000 (12:26 +0000)] 
Bump Haddock submodule

3 years agoComments re ApThunks + small refactor in mkRhsClosure
Simon Peyton Jones [Wed, 20 Jul 2016 14:29:44 +0000 (15:29 +0100)] 
Comments re ApThunks + small refactor in mkRhsClosure

3 years agoComments + tiny refactor of isNullarySrcDataCon
Simon Peyton Jones [Wed, 20 Jul 2016 14:28:37 +0000 (15:28 +0100)] 
Comments + tiny refactor of isNullarySrcDataCon

3 years agoComments only
Simon Peyton Jones [Wed, 20 Jul 2016 14:28:10 +0000 (15:28 +0100)] 
Comments only

3 years agoImplement unboxed sum primitive type
Ömer Sinan Ağacan [Thu, 21 Jul 2016 08:07:41 +0000 (08:07 +0000)] 
Implement unboxed sum primitive type

This patch implements primitive unboxed sum types, as described in

Main changes are:

- Add new syntax for unboxed sums types, terms and patterns. Hidden
  behind `-XUnboxedSums`.

- Add unlifted unboxed sum type constructors and data constructors,
  extend type and pattern checkers and desugarer.

- Add new RuntimeRep for unboxed sums.

- Extend unarise pass to translate unboxed sums to unboxed tuples right
  before code generation.

- Add `StgRubbishArg` to `StgArg`, and a new type `CmmArg` for better
  code generation when sum values are involved.

- Add user manual section for unboxed sums.

Some other changes:

- Generalize `UbxTupleRep` to `MultiRep` and `UbxTupAlt` to
  `MultiValAlt` to be able to use those with both sums and tuples.

- Don't use `tyConPrimRep` in `isVoidTy`: `tyConPrimRep` is really
  wrong, given an `Any` `TyCon`, there's no way to tell what its kind
  is, but `kindPrimRep` and in turn `tyConPrimRep` returns `PtrRep`.

- Fix some bugs on the way: #12375.

Not included in this patch:

- Update Haddock for new the new unboxed sum syntax.

- `TemplateHaskell` support is left as future work.

For reviewers:

- Front-end code is mostly trivial and adapted from unboxed tuple code
  for type checking, pattern checking, renaming, desugaring etc.

- Main translation routines are in `RepType` and `UnariseStg`.
  Documentation in `UnariseStg` should be enough for understanding
  what's going on.


- Johan Tibell wrote the initial front-end and interface file

- Simon Peyton Jones reviewed this patch many times, wrote some code,
  and helped with debugging.

Reviewers: bgamari, alanz, goldfire, RyanGlScott, simonpj, austin,
           simonmar, hvr, erikd

Reviewed By: simonpj

Subscribers: Iceland_jack, ggreif, ezyang, RyanGlScott, goldfire,
             thomie, mpickering

Differential Revision:

3 years agoRevert "Clean up interaction between name cache and built-in syntax"
Ben Gamari [Wed, 20 Jul 2016 17:04:10 +0000 (19:04 +0200)] 
Revert "Clean up interaction between name cache and built-in syntax"

This reverts commit 9513fe6bdeafd35ca1a04e17b5f94732516766aa.

Sadly this broke with -DDEBUG.

3 years agoCompact Regions
Giovanni Campagna [Fri, 15 Jul 2016 18:47:26 +0000 (19:47 +0100)] 
Compact Regions

This brings in initial support for compact regions, as described in the
ICFP 2015 paper "Efficient Communication and Collection with Compact
Normal Forms" (Edward Z. Yang and implemented by Giovanni

Some things may change before the 8.2 release, but I (Simon M.) wanted
to get the main patch committed so that we can iterate.

What documentation there is is in the Data.Compact module in the new
compact package.  We'll need to extend and polish the documentation
before the release.

Test Plan:
(new test cases included)

Reviewers: ezyang, simonmar, hvr, bgamari, austin

Subscribers: vikraman, Yuras, RyanGlScott, qnikst, mboes, facundominguez, rrnewton, thomie, erikd

Differential Revision:

GHC Trac Issues: #11493

3 years agoAdd another testcase for #12082
Ben Gamari [Wed, 20 Jul 2016 15:25:37 +0000 (17:25 +0200)] 
Add another testcase for #12082

Test Plan: Validate, should pass.

Reviewers: austin

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #12082

3 years agotestsuite: Add regression test for #12381
Ben Gamari [Wed, 20 Jul 2016 15:21:35 +0000 (17:21 +0200)] 
testsuite: Add regression test for #12381

Test Plan: Validate

Reviewers: austin

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #12381, #11348

3 years agoClean up interaction between name cache and built-in syntax
Ben Gamari [Wed, 20 Jul 2016 10:34:54 +0000 (12:34 +0200)] 
Clean up interaction between name cache and built-in syntax

This cleans up various aspects of the handling of built-in syntax in the
original name cache (hopefully resulting in a nice reduction in compiler

  * Remove tuple types from original name cache: There is really no
    reason for these to be in the name cache since we already handle
    them specially in interface files to ensure that we can resolve them
    directly to Names, avoiding extraneous name cache lookups.

  * Sadly it's not possible to remove all traces of tuples from the
    name cache, however. Namely we need to keep the tuple type
    representations in since otherwise they would need to be wired-in

  * Remove the special cases for (:), [], and (##) in isBuiltInOcc_maybe
    and rename it to isTupleOcc_maybe

  * Split lookupOrigNameCache into two variants,

     * lookupOrigNameCache': Merely looks up an OccName in the original
       name cache, making no attempt to resolve tuples

     * lookupOrigNameCache: Like the above but handles tuples as well.
       This is given the un-primed name since it does the "obvious"
       thing from the perspective of an API user, who knows nothing of
       our special treatment of tuples.

Arriving at this design took a significant amount of iteration. The
trail of debris leading here can be found in #11357.

Thanks to ezyang and Simon for all of their help in coming to this

Test Plan: Validate

Reviewers: goldfire, simonpj, austin

Reviewed By: simonpj

Subscribers: thomie, ezyang

Differential Revision:

GHC Trac Issues: #11357

3 years agoInstEnv: Ensure that instance visibility check is lazy
Ben Gamari [Wed, 20 Jul 2016 07:56:03 +0000 (09:56 +0200)] 
InstEnv: Ensure that instance visibility check is lazy

Previously instIsVisible had completely broken the laziness of
lookupInstEnv' since it would examine is_dfun_name to check the name of
the defining module (to know whether it is an interactive module). This
resulted in the visibility check drawing in an interface file
unnecessarily. This contributed to the unnecessary regression in
compiler allocations reported in #12367.

Test Plan: Validate, check nofib changes

Reviewers: simonpj, ezyang, austin

Reviewed By: ezyang

Subscribers: thomie, ezyang

Differential Revision:

GHC Trac Issues: #12367

3 years agoUpdate docs for partial type signatures (#12365)
Thomas Winant [Wed, 20 Jul 2016 07:57:04 +0000 (09:57 +0200)] 
Update docs for partial type signatures (#12365)

* Update the sample error messages. The messages have been reworded and
  reformatted since GHC 7.10.

* Mention `TypeApplications` in "Where can they occur?"

* The name of a named wild card is no longer used in the name of a
  resulting type variable. Before: `_foo` => `w_foo`, now: `_foo` => `t`
  or `a`.

Test Plan: generate the users guide

Reviewers: goldfire, austin, bgamari

Reviewed By: bgamari

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #12365

3 years agoData.Either: Add fromLeft and fromRight (#12402)
Dylan Meysmans [Wed, 20 Jul 2016 07:54:55 +0000 (09:54 +0200)] 
Data.Either: Add fromLeft and fromRight (#12402)

Reviewers: austin, hvr, RyanGlScott, bgamari

Reviewed By: RyanGlScott, bgamari

Subscribers: RyanGlScott, thomie

Differential Revision:

GHC Trac Issues: #12402

3 years agoCleanup PosixSource.h
Moritz Angermann [Wed, 20 Jul 2016 07:53:45 +0000 (09:53 +0200)] 
Cleanup PosixSource.h

When trying to build arm64-apple-iso, the build fell over
`strdup`, as the arm64-apple-ios build did not fall into `darwin_HOST_OS`,
and would need `ios_HOST_OS`.

This diff tries to clean up PosixSource.h, instead of layering another
define on top.

As we use `strnlen` in sources that include PosixSource.h, and `strnlen`
is defined in POSIX.1-2008, the `_POSIX_C_SOURCE` and `_XOPEN_SOURCE`
are increased accordingly.

Furthermore the `_DARWIN_C_SOURCE` (required for `u_char`, etc. used in
sysctl.h) define is moved into `OSThreads.h` alongside a similar ifdef
for freebsd.

Test Plan: Build on all supported platforms.

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

Reviewed By: simonmar, bgamari

Subscribers: thomie

Differential Revision:

3 years agoFix bytecode generator panic
Seraphime Kirkovski [Wed, 20 Jul 2016 07:47:23 +0000 (09:47 +0200)] 
Fix bytecode generator panic

This fixes #12128.

The bug was introduced in 1c9fd3f1c5522372fcaf250c805b959e8090a62c.

Test Plan: ./validate

Reviewers: simonmar, austin, hvr, simonpj, bgamari

Reviewed By: bgamari

Subscribers: simonpj, thomie

Differential Revision:

GHC Trac Issues: #12128

3 years agoTcInteract: Add braces to matchClassInst trace output
Ben Gamari [Mon, 18 Jul 2016 18:17:24 +0000 (20:17 +0200)] 
TcInteract: Add braces to matchClassInst trace output

This allows you to easily move to the result in a well-equipped editor.

3 years agoMake Data.{Bifoldable,Bitraversable} -XSafe
Ryan Scott [Wed, 20 Jul 2016 13:15:56 +0000 (09:15 -0400)] 
Make Data.{Bifoldable,Bitraversable} -XSafe

Test Plan:
Previously, `Data.{Bifoldable,Bitraversable}` were being inferred as
`Unsafe` due to a transitive `Data.Coerce` import from `Data.Functor.Utils`.
This rectifies this unfortunate mistake.

Reviewers: austin, hvr, bgamari

Reviewed By: bgamari

Subscribers: thomie, phadej

Differential Revision:

3 years agoSupport SCC pragmas in declaration context
Ömer Sinan Ağacan [Wed, 20 Jul 2016 09:33:43 +0000 (09:33 +0000)] 
Support SCC pragmas in declaration context

Not having SCCs at the top level is becoming annoying real quick. For
simplest cases, it's possible to do this transformation:

    f x y = ...
    f = {-# SCC f #-} \x y -> ...

However, it doesn't work when there's a `where` clause:

    f x y = <t is in scope>
      where t = ...
    f = {-# SCC f #-} \x y -> <t is out of scope>
      where t = ...

Or when we have a "equation style" definition:

    f (C1 ...) = ...
    f (C2 ...) = ...
    f (C3 ...) = ...

(usual solution is to rename `f` to `f'` and define a new `f` with a

This patch implements support for SCC annotations in declaration
contexts. This is now a valid program:

    f x y = ...
        g z = ...
        {-# SCC g #-}
    {-# SCC f #-}

Test Plan: This passes slow validate (no new failures added).

Reviewers: goldfire, mpickering, austin, bgamari, simonmar

Reviewed By: bgamari, simonmar

Subscribers: simonmar, thomie, mpickering

Differential Revision:

3 years agoFix PDF build for the User's Guide.
Gabor Pali [Tue, 19 Jul 2016 16:05:53 +0000 (18:05 +0200)] 
Fix PDF build for the User's Guide.

3 years agoMake okConIdOcc recognize unboxed tuples
Ryan Scott [Mon, 18 Jul 2016 17:51:53 +0000 (13:51 -0400)] 
Make okConIdOcc recognize unboxed tuples

`okConIdOcc`, which validates that a type or constructor name is valid
for splicing using Template Haskell, has a special case for tuples, but
neglects to look for unboxed tuples, causing some sensible Template Haskell
code involving unboxed tuples to be rejected.

Fixes #12407.

Test Plan: make test TEST=T12407

Reviewers: austin, bgamari, hvr, goldfire

Reviewed By: goldfire

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #12407

3 years agoFix Template Haskell reification of unboxed tuple types
Ryan Scott [Mon, 18 Jul 2016 13:29:05 +0000 (09:29 -0400)] 
Fix Template Haskell reification of unboxed tuple types

Previously, Template Haskell reified unboxed tuple types as boxed
tuples with twice the appropriate arity.

Fixes #12403.

Test Plan: make test TEST=T12403

Reviewers: hvr, goldfire, austin, bgamari

Reviewed By: goldfire

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #12403

3 years agoMake DeriveFunctor work with unboxed tuples
Ryan Scott [Mon, 18 Jul 2016 13:28:42 +0000 (09:28 -0400)] 
Make DeriveFunctor work with unboxed tuples

Unboxed tuples have `RuntimeRep` arguments which `-XDeriveFunctor` was
mistaking for actual data constructor arguments. As a result, a derived
`Functor` instance for a datatype that contained an unboxed tuple would
generate twice as many arguments as it needed for an unboxed tuple pattern
match or expression. The solution is to simply put `dropRuntimeRepArgs` in the
right place.

Fixes #12399.

Test Plan: ./validate

Reviewers: austin, hvr, bgamari

Reviewed By: bgamari

Subscribers: thomie, osa1

Differential Revision:

GHC Trac Issues: #12399

3 years agoFix misspellings of the word "instance" in comments
Ryan Scott [Mon, 18 Jul 2016 13:14:36 +0000 (09:14 -0400)] 
Fix misspellings of the word "instance" in comments

[ci skip]

3 years agohp2ps: fix invalid PostScript for names with parentheses
Ben Gamari [Sat, 16 Jul 2016 22:14:04 +0000 (00:14 +0200)] 
hp2ps: fix invalid PostScript for names with parentheses

The names in the .hp files may contain un-matched opening parentheses,
so escape them.

GHC Trac: #9517

Reviewers: bgamari, austin

Reviewed By: bgamari, austin

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #9517

3 years agoPretty: remove a harmful $! (#12227)
Thomas Miedema [Sat, 16 Jul 2016 22:13:45 +0000 (00:13 +0200)] 
Pretty: remove a harmful $! (#12227)

This is backport of [1] for GHC's copy of Pretty. See Note [Differences
between libraries/pretty and compiler/utils/Pretty.hs].


Reviewers: bgamari, austin

Reviewed By: austin

Differential Revision:

GHC Trac Issues: #12227

3 years agoCodeGen: Way to dump cmm only once (#11717)
Vladimir Trubilov [Sat, 16 Jul 2016 22:13:22 +0000 (00:13 +0200)] 
CodeGen: Way to dump cmm only once (#11717)

The `-ddump-cmm` put all stages of Cmm processing into one output.
This patch changes its behavior and adds two more options to make
Cmm dumping flexible.

- `-ddump-cmm-from-stg` dumps only initial version of  Cmm right after
   STG->Cmm codegen
- `-ddump-cmm` dumps the final result of the Cmm pipeline processing
- `-ddump-cmm-verbose` dumps intermediate output of each Cmm pipeline
- `-ddump-cmm-proc` and `-ddump-cmm-caf` seems were lost. Now enabled

Test Plan: ./validate

Reviewers: thomie, simonmar, austin, bgamari

Reviewed By: thomie, simonmar

Subscribers: simonpj, thomie

Differential Revision:

GHC Trac Issues: #11717

3 years agoBugfix for bug 11632: `readLitChar` should consume null characters
Ben Gamari [Sat, 16 Jul 2016 22:12:52 +0000 (00:12 +0200)] 
Bugfix for bug 11632: `readLitChar` should consume null characters

Test Plan: The tests have been included. This change deals with a
relatively minor edge case and should not break unrelated functionality.

Reviewers: thomie, #core_libraries_committee, ekmett, bgamari

Reviewed By: #core_libraries_committee, ekmett, bgamari

Subscribers: bgamari, ekmett

Differential Revision:

GHC Trac Issues: #11632

3 years agoBinary: Use ByteString's copy in getBS
Ben Gamari [Sat, 16 Jul 2016 21:41:46 +0000 (23:41 +0200)] 
Binary: Use ByteString's copy in getBS

It's unclear how much of an effect on runtime this will have, but if
nothing else the code generation may be a tad better since the system's
`memcpy` will be used.

Test Plan: Validate

Reviewers: simonmar, austin

Subscribers: thomie

Differential Revision:

3 years agoIfaceEnv: Only check for built-in OccNames if mod is GHC.Types
Ben Gamari [Sat, 16 Jul 2016 21:38:51 +0000 (23:38 +0200)] 
IfaceEnv: Only check for built-in OccNames if mod is GHC.Types

This check is not entirely cheap and will not succeed unless we are
looking for something in the module where built-in syntax lives,

Reviewers: simonpj, austin

Subscribers: simonpj, thomie, osa1

Differential Revision:

3 years agoLog heap profiler samples to event log
Ben Gamari [Thu, 16 Jun 2016 13:03:01 +0000 (15:03 +0200)] 
Log heap profiler samples to event log

Test Plan: Try it

Reviewers: hvr, simonmar, austin, erikd

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #11094