3 years agoAutoconf: detect and set CFLAGS/CPPFLAGS needed for C99 mode
Herbert Valerio Riedel [Mon, 28 Mar 2016 12:34:22 +0000 (14:34 +0200)] 
Autoconf: detect and set CFLAGS/CPPFLAGS needed for C99 mode

This is the first phase of addressing #11757 which aims to make C99
support a base-line requirement for GHC and clean up the code-base to
use C99 facilities when sensible.

This patch exploits the logic/heuristic used by `AC_PROG_CC_C99` to
determine the flags needed in case the C compiler isn't able to compile
C99 code in its current mode. We can't use `AC_PROG_CC_C99` directly
though because GHC's build-system expects CC to contain a filename
without any flags, while `AC_PROG_CC_C99` would e.g. result in
`CC="gcc -std=gnu99"`. Morever, we support different `CC`s for
stage0/1/2, so we need a version of `AC_PROG_CC_C99` for which we can
specify the `CC`/`CFLAGS` variables to operate on. This is what
`FP_SET_CFLAGS_C99` does.

Note that Clang has been defaulting to C99+ for a long time, while GCC 5
defaults to C99+ as well. So this has mostly an affect on older GCCs
versions prior to 5.0 and possibly compilers other than GCC/Clang (which
are not officially supported for building GHC anyway).

Reviewers: kgardas, erikd, bgamari, austin

Reviewed By: erikd

Differential Revision:

3 years agoDrop Xcode 4.1 hack and fix ignored CC var issue
Herbert Valerio Riedel [Mon, 28 Mar 2016 10:55:21 +0000 (12:55 +0200)] 
Drop Xcode 4.1 hack and fix ignored CC var issue

Xcode 4.1 was released back in 2011 for Mac OSX 10.6/10.7.
However, OSX 10.7 reached EOL sometime around the end of 2014.
So this `--with-gcc-4.2` hack shouldn't be needed anymore.

Moreover, this patch changes ./configure to honor the CC env-var
again (and thus fix #11231) while giving `--with-gcc=...` a higher
priority over `CC=...`.

So the following 3 invocations are equivalent now:

  CC=... ./configure
  ./configure CC=...
  ./configure --with-gcc=...

Since `--with-{gcc,clang}=...` is a misnomer (as is made apparent by
`--with-gcc=clang` or `--with-clang=gcc`), this would give us a neutral
and idiomatic way to tell ./configure which C compiler to use.

Moreover, `./configure --help` says at the end of its output:

  Some influential environment variables:
    CC C compiler command
    CFLAGS C compiler flags
    LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a
nonstandard directory <lib dir>
    LIBS libraries to pass to the linker, e.g. -l<library>
    CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
you have headers in a nonstandard directory <include dir>
    CPP C preprocessor

  Use these variables to override the choices made by `configure' or to help
  it to find libraries and programs with nonstandard names/locations.

Consequently, by honoring CC=... (rather than ignoring it) we increase
consistency and reduce user confusion. Ideally, CC=... would become the
recommended way to set the C compiler, and `--with-{clang,gcc}=...`
would be demoted to legacy aliases.

Reviewed By: erikd, bgamari

Differential Revision:

3 years agoScrap DEC OSF/1 support
Herbert Valerio Riedel [Mon, 28 Mar 2016 10:24:37 +0000 (12:24 +0200)] 
Scrap DEC OSF/1 support

DEC OSF/1 (aka Tru64 UNIX) has been discontinued a few years ago already[1].

This removes the undoubtedly bitrotten support for `OSOsf3 :: OS` from GHC's

Support for `ArchAlpha :: Arch` may be removed at some later point, as there
may still be users out there running a more or less recent Linux/alpha
distribution on their more-than-a-decade old Alpha hardware...


3 years agoScrap IRIX support
Herbert Valerio Riedel [Mon, 28 Mar 2016 09:36:21 +0000 (11:36 +0200)] 
Scrap IRIX support

Long time ago, IRIX was way ahead of its time in the last century with
its SMP capabilities of scaling up to 1024 processors and other features
such as XFS or OpenGL that originated in IRIX and live on to this day in
other operating systems.

However, IRIX's last software update was in 2006 and support ended
around 2013 according to [1], so it's considered an extinct platform by
now. So this commit message is effectively an obituary for GHC's IRIX



3 years agoFix AIX/ppc codegen in `-prof` compilation mode
Herbert Valerio Riedel [Sun, 27 Mar 2016 21:41:12 +0000 (23:41 +0200)] 
Fix AIX/ppc codegen in `-prof` compilation mode

The implementation in df26b95559fd467abc0a3a4151127c95cb5011b9
wrongly assumed that all C-ABI subroutine calls would use a
'ForeignLabel' but it turns out that calls inserted via
'emitRtsCall' use 'CmmLabel's instead.

3 years agoRemove now pointless INLINE_ME macro
Herbert Valerio Riedel [Sun, 27 Mar 2016 19:43:44 +0000 (21:43 +0200)] 
Remove now pointless INLINE_ME macro

At some point there may have been a reason for the
`INLINE_ME` macro, but not anymore...

Reviewed By: austin

Differential Revision:

3 years agoRemove now obsolete LD_STAGE0 hack
Herbert Valerio Riedel [Sun, 27 Mar 2016 18:03:33 +0000 (20:03 +0200)] 
Remove now obsolete LD_STAGE0 hack

This was introduced in 109a1e53287f50103e8a5b592275940b6e3dbb53
but isn't needed anymore because by now we're bootstrapping with
GHC versions which already provide "ld command" in `ghc --info`
(that field was added in GHC 7.8)

3 years agoClarify Note [Kind coercions in Unify]
Richard Eisenberg [Fri, 25 Mar 2016 21:25:25 +0000 (17:25 -0400)] 
Clarify Note [Kind coercions in Unify]

3 years agoCheck for rep poly on wildcard binders.
Richard Eisenberg [Fri, 25 Mar 2016 20:18:09 +0000 (16:18 -0400)] 
Check for rep poly on wildcard binders.

I had just missed this case when adding my test.
This is relevant to ticket #11473.

Also adds lots of comments.

3 years agoFix #11754 by adding an additional check.
Richard Eisenberg [Fri, 25 Mar 2016 19:11:24 +0000 (15:11 -0400)] 
Fix #11754 by adding an additional check.

This was just plain wrong previously.

Test case: typecheck/should_compile/T11754

3 years agoRTS: Fix & refactor "portable inline" macros
Herbert Valerio Riedel [Fri, 25 Mar 2016 23:59:31 +0000 (00:59 +0100)] 
RTS: Fix & refactor "portable inline" macros

Turns out the current macros for gnu90-style inline
semantics stopped working with GCC 5
(and possibly also with Apple's GCC) which switched on
`__GNUC_STDC_INLINE__` by default falling back to using the
suboptimal `static inline` mode.

However, C99 supports an equivalent (as far as our
use-case is concerned) `extern inline` mode.

See also
for a write-up of gnu90 vs C99 semantics.

This patch also removes the MSVC case as VS2015 is supposed
to finally catch up to C99 (and C11), so we don't need any
special care for MSVC anymore.

Reviewed By: erikd, austin

Differential Revision:

3 years agoDWARF: Add debugging information chapter to users guide
Ben Gamari [Fri, 25 Mar 2016 23:44:21 +0000 (00:44 +0100)] 
DWARF: Add debugging information chapter to users guide

Test Plan: Proof-read

Reviewers: scpmw, austin

Subscribers: simonmar, thomie

Differential Revision:

3 years agotestsuite: Identify framework failures in testsuite summary
Ben Gamari [Fri, 25 Mar 2016 23:43:24 +0000 (00:43 +0100)] 
testsuite: Identify framework failures in testsuite summary

Currently the testsuite driver tells you how many tests failed due to a
framework failure but you need to manually grep through the testsuite
output to identify which ones.

Test Plan: Validate with, e.g., a timing out testcase

Reviewers: austin, thomie

Reviewed By: austin, thomie

Differential Revision:

GHC Trac Issues: #11165

3 years agoPanic: Try outputting SDocs
Ben Gamari [Fri, 25 Mar 2016 23:42:27 +0000 (00:42 +0100)] 
Panic: Try outputting SDocs

This works in conjunction with D2036 to allow useful debug output before
DynFlags has been initializated.

See #11755.

Reviewers: austin

Reviewed By: austin

Subscribers: thomie, gridaphobe

Differential Revision:

GHC Trac Issues: #11755

3 years agoDynFlags: Initialize unsafeGlobalDynFlags enough to be useful
Ben Gamari [Fri, 25 Mar 2016 23:42:11 +0000 (00:42 +0100)] 
DynFlags: Initialize unsafeGlobalDynFlags enough to be useful

Previously unsafeGlobalDynFlags would bottom if used prior to
initialization. This meant that any attempt to use the pretty-printer
early in the initialization process of the compiler would fail. This is
quite inconvenient.

Here we initialize unsafeGlobalDynFlags with defaultDynFlags, bottoming
only if settings is accessed.

See #11755.

Test Plan: Validate

Reviewers: austin

Reviewed By: austin

Subscribers: thomie, gridaphobe

Differential Revision:

GHC Trac Issues: #11755

3 years agoMore clarification in docs for implicit quantification
Simon Peyton Jones [Fri, 25 Mar 2016 10:41:57 +0000 (10:41 +0000)] 
More clarification in docs for implicit quantification

This is a follow-up patch to the previous one for #11726.
It turns out that I'd missed the point of the ticket; this
patch addresses it.

3 years agoDocument implicit quantification better
Simon Peyton Jones [Fri, 25 Mar 2016 10:32:13 +0000 (10:32 +0000)] 
Document implicit quantification better

Addresses Trac #11726

3 years agoTest Trac #11728
Simon Peyton Jones [Fri, 25 Mar 2016 10:22:07 +0000 (10:22 +0000)] 
Test Trac #11728

3 years agoA raft of comments about TyBinders
Simon Peyton Jones [Fri, 25 Mar 2016 09:28:31 +0000 (09:28 +0000)] 
A raft of comments about TyBinders

I had a conversation with Richard about TyBinders
and VisibilityFlags.  This patch adds a lot of comments
to explain what is going on.  I feel much more secure now.

Richard please check.

3 years agoCorePrep: refactoring to reduce duplication
Simon Peyton Jones [Fri, 25 Mar 2016 09:25:34 +0000 (09:25 +0000)] 
CorePrep: refactoring to reduce duplication

There's no functional change here, just tidying up

3 years agoDo not eta-reduce across Ticks in CorePrep
Simon Peyton Jones [Fri, 25 Mar 2016 09:23:17 +0000 (09:23 +0000)] 
Do not eta-reduce across Ticks in CorePrep

The function tryEtaReducePrep was being over-ambitious.
When Breakpoint ticks were involved (i.e. in GHCi), eta
reduction left an out-of-scope variable in the Tick.

Easily fixed. Fixes the original report in Trac #111728.

3 years agoAn extra traceTc in tcExpr for ExprWithSig
Simon Peyton Jones [Thu, 24 Mar 2016 20:53:14 +0000 (20:53 +0000)] 
An extra traceTc in tcExpr for ExprWithSig

3 years agobase: Fix GHC.Word and GHC.Int on 32-bit platforms
Ben Gamari [Thu, 24 Mar 2016 23:48:22 +0000 (00:48 +0100)] 
base: Fix GHC.Word and GHC.Int on 32-bit platforms

Due to a cut-and-paste error D1980 (#11688) broke 32-bit platforms. This
should fix it.

See #11750.

3 years agoRemove code-duplication in the PPC NCG
Herbert Valerio Riedel [Thu, 24 Mar 2016 22:24:08 +0000 (23:24 +0100)] 
Remove code-duplication in the PPC NCG

Reviewed By: bgamari, trommler

Differential Revision:

3 years agoAdd NCG support for AIX/ppc32
Herbert Valerio Riedel [Thu, 24 Mar 2016 20:00:17 +0000 (21:00 +0100)] 
Add NCG support for AIX/ppc32

This extends the previous work to revive the unregisterised GHC build
for AIX/ppc32. Strictly speaking, AIX runs on POWER4 (and later)
hardware, but the PPC32 instructions implemented in the PPC NCG
represent a compatible subset of the POWER4 ISA.

IBM AIX follows the PowerOpen ABI (and shares many similiarites with the
Linux PPC64 ELF V1 NCG backend) but uses the rather limited XCOFF
format (compared to ELF).

This doesn't support dynamic libraries yet.

A major limiting factor is that the AIX assembler does not support the
`@ha`/`@l` relocation types nor the ha16()/lo16() functions Darwin's
assembler supports. Therefore we need to avoid emitting those. In case
of numeric literals we simply compute the functions ourselves, while for
labels we have to use local TOCs and hope everything fits into a 16bit
offset (for ppc32 this gives us at most 16384 entries per TOC section,
which is enough to compile GHC).

Another issue is that XCOFF doesn't seem to have a relocation type for
label-differences, and therefore the label-differences placed into
tables-next-to-code can't be relocated, but the linker may rearrange
different sections, so we need to place all read-only sections into the
same `.text[PR]` section to workaround this.

Finally, the PowerOpen ABI distinguishes between function-descriptors
and actualy entry-point addresses. For AIX we need to be specific when
emitting assembler code whether we want the address of the function
descriptor `printf`) or for the entry-point (`.printf`). So we let the
asm pretty-printer prefix a dot to all emitted subroutine
calls (i.e. `BL`) on AIX only. For now, STG routines' entry-point labels
are not prefixed by a label and don't have any associated

Reviewers: austin, trommler, erikd, bgamari

Reviewed By: trommler, erikd, bgamari

Differential Revision:

3 years agoAdd option `no-keep-hi-files` and `no-keep-o-files` (fixes #4114)
Kai Harries [Thu, 24 Mar 2016 21:33:27 +0000 (22:33 +0100)] 
Add option `no-keep-hi-files` and `no-keep-o-files` (fixes #4114)

Summary: Remove `.hi` and `.o` files if the flags `no-keep-hi-files` and
`no-keep-o-files` are given.

Test Plan: ./validate

Reviewers: austin, thomie, bgamari

Reviewed By: thomie, bgamari

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #4114

3 years agousers_guide: small improvements on pattern synonyms.
Dominik Bollmann [Thu, 24 Mar 2016 21:32:56 +0000 (22:32 +0100)] 
users_guide: small improvements on pattern synonyms.

Since the order of required and provided constraint contexts of pattern
synonyms has been switched recently, I updated a couple places in the
users guide's pattern synonym section to accommodate for this.

Test Plan: read it :-)

Reviewers: goldfire, thomie, mpickering, simonpj, austin, bgamari

Reviewed By: bgamari

Differential Revision:

3 years agousers-guide: Add -Wredundant-constraints to flags reference
Ben Gamari [Thu, 24 Mar 2016 21:32:20 +0000 (22:32 +0100)] 
users-guide: Add -Wredundant-constraints to flags reference

Test Plan: Validate and read

Reviewers: austin

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #11741

3 years agousers_guide: Fix various issues
Ben Gamari [Thu, 24 Mar 2016 21:32:04 +0000 (22:32 +0100)] 
users_guide: Fix various issues

Sphinx apparently expects references to anchors that don't accompany a
header to have a caption.

Test Plan: validate

Reviewers: austin

Subscribers: thomie

Differential Revision:

3 years agoAvoid local label syntax for assembler on AIX
Herbert Valerio Riedel [Thu, 24 Mar 2016 19:35:42 +0000 (20:35 +0100)] 
Avoid local label syntax for assembler on AIX

Unfortunately (for inline `__asm__()` uses), IBM's `as` doesn't seem to support
local labels[1] like GNU `as` does so we need to workaround this when on AIX.


Turns out this also addresses the long-standing bug #485

Reviewed By: bgamari, trommler

Differential Revision:

3 years agoTidy up handling of coercion variables
Simon Peyton Jones [Thu, 24 Mar 2016 17:31:12 +0000 (17:31 +0000)] 
Tidy up handling of coercion variables

* Comments to explain that a CoVar, whose IdInfo is CoVarId,
  is always unlifted (but may be nominal or representational role)

  And TyCoRep.isCoercionType picks out only those unlifted
  types, NOT the lifted versions

* Introduce Var.NcId for non-co-var Ids
  with predicate isNonCoVarId

* Add assertions in CoreSubst that the Id env is only
  used for NcIds

* Fix lurking bug in CSE which extended the
  CoreSubst Id env with a CoVar

* Fix two bugs in Specialise.spec_call, which wrongly treated
  CoVars like NcIds
    - needed a varToCoreExpr in one place
    - needed extendSubst not extendIdSubst in another
  This was the root cause of Trac #11644

Minor refactoring

* Eliminate unused mkDerivedLocalCoVarM, mkUserLocalCoVar
* Small refactor in mkSysLocalOrCoVar

3 years agoComments only
Simon Peyton Jones [Thu, 24 Mar 2016 17:21:56 +0000 (17:21 +0000)] 
Comments only

3 years agoDefer inlining of Eq for primitive types
Ben Gamari [Thu, 24 Mar 2016 10:24:32 +0000 (11:24 +0100)] 
Defer inlining of Eq for primitive types

This is one solution to #11688, wherein (==) was inlined to soon
defeating a rewrite rule provided by bytestring. Since the RHSs of Eq's
methods are simple, there is little to be gained and much to be lost by
inlining them early.

For instance, the bytestring library provides,

break :: (Word8 -> Bool) -> ByteString -> (ByteString, ByteString)
breakByte :: Word8 -> ByteString -> (ByteString, ByteString)

and a rule

forall x. break ((==) x) = breakByte x

since `breakByte` implments an optimized version of `break (== x)` for
known `x :: Word8`. If we allow `(==)` to be inlined too early, we will
prevent this rule from firing. This was the cause of #11688.

This patch just defers the `Eq` methods, although it's likely worthwhile
giving `Ord` this same treatment. This regresses compiler allocations
for T9661 by about 8% due to the additional inlining that we now require
the simplifier to perform.

Updates the `bytestring` submodule to include updated rewrite rules
which match on `eqWord8` instead of `(==)`.

Test Plan:
 * Validate, examine performance impact

Reviewers: simonpj, hvr, austin

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #11688

3 years agoDefault RuntimeRep variables unless -fprint-explicit-runtime-reps
Ben Gamari [Thu, 24 Mar 2016 10:39:59 +0000 (11:39 +0100)] 
Default RuntimeRep variables unless -fprint-explicit-runtime-reps

Addresses #11549 by defaulting `RuntimeRep` variables to `PtrRepLifted`
and adding a new compiler flag `-fprint-explicit-runtime-reps` to
disable this behavior.

This is just a guess at the right way to go about this. If it's
wrong-beyond-any-hope just say so.

Test Plan: Working on a testcase

Reviewers: goldfire, austin

Subscribers: simonpj, thomie

Differential Revision:

GHC Trac Issues: #11549

3 years agoShow: Restore redundant parentheses around records
Ben Gamari [Thu, 24 Mar 2016 09:54:11 +0000 (10:54 +0100)] 
Show: Restore redundant parentheses around records

As discussed in #2530 we are going to continue to produce parentheses
here in order to preserve compatibility with previous GHC releases. It
was found that dropped parentheses would break some testsuites which
compared against output from Show. This has been documented in the users

This reverts commit 5692643c9d17e746327588cd6157a923642b7975.

Test Plan: Validate

Reviewers: hvr, austin

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #2350

3 years agoRevert "Various ticky-related work"
Ben Gamari [Thu, 24 Mar 2016 10:23:31 +0000 (11:23 +0100)] 
Revert "Various ticky-related work"

This reverts commit 6c2c853b11fe25c106469da7b105e2be596c17de which was
supposed to be merged as individual commits.

3 years agoAdd expected output for T9405
Ben Gamari [Thu, 24 Mar 2016 09:52:56 +0000 (05:52 -0400)] 
Add expected output for T9405

3 years agoDsExpr: Rip out static/dynamic check in list desugaring
Ben Gamari [Wed, 23 Mar 2016 16:24:45 +0000 (17:24 +0100)] 
DsExpr: Rip out static/dynamic check in list desugaring

Previously we would try to break explicit lists into a dynamic prefix
and static tail and desugar the former into a `build` expression.
Unfortunately, this heuristic resulted in surprising behavior
(see #11710) and wasn't pulling its weight. Here we drop it (along with
the `-fsimple-list-literals` flag), leaving only the list length
heuristic to determine whether `build` or cons list desugaring should be

Test Plan: Validate

Reviewers: simonpj, austin

Reviewed By: simonpj

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #11710

3 years agoCreate empty dump files (fixes #10320)
Kai Harries [Wed, 23 Mar 2016 15:21:52 +0000 (16:21 +0100)] 
Create empty dump files (fixes #10320)

Test Plan: ./validate

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #10320

3 years agoVarious ticky-related work
Joachim Breitner [Wed, 23 Mar 2016 15:20:36 +0000 (16:20 +0100)] 
Various ticky-related work

this Diff contains small, self-contained changes as I work towards
fixing #10613. It is mostly created to let harbormaster do its job, but
feedback is welcome as well.

Please do not merge this via arc; I’d like to push the individual
patches as layed out here. I might push mostly trivial ones even without
review, as long as the build passes.

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: thomie

Differential Revision:

3 years agoAdd unicode syntax for banana brackets
Josh Price [Wed, 23 Mar 2016 15:19:01 +0000 (16:19 +0100)] 
Add unicode syntax for banana brackets

Add "⦇" and "⦈" as unicode alternatives for "(|" and "|)" respectively.

This must be implemented differently than other unicode additions
because ⦇" and "⦈" are interpretted as a $unigraphic rather than
a $unisymbol.

Test Plan: validate

Reviewers: goldfire, bgamari, austin

Reviewed By: bgamari, austin

Subscribers: thomie, mpickering

Differential Revision:

GHC Trac Issues: #10162

3 years agoClose ticky profiling file stream after printing (#9405)
Flaviu Andrei Csernik [Wed, 23 Mar 2016 15:18:11 +0000 (16:18 +0100)] 
Close ticky profiling file stream after printing (#9405)

Test Plan: T9405

Reviewers: simonmar, austin, bgamari

Reviewed By: simonmar, bgamari

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #9405

3 years agoAdd `PatSynSigSkol` and modify `PatSynCtxt`
Rik Steenkamp [Wed, 23 Mar 2016 15:17:27 +0000 (16:17 +0100)] 
Add `PatSynSigSkol` and modify `PatSynCtxt`

As the type of a pattern synonym cannot in general be represented by a
value of type Type, we cannot use a value `SigSkol (PatSynCtxt n) (Check
ty)` to represent the signature of a pattern synonym (this causes
incorrect signatures to be printed in error messages). Therefore we now
represent it by a value `PatSynSigSkol n` (instead of incorrect
signatures we simply print no explicit signature).

Furthermore, we rename `PatSynCtxt` to `PatSynBuilderCtxt`, and use
`SigSkol (PatSynBuilderCtxt n) (Check ty)` to represent the type of a
bidirectional pattern synonym when used in an expression context.
Before, this type was represented by a value `SigSkol (PatSynCtxt n)
(Check ty)`, which caused incorrect error messages.

Also, in `mk_dict_err` of `typecheck\TcErrors.hs` we now distinguish
between all enclosing implications and "useful" enclosing implications,
for better error messages concerning pattern synonyms. See `Note [Useful

See the Phabricator page for examples.

Reviewers: mpickering, goldfire, simonpj, austin, bgamari

Reviewed By: bgamari

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #11667

3 years agoErrUtils: Add timings to compiler phases
Ben Gamari [Wed, 23 Mar 2016 15:11:45 +0000 (16:11 +0100)] 
ErrUtils: Add timings to compiler phases

This adds timings and allocation figures to the compiler's output when
run with `-v2` in an effort to ease performance analysis.

  * Documentation
  * Where else should we add these?
  * Perhaps we should remove some of the now-arguably-redundant
    `showPass` occurrences where they are
  * Must we force more?
  * Perhaps we should place this behind a `-ftimings` instead of `-v2`

Test Plan: `ghc -v2 Test.hs`, look at the output

Reviewers: hvr, goldfire, simonmar, austin

Reviewed By: simonmar

Subscribers: angerman, michalt, niteria, ezyang, thomie

Differential Revision:

3 years agoEnsure T9646 dump-simpl output is cleaned
Ben Gamari [Sun, 20 Mar 2016 23:49:24 +0000 (00:49 +0100)] 
Ensure T9646 dump-simpl output is cleaned

3 years agobase: Fix ClockGetTime on OS X
Ben Gamari [Wed, 23 Mar 2016 16:25:26 +0000 (17:25 +0100)] 
base: Fix ClockGetTime on OS X

Apparently _POSIX_CPUTIME may be defined as -1 if

Test Plan: Validate

Reviewers: austin, hvr, erikd, goldfire

Reviewed By: erikd, goldfire

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #11733

3 years agoFix regression test for #11145.
Dominik Bollmann [Thu, 24 Mar 2016 09:11:46 +0000 (10:11 +0100)] 
Fix regression test for #11145.

Test Plan: ./validate

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #11145

3 years agoMove DFunUnfolding generation to TcInstDcls
Simon Peyton Jones [Wed, 23 Mar 2016 15:37:50 +0000 (15:37 +0000)] 
Move DFunUnfolding generation to TcInstDcls

The desugarer had a fragile case to generate the Unfolding for a
DFun. This patch moves the unfolding generation to TcInstDcls, where
all the pieces are to hand.

Fixes Trac #11742

3 years agoMove applyTysX near piResultTys
Simon Peyton Jones [Mon, 21 Mar 2016 12:51:40 +0000 (12:51 +0000)] 
Move applyTysX near piResultTys

3 years agoComment fix
Simon Peyton Jones [Thu, 17 Mar 2016 08:50:23 +0000 (08:50 +0000)] 
Comment fix

3 years agoAvoid running afoul of the zipTvSubst check.
Richard Eisenberg [Tue, 22 Mar 2016 02:35:41 +0000 (22:35 -0400)] 
Avoid running afoul of the zipTvSubst check.

addDataConStupidTheta includes comments that the types list
might be longer than the tvs list. And the check in zipTvSubst
doesn't appear to be terribly recent. I am utterly flummoxed
as to why this worked before. It was clearly just broken.
And now it's fixed.

3 years agoUse the correct in-scope set in coercionKind
Bartosz Nitka [Mon, 21 Mar 2016 18:11:26 +0000 (11:11 -0700)] 
Use the correct in-scope set in coercionKind

The free vars of `ty2` need to be in scope to satisfy the substitution
As far as I can tell we don't have the free vars of `ty2` when
substituting, so unfortunately we have to compute them.

Test Plan: ./validate

Reviewers: austin, bgamari, simonpj, goldfire

Subscribers: thomie, simonmar

Differential Revision:

GHC Trac Issues: #11371

3 years agoPPC NCG: Emit more portable `fcmpu 0, ...` instead of `fcmpu cr0, ...`
Herbert Valerio Riedel [Mon, 21 Mar 2016 10:30:03 +0000 (11:30 +0100)] 
PPC NCG: Emit more portable `fcmpu 0, ...` instead of `fcmpu cr0, ...`

Use `fcmpu 0, ...` rather than `fcmpu cr0, ...` for better
portability since some non-GNU assembler (such as IBM's `as`) tend to not
support the symbolic register name `cr0`. This matches the syntax that
GCC emits for PPC targets.

3 years agoComments (only) in TcFlatten
Richard Eisenberg [Mon, 21 Mar 2016 21:03:38 +0000 (17:03 -0400)] 
Comments (only) in TcFlatten

3 years agostgMallocBytes: Tolerate malloc(0) returning a NULL ptr
Herbert Valerio Riedel [Mon, 21 Mar 2016 20:40:23 +0000 (21:40 +0100)] 
stgMallocBytes: Tolerate malloc(0) returning a NULL ptr

This is valid behaviour for `malloc()` according to ISO C99 and POSIX,
and there's at least one operating system (AIX) which actually does return
NULL for 0-sized allocations.

The `createAdjustor()` routine is currently the only known use-site of
`stgMallocBytes` which may call `stgMallocBytes()` requesting a 0-size

Reviewed By: bgamari, austin

Differential Revision:

3 years agoImprove panicking output
Richard Eisenberg [Mon, 21 Mar 2016 03:15:13 +0000 (23:15 -0400)] 
Improve panicking output

3 years agoFix #11723 and #11724.
Richard Eisenberg [Sat, 19 Mar 2016 21:19:04 +0000 (17:19 -0400)] 
Fix #11723 and #11724.

Test cases: typecheck/should_fail/T1172{3,4}

3 years agoZonk before calling splitDepVarsOfType.
Richard Eisenberg [Mon, 21 Mar 2016 15:08:10 +0000 (11:08 -0400)] 
Zonk before calling splitDepVarsOfType.

It was Utterly Wrong before.

Note to self: Never, ever take the free vars of an unzonked type.

3 years agoTrack specified/invisible more carefully.
Richard Eisenberg [Sat, 19 Mar 2016 20:55:50 +0000 (16:55 -0400)] 
Track specified/invisible more carefully.

In particular, this allows correct tracking of specified/invisible
for variables in Haskell98 data constructors and in pattern synonyms.
GADT-syntax constructors are harder, and are left until #11721.

This was all inspired by Simon's comments to my fix for #11512,
which this subsumes.

Test case: ghci/scripts/TypeAppData

[skip ci]  (The test case fails because of an unrelated problem
fixed in the next commit.)

3 years agoComment a suspicious zonk in TcFlatten.
Richard Eisenberg [Sat, 19 Mar 2016 02:37:37 +0000 (22:37 -0400)] 
Comment a suspicious zonk in TcFlatten.

3 years agoPrevent eager unification with type families.
Richard Eisenberg [Sat, 19 Mar 2016 02:36:34 +0000 (22:36 -0400)] 
Prevent eager unification with type families.

See Note [Prevent unification with type families]
in TcUnify for the details.

3 years agoRename test for #11334 to 11334b, fixing conflict
Richard Eisenberg [Sat, 19 Mar 2016 01:40:04 +0000 (21:40 -0400)] 
Rename test for #11334 to 11334b, fixing conflict

3 years agoMake equality print better. (#11712)
Richard Eisenberg [Fri, 18 Mar 2016 15:20:31 +0000 (11:20 -0400)] 
Make equality print better. (#11712)

3 years agoFix #11635 / #11719.
Richard Eisenberg [Fri, 18 Mar 2016 15:02:38 +0000 (11:02 -0400)] 
Fix #11635 / #11719.

Instead of creating a new meta-tyvar and then unifying it with
a known kind in a KindedTyVar in a LHsQTyVars, just use the known kind.

Sadly, this still doesn't make #11719 usable, because while you can
now define a higher-kinded type family, you can't write any equations
for it, which is a larger problem.

test cases: dependent/should_compile/T{11635,11719}

3 years agoAdd two small optimizations. (#11196)
Richard Eisenberg [Fri, 18 Mar 2016 13:40:15 +0000 (09:40 -0400)] 
Add two small optimizations. (#11196)

- Optimize zonking * to avoid allocation.
- Try to avoid looking at the free variables of a type in the
  pure unifier. We need look at the variables only in the case
  of a forall.

The performance results updates included in this also include
a regression, but the regression is not due to this patch. When
validating previous patches, the test case failed, but I was
unable to reproduce outside of validation, so I let it go by, thinking
the failure was spurious. Upon closer inspection, the perf number
was right at the line, and the wibble between a valiation environment
and a regular test run was enough to make the difference.

3 years agoTypeApplications does not imply AllowAmbiguousTypes
Richard Eisenberg [Thu, 17 Mar 2016 21:49:28 +0000 (17:49 -0400)] 
TypeApplications does not imply AllowAmbiguousTypes

3 years agoFix exponential algorithm in pure unifier.
Richard Eisenberg [Thu, 17 Mar 2016 19:40:58 +0000 (15:40 -0400)] 
Fix exponential algorithm in pure unifier.

3 years agoRemove unused substTyWithBinders functions
Bartosz Nitka [Mon, 21 Mar 2016 12:33:44 +0000 (05:33 -0700)] 
Remove unused substTyWithBinders functions

Originally I wanted to only remove substTyWithBindersUnchecked, but
since both of them are unused maybe we don't need them.

Test Plan: ./validate

Reviewers: austin, goldfire, bgamari, simonpj

Reviewed By: simonpj

Subscribers: thomie, simonmar

Differential Revision:

GHC Trac Issues: #11371

3 years agoRemove unnecessary Ord instance for ConLike
Bartosz Nitka [Mon, 21 Mar 2016 10:34:03 +0000 (03:34 -0700)] 
Remove unnecessary Ord instance for ConLike

The Ord instance for ConLike uses Unique order which is bad for
determinism. Fortunately it's not used, so we can just delete it.
The is part of the effort to make Unique comparisons explicit.

Test Plan: ./validate

Reviewers: austin, simonmar, bgamari, simonpj

Reviewed By: simonpj

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #4012

3 years agoDelete a misleading comment in TyCon
Bartosz Nitka [Mon, 21 Mar 2016 10:30:59 +0000 (03:30 -0700)] 
Delete a misleading comment in TyCon

`Ord` for `TyCon` uses `Uniques` and it's not lexicographic.
I did some archeology and in
rGHC6c381e873e222417d9a67aeec77b9555eca7b7a8 the comment was introduced,
where there was something like `Ord3 Tycon` which *was* lexicographic.
In rGHC9dd6e1c216993624a2cd74b62ca0f0569c02c26b `Ord3 TyCon` was already
not lexicographic and `Ord3` got removed.

Test Plan: make someone take a look

Reviewers: hvr, austin, bgamari

Reviewed By: bgamari

Subscribers: thomie, simonmar

Differential Revision:

3 years agobase: Fix CPUTime on Windows
Ben Gamari [Sun, 20 Mar 2016 21:15:46 +0000 (22:15 +0100)] 
base: Fix CPUTime on Windows

Arg, silly CPP.

3 years agoT11145: Fix expected output
Ben Gamari [Sun, 20 Mar 2016 19:44:19 +0000 (20:44 +0100)] 
T11145: Fix expected output

The uniques seem to keep changing here.

3 years agobase: Rework System.CPUTime
Ben Gamari [Sun, 20 Mar 2016 16:56:24 +0000 (17:56 +0100)] 
base: Rework System.CPUTime

This started when I noticed that `getCPUTime` only provides 1
millisecond resolution on Linux. Unfortunately the previous
implementation was quite unmaintainable, so this ended up being a bit
more involved than I expected.

Here we do several things,

 * Split up `System.CPUTime`

 * Add support for `clock_gettime`, allowing for significantly more
   precise timing information when available

 * Fix System.CPUTime resolution for Windows. While it's hard to get
   reliable numbers, the consensus is that Windows only provides 16
   millisecond resolution in GetProcessTimes (see Python PEP 0418 [1])

 * Eliminate terrible hack wherein we would cast between `CTime` and
   `Integer` through `Double`


Test Plan: Validate on various platforms

Reviewers: austin, hvr, erikd

Reviewed By: erikd

Subscribers: thomie

Differential Revision:

3 years agoAdd test for incompatible flags (issue #11580)
Kai Harries [Sun, 20 Mar 2016 16:51:39 +0000 (17:51 +0100)] 
Add test for incompatible flags (issue #11580)

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #11580

3 years agoDsExpr: Don't build/foldr huge lists
Ben Gamari [Sun, 20 Mar 2016 16:49:58 +0000 (17:49 +0100)] 
DsExpr: Don't build/foldr huge lists

Desugaring long lists with build trades large static data for large
code, which is likely a poor trade-off. See #11707.

Test Plan: Validate, nofib

Reviewers: simonpj, austin

Reviewed By: austin

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #11707

3 years agoprof: Fix heap census for large ARR_WORDS (#11627)
Jason Eisenberg [Sun, 20 Mar 2016 16:49:24 +0000 (17:49 +0100)] 
prof: Fix heap census for large ARR_WORDS (#11627)

The heap census now handles large ARR_WORDS objects which have
been shrunk by shrinkMutableByteArray# or resizeMutableByteArray#.

Test Plan: ./validate && make test WAY=profasm

Reviewers: hvr, bgamari, austin, thomie

Reviewed By: thomie

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #11627

3 years agoDwarf: Add support for labels in unwind expressions
Ben Gamari [Sun, 20 Mar 2016 16:47:57 +0000 (17:47 +0100)] 
Dwarf: Add support for labels in unwind expressions

Test Plan: Look at DWARF output.

Reviewers: scpmw, austin

Reviewed By: austin

Subscribers: thomie

Differential Revision:

3 years agoFix T9646
Ben Gamari [Sun, 20 Mar 2016 15:47:31 +0000 (16:47 +0100)] 
Fix T9646

For #9646.

3 years agoFix duplicate T11334 test
Ben Gamari [Sun, 20 Mar 2016 15:02:32 +0000 (16:02 +0100)] 
Fix duplicate T11334 test

3 years agoRevert "Add test for #11473"
Ben Gamari [Fri, 18 Mar 2016 15:49:13 +0000 (16:49 +0100)] 
Revert "Add test for #11473"

This reverts commit 89bdac7635e6ed08927d760aa885d3e7ef3edb81 as
this test is duplicated with dependent/should_fail/T11473, added by

3 years agoEnsure T11702 always runs with optasm
Ben Gamari [Wed, 16 Mar 2016 09:00:12 +0000 (10:00 +0100)] 
Ensure T11702 always runs with optasm

3 years agoMark GHC.Real.even and odd as INLINEABLE
Ben Gamari [Mon, 14 Mar 2016 12:27:23 +0000 (13:27 +0100)] 
Mark GHC.Real.even and odd as INLINEABLE

Previously they were merely specialised at Int and Integer. It seems to
me that these are cheap enough to be worth inlining. See #11701 for

Test Plan: Validate

Reviewers: austin, hvr, simonpj

Reviewed By: simonpj

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #11701

3 years agoPrelRules: Fix constant folding for WordRemOp
Ben Gamari [Mon, 14 Mar 2016 12:27:00 +0000 (13:27 +0100)] 
PrelRules: Fix constant folding for WordRemOp

Test Plan: Validate with testcase in D2002

Reviewers: austin, simonpj

Reviewed By: simonpj

Subscribers: simonpj, thomie

Differential Revision:

GHC Trac Issues: #11702

3 years agoAdd test for #9646
Erik de Castro Lopo [Wed, 16 Mar 2016 09:19:28 +0000 (20:19 +1100)] 
Add test for #9646

Test Plan: Test that it passes git HEAD and fails with GHC 7.8.

Reviewers: bgamari, hvr, austin, goldfire, thomie

Differential Revision:

GHC Trac Issues: #9646

3 years agoFix #11512 by getting visibility right for methods
Richard Eisenberg [Thu, 17 Mar 2016 03:37:30 +0000 (23:37 -0400)] 
Fix #11512 by getting visibility right for methods

Test case: typecheck/should_compile/T11512

3 years agoFix #11716.
Richard Eisenberg [Wed, 16 Mar 2016 19:20:32 +0000 (15:20 -0400)] 
Fix #11716.

There were several smallish bugs here:
 - We had too small an InScopeSet when rejigging GADT return types.
 - When adding the extra_tvs with a datatype kind signature, we
   were sometimes changing Uniques of an explicitly bound kind var.
 - Using coercionKind in the flattener got the wrong visibility
   for a binder. Now we just zonk to get what we need.

Test case: dependent/should_compile/RaeJobTalk

3 years agotypechecker: fix trac issue #11708
Csongor Kiss [Wed, 16 Mar 2016 19:26:59 +0000 (15:26 -0400)] 
typechecker: fix trac issue #11708

Summary: Fixes T11708

Reviewers: austin, bgamari, goldfire, simonpj

Reviewed By: goldfire, simonpj

Subscribers: simonpj, goldfire, thomie

Differential Revision:

GHC Trac Issues: #11708

3 years agoFix #11711.
Richard Eisenberg [Wed, 16 Mar 2016 18:30:00 +0000 (14:30 -0400)] 
Fix #11711.

There were two bugs here, both simple: we need to filter out
covars before calling isMetaTyVar in the solver, and TcPat had
a tcSubType the wrong way round.

test case: dependent/should_compile/T11711

3 years agoDriverPipeline: Fix 'unused arguments' warnings from Clang
Erik de Castro Lopo [Sun, 13 Mar 2016 04:28:11 +0000 (15:28 +1100)] 
DriverPipeline: Fix 'unused arguments' warnings from Clang

When using Clang as the C compiler, over 100 tests were failing
due to Clang reporting that some command line arguments were not
being used. These warnings only occur when Clang is compiling
assembler files which happens in two places, one of which already
conditionally adding `-Qunused-arguments` to the command line when
the compiler was Clang. This fixes the other.

Test Plan: validate with clang as the C compiler

Reviewers: bgamari, hvr, austin, rwbarton

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #11684

3 years agoClean up some pretty-printing in errors.
Richard Eisenberg [Tue, 15 Mar 2016 20:56:51 +0000 (16:56 -0400)] 
Clean up some pretty-printing in errors.

It turns out that there were some pretty egregious mistakes
in the code that suggested -fprint-explicit-kinds, which are
fixed. This commit also reorders a bunch of error messages,
which I think is an improvement.

This also adds the test case for #11471, which is what
triggered the cleanup in TcErrors. Now that #11473 is done,
there is nothing more outstanding for #11471.

test case: dependent/should_fail/T11471

3 years agoFix printing of "kind" vs. "type"
Richard Eisenberg [Tue, 15 Mar 2016 18:54:48 +0000 (14:54 -0400)] 
Fix printing of "kind" vs. "type"

This is as reported in #11471, though it's not the focus of that

test case: polykinds/KindVType

3 years agoFix #11473.
Richard Eisenberg [Tue, 15 Mar 2016 18:27:22 +0000 (14:27 -0400)] 
Fix #11473.

I've added a check in the zonker for representation polymorphism.
I don't like having this be in the zonker, but I don't know where
else to put it. It can't go in TcValidity, because a clever enough
user could convince the solver to do bogus representation polymorphism
even though there's nothing obviously wrong in what they wrote.
Note that TcValidity doesn't run over *expressions*, which is where
this problem arises.

In any case, the check is simple and it works.

test case: dependent/should_fail/T11473

3 years agoFix #11357.
Richard Eisenberg [Tue, 15 Mar 2016 17:49:15 +0000 (13:49 -0400)] 
Fix #11357.

We were looking at a data instance tycon for visibility info,
which is the wrong place to look. Look at the data family tycon

Also improved the pretty-printing near there to suppress kind
arguments when appropriate.

3 years agoIncorporate bgamari's suggestions for #11614.
Richard Eisenberg [Tue, 15 Mar 2016 17:21:20 +0000 (13:21 -0400)] 
Incorporate bgamari's suggestions for #11614.

3 years agoRemove redundant anonymiseTyBinders (#11648)
Richard Eisenberg [Tue, 15 Mar 2016 15:37:00 +0000 (11:37 -0400)] 
Remove redundant anonymiseTyBinders (#11648)

This was necessary in an earlier version of the patch for #11648,
but not in the final version. I forgot to remove it.

3 years agoTestsuite wibbles from previous commits.
Richard Eisenberg [Sat, 12 Mar 2016 20:52:22 +0000 (15:52 -0500)] 
Testsuite wibbles from previous commits.

3 years agoAllow eager unification with type families.
Richard Eisenberg [Tue, 15 Mar 2016 02:09:36 +0000 (22:09 -0400)] 
Allow eager unification with type families.

Previously, checkTauTvUpdate, used in the eager unifier (TcUnify)
right before writing to a metavar, refused to write a metavar to
a type involving type functions. The reason for this was given
in a Note, but the Note didn't make all that much sense and even
admitted that it was a bit confused. The Note, in turn, referred
to another Note, which it was quite sceptical of, as well.

The type-family check was slowing down performance, so I tried
removing it, running the tests referred to in the Note. The tests
all passed without the check. Looking at more test results, I
saw several error messages improve without the check, and some cases
where GHC looped (T7788, in particular) it now doesn't.

So, all in all, quite a win: Two hairy Notes removed, several lines
of code removed, better performance, and improved output.

[skip ci]

3 years agoFix #11648.
Richard Eisenberg [Sun, 13 Mar 2016 01:59:44 +0000 (20:59 -0500)] 
Fix #11648.

We now check that a CUSK is really a CUSK and issue an error if
it isn't. This also involves more solving and zonking in
kcHsTyVarBndrs, which was the outright bug reported in #11648.

Test cases: polykinds/T11648{,b}

This updates the haddock submodule.

[skip ci]

3 years agoDocument TypeInType (#11614)
Richard Eisenberg [Fri, 11 Mar 2016 16:14:04 +0000 (11:14 -0500)] 
Document TypeInType (#11614)

[skip ci]

3 years agoTest case for #11699 in typecheck/should_compile
Richard Eisenberg [Fri, 11 Mar 2016 15:27:53 +0000 (10:27 -0500)] 
Test case for #11699 in typecheck/should_compile

[skip ci]