ghc.git
4 years agoAdd extra ghc-pkg sanity check for module re-exports and duplicates wip/cabal-head-updates
Duncan Coutts [Fri, 29 Aug 2014 13:00:57 +0000 (14:00 +0100)] 
Add extra ghc-pkg sanity check for module re-exports and duplicates

For re-exports, check that the defining package exists and that it
exposes the defining module (or for self-rexport exposed or hidden
modules). Also check that the defining package is actually a direct
or indirect dependency of the package doing the re-exporting.

Also add a check for duplicate modules in a package, including
re-exported modules.

4 years agoUpdate to Cabal head, update ghc-pkg to use new module re-export types
Duncan Coutts [Fri, 29 Aug 2014 12:53:52 +0000 (13:53 +0100)] 
Update to Cabal head, update ghc-pkg to use new module re-export types

The main change is that Cabal changed the representation of module
re-exports to distinguish reexports in source .cabal files versus
re-exports in installed package registraion files.

Cabal now also does the resolution of re-exports to specific installed
packages itself, so ghc-pkg no longer has to do this. This is a cleaner
design overall because re-export resolution can fail so it is better to
do it during package configuration rather than package registration.
It also simplifies the re-export representation that ghc-pkg has to use.

4 years agoFix failing test on BINDIST=YES
Edward Z. Yang [Fri, 29 Aug 2014 12:35:09 +0000 (13:35 +0100)] 
Fix failing test on BINDIST=YES

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
4 years agoAdd release notes about ghc-pkg change, and Cabal dep removal
Duncan Coutts [Thu, 28 Aug 2014 04:52:48 +0000 (05:52 +0100)] 
Add release notes about ghc-pkg change, and Cabal dep removal

That ghc-pkg doesn't support single-file style databases, and that
the ghc library does not depend on Cabal any more.

We don't need to document the ghc-pkg change in the ghc-pkg section
itself, since ghc-pkg init is already described there, and that is the
right thing. The old deprecated approach was not documented.

4 years agoFix a few minor issues spotted in code review
Duncan Coutts [Thu, 28 Aug 2014 04:24:04 +0000 (05:24 +0100)] 
Fix a few minor issues spotted in code review

4 years agoChange testsuite to not use old-style file package databases
Duncan Coutts [Wed, 27 Aug 2014 15:33:20 +0000 (16:33 +0100)] 
Change testsuite to not use old-style file package databases

Now uses ghc-pkg init. The file-style databases are no longer supported.

4 years agoUpdate Cabal and haddock submodules to follow the Canal-dep removal changes
Duncan Coutts [Wed, 27 Aug 2014 12:57:46 +0000 (13:57 +0100)] 
Update Cabal and haddock submodules to follow the Canal-dep removal changes

In particular, Cabal was still in one place using old file-style package
databases. Haddock just needed simple changes to follow the change of
representation of packages in the ghc library.

4 years agoFix validation error in Linker arising from package rep changes
Duncan Coutts [Wed, 27 Aug 2014 12:26:24 +0000 (13:26 +0100)] 
Fix validation error in Linker arising from package rep changes

4 years agoAddress a number of Edward's code review comments
Duncan Coutts [Sun, 24 Aug 2014 22:43:40 +0000 (23:43 +0100)] 
Address a number of Edward's code review comments

Some others addressed as part of other recent patches.

4 years agoFix string conversions in ghc-pkg to be correct w.r.t. Unicode
Duncan Coutts [Sun, 24 Aug 2014 21:11:33 +0000 (22:11 +0100)] 
Fix string conversions in ghc-pkg to be correct w.r.t. Unicode

Similar change to that on the ghc library side in the previous patch.
The BinaryStringRep class has to use a ByteString in UTF8 encoding.

4 years agoSwitch the package id types to use FastString (rather than String)
Duncan Coutts [Sun, 24 Aug 2014 20:59:03 +0000 (21:59 +0100)] 
Switch the package id types to use FastString (rather than String)

The conversions should now be correct w.r.t Unicode.

Also move a couple instances to avoid orphan instances.

Strictly speaking there's no need for these types to use FastString as
they do not need the unique feature. They could just use some other
compact string type, but ghc's internal utils don't have much support
for such a type, so we just use FastString.

4 years agoMake mkFastStringByteString pure and fix up uses
Duncan Coutts [Sun, 24 Aug 2014 20:46:17 +0000 (21:46 +0100)] 
Make mkFastStringByteString pure and fix up uses

It's morally pure, and we'll need it in a pure context.

4 years agoAdd a ghc -show-packages mode to display ghc's view of the package env
Duncan Coutts [Sun, 24 Aug 2014 02:38:39 +0000 (03:38 +0100)] 
Add a ghc -show-packages mode to display ghc's view of the package env

You can use ghc -show-packages, in addition to any -package -package-conf
-hide-package, etc flags and see just what ghc's package info looks like.
The format is much like ghc-pkg show.

Like the existing verbose tracing, but a specific mode.
Re-introduce pretty printed package info (Cabal handled this previously).

4 years agoRemove a TODO that is now done
Duncan Coutts [Sun, 24 Aug 2014 02:41:45 +0000 (03:41 +0100)] 
Remove a TODO that is now done

4 years agoFix long lines and trailing whitespace
Duncan Coutts [Sat, 23 Aug 2014 12:12:20 +0000 (13:12 +0100)] 
Fix long lines and trailing whitespace

in the previous patches in this series

4 years agoFix warnings arising from the package db refactoring
Duncan Coutts [Fri, 22 Aug 2014 14:57:07 +0000 (15:57 +0100)] 
Fix warnings arising from the package db refactoring

4 years agoMake binary a boot package
Duncan Coutts [Fri, 22 Aug 2014 14:10:47 +0000 (15:10 +0100)] 
Make binary a boot package

Since ghc-pkg needs a relatively recent version.

4 years agoDrop ghc library dep on Cabal
Duncan Coutts [Fri, 22 Aug 2014 14:09:55 +0000 (15:09 +0100)] 
Drop ghc library dep on Cabal

4 years agoMove Cabal Binary instances from bin-package-db to ghc-pkg itself
Duncan Coutts [Fri, 22 Aug 2014 14:08:24 +0000 (15:08 +0100)] 
Move Cabal Binary instances from bin-package-db to ghc-pkg itself

The ghc-pkg program of course still depends on Cabal, it's just the
bin-package-db library (shared between ghc and ghc-pkg) that does not.

4 years agoUse ghc-local types for packages, rather than Cabal types
Duncan Coutts [Fri, 22 Aug 2014 13:38:10 +0000 (14:38 +0100)] 
Use ghc-local types for packages, rather than Cabal types

Also start using the new package db file format properly, by using the
ghc-specific section.

This is the main patch in the series for removing the compiler's dep
on the Cabal lib.

4 years agoIntroduce new file format for the package database binary cache
Duncan Coutts [Tue, 19 Aug 2014 19:33:10 +0000 (20:33 +0100)] 
Introduce new file format for the package database binary cache

The purpose of the new format is to make it possible for the compiler
to not depend on the Cabal library. The new cache file format contains
more or less the same information duplicated in two different sections
using different representations.

One section is basically the same as what the package db contains now,
a list of packages using the types defined in the Cabal library. This
section is read back by ghc-pkg, and used for things like ghc-pkg dump
which have to produce output using the Cabal InstalledPackageInfo text
representation.

The other section is a ghc-local type which contains a subset of the
information from the Cabal InstalledPackageInfo -- just the bits that
the compiler cares about.

The trick is that the compiler can read this second section without
needing to know the representation (or types) of the first part. The
ghc-pkg tool knows about both representations and writes both.

This patch introduces the new cache file format but does not yet use it
properly. More patches to follow. (As of this patch, the compiler reads
the part intended for ghc-pkg so it still depends on Cabal and the
ghc-local package type is not yet fully defined.)

4 years agoImprove the ghc-pkg warnings for missing and out of date package cache files
Duncan Coutts [Tue, 19 Aug 2014 15:10:04 +0000 (16:10 +0100)] 
Improve the ghc-pkg warnings for missing and out of date package cache files

In particular, report when it's missing, and also report it for ghc-pkg check.
Also make the warning message more explicit, that ghc will not be able to
read these dbs, even though ghc-pkg may be able to.

4 years agoDrop support for single-file style package databases
Duncan Coutts [Tue, 19 Aug 2014 12:23:56 +0000 (13:23 +0100)] 
Drop support for single-file style package databases

Historically the package db format was a single text file in Read/Show
format containing [InstalledPackageInfo]. For several years now the
default format has been a directory with one file per package, plus a
binary cache.

The old format cannot be supported under the new scheme where the
compiler will not depend on the Cabal library (because it will not
have access to the InstalledPackageInfo type) so we must drop support.
It would still technically be possible to support a single text file
style db (but containing a different type), but there does not seem to
be any compelling reason to do so.

(Part of preparitory work for removing the compiler's dep on Cabal)

4 years agoSimplify conversion in binary serialisation of ghc-pkg db
Duncan Coutts [Tue, 19 Aug 2014 00:00:54 +0000 (01:00 +0100)] 
Simplify conversion in binary serialisation of ghc-pkg db

We can serialise directly, without having to convert some fields to
string first.

(Part of preparitory work for removing the compiler's dep on Cabal)

4 years agoTestsuite wibbles
Simon Peyton Jones [Fri, 29 Aug 2014 09:20:21 +0000 (10:20 +0100)] 
Testsuite wibbles

4 years agoImprove "specImport discarding" message
Simon Peyton Jones [Fri, 29 Aug 2014 09:19:37 +0000 (10:19 +0100)] 
Improve "specImport discarding" message

4 years agoIn GHC.Real, specialise 'even' and 'odd' to Int and Integer
Simon Peyton Jones [Fri, 29 Aug 2014 09:19:02 +0000 (10:19 +0100)] 
In GHC.Real, specialise 'even' and 'odd' to Int and Integer

This was previously happening by a fluke -- they were called with those types
in GHC.Real itself -- but my recent changes to specialisation mean that auto
specialisations like these are not necessarily exported.

Losing those specialisations made a huge difference to two performance tests
   perf/should_run/MethSharing
   perf/should_run/T9339

4 years agoRename red-black test in indexed-types to red-black-delete
Simon Peyton Jones [Fri, 29 Aug 2014 09:16:35 +0000 (10:16 +0100)] 
Rename red-black test in indexed-types to red-black-delete

4 years agoDefine mapUnionVarSet, and use it
Simon Peyton Jones [Fri, 29 Aug 2014 09:14:45 +0000 (10:14 +0100)] 
Define mapUnionVarSet, and use it

Call sites are much easier to understand than before

4 years agoBetter compiler performance (30% less allocation) for T783!
Simon Peyton Jones [Fri, 29 Aug 2014 09:12:04 +0000 (10:12 +0100)] 
Better compiler performance (30% less allocation) for T783!

4 years agoWhite space only
Simon Peyton Jones [Fri, 29 Aug 2014 09:11:19 +0000 (10:11 +0100)] 
White space only

4 years agoFix syntax in perf/compiler/all.T
Simon Peyton Jones [Fri, 29 Aug 2014 09:11:06 +0000 (10:11 +0100)] 
Fix syntax in perf/compiler/all.T

4 years agoImprove trimming of auto-rules
Simon Peyton Jones [Fri, 29 Aug 2014 07:06:36 +0000 (08:06 +0100)] 
Improve trimming of auto-rules

I hadn't got the new function trimAutoRules quite right, so we had
a left-over rule which mentioned a local variable whose binding had
been discarded.  (Result: crash when compiling Haddock.)

This patch merges trimAutoRules into an expanded version of
findExternalRules, gets it right, and adds lots of comments.

See Note [Finding external rules].

And indeed in one regression test we get to trim off more rules
(and hence code) than before.

4 years agoPprC: cleanup: don't emit 'FB_' / 'FE_' in via-C
Sergei Trofimovich [Thu, 28 Aug 2014 21:00:19 +0000 (00:00 +0300)] 
PprC: cleanup: don't emit 'FB_' / 'FE_' in via-C

No need to emit (now empty) those special markers.
Markers were needed only in registerised -fvia-C mode.

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
4 years ago[ci skip] Update .gitignore
Austin Seipp [Thu, 28 Aug 2014 20:47:23 +0000 (15:47 -0500)] 
[ci skip] Update .gitignore

Signed-off-by: Austin Seipp <austin@well-typed.com>
4 years ago[ci skip] ghc-prim: Update .gitignore
Austin Seipp [Thu, 28 Aug 2014 20:47:10 +0000 (15:47 -0500)] 
[ci skip] ghc-prim: Update .gitignore

Signed-off-by: Austin Seipp <austin@well-typed.com>
4 years agoTemporary fix to the crash
Simon Peyton Jones [Thu, 28 Aug 2014 16:50:49 +0000 (17:50 +0100)] 
Temporary fix to the crash

   ghc-stage2: panic! (the 'impossible' happened)
     (GHC version 7.9.20140828 for x86_64-unknown-linux):
    nameModule $w$smiddle_sfx6

   make[1]: *** [utils/haddock/dist/build/Haddock/Backends/Xhtml.dyn_o] Error 1

4 years agoComments only
Simon Peyton Jones [Thu, 28 Aug 2014 15:59:06 +0000 (16:59 +0100)] 
Comments only

4 years agoAdd an interesting type-family/GADT example of deletion for red-black trees
Simon Peyton Jones [Thu, 28 Aug 2014 09:34:17 +0000 (10:34 +0100)] 
Add an interesting type-family/GADT example of deletion for red-black trees

Due to Stephanie Weirich, Dan Licata, John Hughes, Matt Might

4 years agotestsuite: disable 'rdynamic' for 'ghci' way
Sergei Trofimovich [Thu, 28 Aug 2014 13:14:22 +0000 (16:14 +0300)] 
testsuite: disable 'rdynamic' for 'ghci' way

'-rdynamic' is currently only a link-time option.
Does not make sense for ghci without major changes.

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
4 years agotestsuite: disable T367_letnoescape on 'optllvm'
Sergei Trofimovich [Thu, 28 Aug 2014 12:45:23 +0000 (15:45 +0300)] 
testsuite: disable T367_letnoescape on 'optllvm'

Known Issue #7297

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
4 years agoTestsuite wibbles
Simon Peyton Jones [Thu, 28 Aug 2014 11:10:57 +0000 (12:10 +0100)] 
Testsuite wibbles

4 years agoWhite space only
Simon Peyton Jones [Thu, 28 Aug 2014 10:13:37 +0000 (11:13 +0100)] 
White space only

4 years agoRemove dead lookup_dfun_id (merge-o)
Simon Peyton Jones [Thu, 28 Aug 2014 10:13:24 +0000 (11:13 +0100)] 
Remove dead lookup_dfun_id (merge-o)

4 years agoSimple refactor of the case-of-case transform
Simon Peyton Jones [Tue, 27 May 2014 08:09:28 +0000 (09:09 +0100)] 
Simple refactor of the case-of-case transform

More modular, less code.  No change in behaviour.

4 years agoPerformance changes
Simon Peyton Jones [Fri, 23 May 2014 12:49:04 +0000 (13:49 +0100)] 
Performance changes

* T1969 improves, perhaps because of better specialiation

* T5642 (a bizarre case) worsens, because we get lots and lots
  of specialisations of imported functions for the lots and
  lots of data types T5642 declares

4 years agoTestsuite wibbles
Simon Peyton Jones [Fri, 23 May 2014 12:42:37 +0000 (13:42 +0100)] 
Testsuite wibbles

4 years agoRun float-inwards immediately before the strictness analyser.
Simon Peyton Jones [Fri, 23 May 2014 12:42:05 +0000 (13:42 +0100)] 
Run float-inwards immediately before the strictness analyser.

Doing so pushes bindings nearer their use site and hence makes
them more likely to be strict. These bindings might only show
up after the inlining from simplification.  Example in fulsom,
Csg.calc, where an arg of timesDouble thereby becomes strict.

Very few programs are affected, but it's basically good news.

        Program           Size    Allocs   Runtime   Elapsed  TotalMem
--------------------------------------------------------------------------------
            fft          -0.2%     +1.3%      0.06      0.06    -10.0%
         fulsom          -0.0%     -2.6%     -4.3%     -4.7%     -6.7%
         simple          +0.0%     -0.8%      0.0%      0.0%      0.0%
--------------------------------------------------------------------------------
            Min          -0.5%     -2.6%     -4.5%     -4.7%    -10.0%
            Max          +0.1%     +1.3%     +3.3%     +3.4%     +2.6%
 Geometric Mean          -0.0%     -0.0%     -0.6%     -0.6%     -0.2%

The lossage in fft is the loss of detecting a common sub-expression,
and can be fixed by doing earlier CSE.  But that is in any case a bit
of a fluke so I don't mind losing it in exchange for this more reliable
gain.

4 years agoComments only
Simon Peyton Jones [Fri, 23 May 2014 08:16:00 +0000 (09:16 +0100)] 
Comments only

4 years agoMake tidyProgram discard speculative specialisation rules
Simon Peyton Jones [Fri, 23 May 2014 07:23:41 +0000 (08:23 +0100)] 
Make tidyProgram discard speculative specialisation rules

The new function TidyPgm.trimAutoRules discards bindings and
rules that were useful, but now have served their purpose.

See Note [Trimming auto rules] in TidyPgm

4 years agoFix an egregious bug in the NonRec case of bindFreeVars
Simon Peyton Jones [Fri, 23 May 2014 07:15:52 +0000 (08:15 +0100)] 
Fix an egregious bug in the NonRec case of bindFreeVars

We were missing the free variables of rules etc.  It's correct
for Rec but wrong for NonRec.  I'm not sure how this bug hasn't
bitten us before, but it cropped up when I was doing trimAutoRules.

4 years agoAdd -fspecialise-aggressively
Simon Peyton Jones [Tue, 13 May 2014 12:10:26 +0000 (13:10 +0100)] 
Add -fspecialise-aggressively

This flag specialises any imported overloaded function that has an
unfolding, whether or not it was marked INLINEABLE.

We get a lot of orphan SPEC rules as a result, but that doesn't matter
provided we don't treat orphan auto-generated rules as causing the module
itself to be an orphan module.  See Note [Orphans and auto-generated rules]
in MkIface.

4 years agoCompiler performance increases -- yay!
Simon Peyton Jones [Tue, 13 May 2014 11:43:50 +0000 (12:43 +0100)] 
Compiler performance increases -- yay!

4 years agoMore SPEC rules fire
Simon Peyton Jones [Tue, 13 May 2014 11:43:27 +0000 (12:43 +0100)] 
More SPEC rules fire

4 years agoWibbles to "...plus N others" error message about instances in scope
Simon Peyton Jones [Tue, 13 May 2014 11:42:58 +0000 (12:42 +0100)] 
Wibbles to "...plus N others" error message about instances in scope

I this this arises from my de-orphaning the Enum Word instance

4 years agoSpecialise monad functions, and make them INLINEABLE
Simon Peyton Jones [Tue, 13 May 2014 09:59:19 +0000 (10:59 +0100)] 
Specialise monad functions, and make them INLINEABLE

Specialise liftM, foldM, etc, and make them specialisable
for new monads at their call sites by using INLINEABLE

4 years agoSlightly improve fusion rules for 'take'
Simon Peyton Jones [Tue, 13 May 2014 09:55:33 +0000 (10:55 +0100)] 
Slightly improve fusion rules for 'take'

4 years agoDon't float out (classop dict e1 e2)
Simon Peyton Jones [Tue, 13 May 2014 09:00:45 +0000 (10:00 +0100)] 
Don't float out (classop dict e1 e2)

A class op applied to a dictionary doesn't do much work, so it's not
a great idea to float it out (except possibly to the top level.

See Note [Floating over-saturated applications] in SetLevels

I also renamed "floatOutPartialApplications" to "floatOutOverSatApps";
the former is deeply confusing, since there is no partial application
involved -- quite the reverse, it is *over* saturated.

4 years agoMove the Enum Word instance into GHC.Enum
Simon Peyton Jones [Mon, 12 May 2014 09:54:30 +0000 (10:54 +0100)] 
Move the Enum Word instance into GHC.Enum

This just avoids an unnecessary orphan instance.
All the other instances for "earlier" types are in GHC.Enum already.

4 years agoSpecialise Eq, Ord, Read, Show at Int, Char, String
Simon Peyton Jones [Mon, 12 May 2014 09:53:09 +0000 (10:53 +0100)] 
Specialise Eq, Ord, Read, Show at Int, Char, String

These instances are quite common, so it's good to have
pre-specialised versions available

4 years agoMake worker/wrapper work on INLINEABLE things
Simon Peyton Jones [Fri, 9 May 2014 10:15:33 +0000 (11:15 +0100)] 
Make worker/wrapper work on INLINEABLE things

This fixes a long-standing bug: Trac #6056.  The trouble was that
INLINEABLE "used up" the unfolding for the Id, so it couldn't be
worker/wrapper'd by the strictness analyser.

This patch allows the w/w to go ahead, and makes the *worker* INLINEABLE
instead, so it can later be specialised.

However, that doesn't completely solve the problem, because the dictionary
argument (which the specialiser treats specially) may be strict and
hence unpacked by w/w, so now the worker won't be specilialised after all.

Solution: never unpack dictionary arguments, which is done by the isClassTyCon
          test in WwLib.deepSplitProductType_maybe

4 years agoMake maybeUnfoldingTemplate respond to DFunUnfoldings
Simon Peyton Jones [Fri, 9 May 2014 09:59:40 +0000 (10:59 +0100)] 
Make maybeUnfoldingTemplate respond to DFunUnfoldings

CoreSyn.maybeUnfoldingTemplate is used mainly when specialising,
so make DFunUnfoldings respond to it makes it possible to specialise
them properly.

4 years agoKill unused setUnfoldingTemplate
Simon Peyton Jones [Fri, 9 May 2014 09:55:15 +0000 (10:55 +0100)] 
Kill unused setUnfoldingTemplate

4 years agoRefactor unfoldings
Simon Peyton Jones [Thu, 8 May 2014 10:21:16 +0000 (11:21 +0100)] 
Refactor unfoldings

There are two main refactorings here

1.  Move the uf_arity field
       out of CoreUnfolding
       into UnfWhen
    It's a lot tidier there.  If I've got this right, no behaviour
    should change.

2.  Define specUnfolding and use it in DsBinds and Specialise
     a) commons-up some shared code
     b) makes sure that Specialise correctly specialises DFun
        unfoldings (which it didn't before)

The two got put together because both ended up interacting in the
specialiser.

They cause zero difference to nofib.

4 years agoLess voluminous output when printing continuations
Simon Peyton Jones [Thu, 8 May 2014 10:05:39 +0000 (11:05 +0100)] 
Less voluminous output when printing continuations

4 years agoRevert "disable shared libs on sparc (linux/solaris) (fixes #8857)"
Sergei Trofimovich [Wed, 27 Aug 2014 19:20:33 +0000 (22:20 +0300)] 
Revert "disable shared libs on sparc (linux/solaris) (fixes #8857)"

This reverts commit 623883f1ed0ee11cc925c4590fb09565403fd231.

The commit a93ab43ab5f40cadbedea2f6342b93c245e91434
    driver: pass '-fPIC' option to assembler as well
fixes shared libraries on sparc at least on linux.

Properly fixes Issue #8857

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
4 years agodriver: pass '-fPIC' option to assembler as well
Sergei Trofimovich [Wed, 27 Aug 2014 19:19:52 +0000 (22:19 +0300)] 
driver: pass '-fPIC' option to assembler as well

Summary:
Before the patch '-fPIC' was passed only to C compiler,
but not to assembler itself.

It led to runtime crash in GHC_DYNAMIC_PROGRAMS=YES mode
on sparc32.

Technical details are in 'Note [-fPIC for assembler]'.

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
Test Plan: validate on sparc

Reviewers: simonmar, austin, kgardas

Reviewed By: austin

Subscribers: simonmar, ezyang, carter

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

4 years agoUNREG: fix emission of large Integer literals in C codegen
Sergei Trofimovich [Tue, 26 Aug 2014 10:07:14 +0000 (13:07 +0300)] 
UNREG: fix emission of large Integer literals in C codegen

Summary:
On amd64/UNREG build there is many failing tests trying
to deal with 'Integer' types.

Looking at 'integerConversions' test I've observed
invalid C code generated by GHC.

Cmm code
    CInt a = -1; (a == -1)
yields 'False' with optimisations enabled via the following C code:
    StgWord64 a = (StgWord32)0xFFFFffffFFFFffffu; (a == 0xFFFFffffFFFFffffu)

The patch fixes it by shrinking emitted literals to required sizes:
    StgWord64 a = (StgWord32)0xFFFFffffu; (a == 0xFFFFffffu)

Thanks to Reid Barton for tracking down and fixing the issue.

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
Test Plan: validate on UNREG build (amd64, x86)

Reviewers: simonmar, rwbarton, austin

Subscribers: hvr, simonmar, ezyang, carter

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

4 years agoImprove documentation of record wildcards
Simon Peyton Jones [Mon, 25 Aug 2014 15:18:03 +0000 (16:18 +0100)] 
Improve documentation of record wildcards

In particular mention that they aren't allowed for record updates.

Triggered by Trac #9437

4 years agoTwo buglets in record wild-cards (Trac #9436 and #9437)
Simon Peyton Jones [Mon, 25 Aug 2014 14:17:39 +0000 (15:17 +0100)] 
Two buglets in record wild-cards (Trac #9436 and #9437)

of named fields, whereas the code in RnPat.rnHsRecFields is
much better set up to do so.

Both easily fixed.

4 years agoCheck for un-saturated type family applications
Simon Peyton Jones [Mon, 25 Aug 2014 14:13:02 +0000 (15:13 +0100)] 
Check for un-saturated type family applications

This patch corrects an egregious error introduced by:

  commit 022f8750edf6f413fba31293435dcc62600eab77
  Author: Simon Peyton Jones <simonpj@microsoft.com>
  Date:   Thu May 15 16:07:04 2014 +0100

    Refactoring around TyCon.isSynTyCon

    * Document isSynTyCon better
    * Add isTypeSyonymTyCon for regular H98 type synonyms
    * Use isTypeSynonymTyCon rather than isSynTyCon where
      the former is really intended

At this particular spot in TcValidity we really do mean
isSynTyCon and not isTypeSynonymTyCon.

Fixes Trac #9433

4 years agoMake Core Lint check for un-saturated type applications
Simon Peyton Jones [Mon, 25 Aug 2014 14:10:19 +0000 (15:10 +0100)] 
Make Core Lint check for un-saturated type applications

Un-saturated type-family and type-synonym applications are
detected in the front end, but for some reason Lint wasn't
looking for them.

I came across this when wondering why Trac #9433 didn't give
a Core Lint error

4 years agoMore refactoring in SpecConstr
Simon Peyton Jones [Mon, 25 Aug 2014 12:38:55 +0000 (13:38 +0100)] 
More refactoring in SpecConstr

This patch should make no change in behaviour.

 * Make RhsInfo into a record

 * Include ri_rhs_usg, which previously travelled around separately

 * Introduce specRec, specNonRec, and
   make them return [OneSpec] rather than SpecInfo

4 years agoDo not duplicate call information in SpecConstr (Trac #8852)
Simon Peyton Jones [Mon, 25 Aug 2014 11:28:44 +0000 (12:28 +0100)] 
Do not duplicate call information in SpecConstr (Trac #8852)

This long-standing and egregious bug meant that call information was
being gratuitously copied, leading to an exponential blowup in the
number of calls to be examined when function definitions are deeply
nested.  That is what has been causing the blowup in SpecConstr's
running time, not (as I had previously supposed) generating very large code.

See Note [spec_usg includes rhs_usg]

4 years agoIntroduce the Call data types
Simon Peyton Jones [Mon, 25 Aug 2014 11:24:55 +0000 (12:24 +0100)] 
Introduce the Call data types

This is just a small refactoring that makes the code a bit clearer,
using a data type instead of a triple.  We get better pretty-printing too.

4 years agoUse DumpStyle rather than UserStyle for pprTrace output
Simon Peyton Jones [Mon, 25 Aug 2014 11:10:29 +0000 (12:10 +0100)] 
Use DumpStyle rather than UserStyle for pprTrace output

The main motivation is that user-style output assumes that everything has been
tidied, not enough uniques are printed by default.

The downside is that pprTrace output now has module prefixes which can be overwhelming,
but -dsuppress-module-prefixes will suppress them.

4 years agotestsuite: add 16-byte case for T9329
Sergei Trofimovich [Mon, 25 Aug 2014 10:00:24 +0000 (13:00 +0300)] 
testsuite: add 16-byte case for T9329

Exposes Issue #9512 on amd64

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
4 years agoDeclare official GitHub home of libraries/{directory,process}
Herbert Valerio Riedel [Mon, 25 Aug 2014 07:14:31 +0000 (09:14 +0200)] 
Declare official GitHub home of libraries/{directory,process}

Effective immediately, pushing to libraries/{directory,process} requires
pushing to ssh://git@github.com/haskell/{directory.process}.git. This has
been done now even though there's no scripted tooling yet as the GitHub repo
was already getting issues filed.

4 years agotestsuite: added 'bytes allocated' for T9339 wordsize(32)
Sergei Trofimovich [Sun, 24 Aug 2014 17:46:44 +0000 (20:46 +0300)] 
testsuite: added 'bytes allocated' for T9339 wordsize(32)

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
4 years agoAdd MO_AddIntC, MO_SubIntC MachOps and implement in X86 backend
Reid Barton [Fri, 22 Aug 2014 22:57:50 +0000 (18:57 -0400)] 
Add MO_AddIntC, MO_SubIntC MachOps and implement in X86 backend

Summary:
These MachOps are used by addIntC# and subIntC#, which in turn are
used in integer-gmp when adding or subtracting small Integers. The
following benchmark shows a ~6% speedup after this commit on x86_64
(building GHC with BuildFlavour=perf).

    {-# LANGUAGE MagicHash #-}

    import GHC.Exts
    import Criterion.Main

    count :: Int -> Integer
    count (I# n#) = go n# 0
      where go :: Int# -> Integer -> Integer
            go 0# acc = acc
            go n# acc = go (n# -# 1#) $! acc + 1

    main = defaultMain [bgroup "count"
                          [bench "100" $ whnf count 100]]

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

4 years agorts/Linker.c: declare 'deRefStablePtr' as an exported 'rts' symbol
Sergei Trofimovich [Sat, 23 Aug 2014 10:11:23 +0000 (13:11 +0300)] 
rts/Linker.c: declare 'deRefStablePtr' as an exported 'rts' symbol

    $ inplace/bin/ghc-stage2 -fforce-recomp -dcore-lint -dcmm-lint -dno-debug-output -no-user-package-db -rtsopts -optc-fno-builtin -fno-ghci-history \
        testsuite/tests/ffi/should_run/T4038.hs --interactive -v0 -ignore-dot-ghci +RTS -I0.1 -RTS

    *Main> main
    <interactive>: /tmp/ghc16668_0/ghc16668_5.o: unknown symbol `deRefStablePtr'

The reference to 'deRefStablePtr' is generated by 'compiler/deSugar/DsForeign.lhs':
    the_cfun
       = case maybe_target of
          Nothing    -> text "(StgClosure*)deRefStablePtr(the_stableptr)"
          Just hs_fn -> char '&' <> ppr hs_fn <> text "_closure"

Patch fixes all broken tests using 'import wrapper':
    TEST="ffi013 ffi010 ffi011 ffi005 ffi020 ffi006 ffi019 fed001 T1679 T4038"

Tests manifested as broken only in DYNAMIC_GHC_PROGRAMS=NO builds,
where GHCi's custom linker is used instead of system's linker.

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
4 years agotestsuite: mark testwsdeque mark as faulty on NOSMP builds
Sergei Trofimovich [Sat, 23 Aug 2014 08:32:05 +0000 (11:32 +0300)] 
testsuite: mark testwsdeque mark as faulty on NOSMP builds

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
4 years agotestsuite: disable memcpy asm comparison tests on UNREG
Sergei Trofimovich [Sat, 23 Aug 2014 08:22:59 +0000 (11:22 +0300)] 
testsuite: disable memcpy asm comparison tests on UNREG

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
4 years agotestsuite: disable gcc's warnings about casts of incompatible prototypes in UNREG
Sergei Trofimovich [Sat, 23 Aug 2014 08:01:16 +0000 (11:01 +0300)] 
testsuite: disable gcc's warnings about casts of incompatible prototypes in UNREG

Haskell's 'foreign import' declaraion does not have a way
to extress exact C prototypes (it ignores 'const' modifiers, exact pointer
types, etc.) which leads to warnings when C backend generates calls to such
functions:

    /tmp/ghc32698_0/ghc32698_10.hc:52:5:
         warning: conflicting types for built-in function ‘strlen’ [enabled by default]
         EF_(strlen);
             ^

Patch disables builtin functions for UNREG build
to workaround test failures due to stderr mismatch.

Fixes the following test failures:
    TEST="safePkg01 T5423 T7574 T3736"

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
4 years agotestsuite: T7815 requires SMP support from ghc
Sergei Trofimovich [Fri, 22 Aug 2014 22:20:11 +0000 (01:20 +0300)] 
testsuite: T7815 requires SMP support from ghc

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
4 years agoEnable GHC API tests by default.
Edward Z. Yang [Fri, 22 Aug 2014 17:01:43 +0000 (18:01 +0100)] 
Enable GHC API tests by default.

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
4 years agoNormalise GHC version number to make tests less fragile.
Edward Z. Yang [Fri, 22 Aug 2014 14:05:29 +0000 (15:05 +0100)] 
Normalise GHC version number to make tests less fragile.

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
4 years agoRevert "rts/base: Fix #9423"
Austin Seipp [Fri, 22 Aug 2014 13:51:38 +0000 (08:51 -0500)] 
Revert "rts/base: Fix #9423"

This should fix the Windows fallout, and hopefully this will be fixed
once that's sorted out.

This reverts commit f9f89b7884ccc8ee5047cf4fffdf2b36df6832df.

Signed-off-by: Austin Seipp <austin@well-typed.com>
4 years agoDo not zero out version number when processing wired-in packages.
Edward Z. Yang [Fri, 22 Aug 2014 00:29:28 +0000 (01:29 +0100)] 
Do not zero out version number when processing wired-in packages.

Summary:
Previously, GHC would look for instances of wired-in packages in the
in-memory package database and null out the version number.  This was
necessary when the sourcePackageId was used to determine the linker
symbols; however, we now use a package key, so only that needs to be
updated.

Long-term, we can remove this hack by ensuring that Cabal actually records
the proper package key in the database.  This will also fix an unrelated
hack elsewhere.

Keeping version numbers means that wired in packages get rendered differently
when output by GHC.  This is the source of all the test-case output changes.

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
Test Plan: validate

Reviewers: hvr, austin

Subscribers: simonmar, ezyang, carter

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

4 years agosubmodule update hpc/stm with gitignore.
Edward Z. Yang [Fri, 22 Aug 2014 13:23:56 +0000 (14:23 +0100)] 
submodule update hpc/stm with gitignore.

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
4 years agogitignore: Ignore tests/rts/rdynamic
Edward Z. Yang [Fri, 22 Aug 2014 00:40:55 +0000 (01:40 +0100)] 
gitignore: Ignore tests/rts/rdynamic

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
4 years agoFix #9465.
Gabor Pali [Fri, 22 Aug 2014 07:03:09 +0000 (09:03 +0200)] 
Fix #9465.

It turned out the sed(1) expressions are not fully portable.  So revist my
earlier attempt for getting GHC_LDFLAGS in the configure script and rewrite
it in Perl instead.

4 years agoT8832: fix no newline at end of file warning
Karel Gardas [Thu, 21 Aug 2014 07:00:15 +0000 (09:00 +0200)] 
T8832: fix no newline at end of file warning

4 years agoincludes: detabify/dewhitespace rts/storage/ClosureMacros.h
Austin Seipp [Wed, 20 Aug 2014 17:50:14 +0000 (12:50 -0500)] 
includes: detabify/dewhitespace rts/storage/ClosureMacros.h

Signed-off-by: Austin Seipp <austin@well-typed.com>
4 years ago[ci skip] includes: detabify/dewhitespace rts/storage/InfoTables.h
Austin Seipp [Wed, 20 Aug 2014 17:49:33 +0000 (12:49 -0500)] 
[ci skip] includes: detabify/dewhitespace rts/storage/InfoTables.h

Signed-off-by: Austin Seipp <austin@well-typed.com>
4 years ago[ci skip] includes: detabify/dewhitespace rts/storage/Block.h
Austin Seipp [Wed, 20 Aug 2014 17:49:27 +0000 (12:49 -0500)] 
[ci skip] includes: detabify/dewhitespace rts/storage/Block.h

Signed-off-by: Austin Seipp <austin@well-typed.com>
4 years ago[ci skip] includes: detabify/dewhitespace rts/storage/GC.h
Austin Seipp [Wed, 20 Aug 2014 17:47:32 +0000 (12:47 -0500)] 
[ci skip] includes: detabify/dewhitespace rts/storage/GC.h

Signed-off-by: Austin Seipp <austin@well-typed.com>
4 years ago[ci skip] includes: detabify/dewhitespace rts/storage/Closures.h
Austin Seipp [Wed, 20 Aug 2014 17:47:21 +0000 (12:47 -0500)] 
[ci skip] includes: detabify/dewhitespace rts/storage/Closures.h

Signed-off-by: Austin Seipp <austin@well-typed.com>
4 years ago[ci skip] includes: detabify/dewhitespace rts/storage/TSO.h
Austin Seipp [Wed, 20 Aug 2014 17:47:07 +0000 (12:47 -0500)] 
[ci skip] includes: detabify/dewhitespace rts/storage/TSO.h

Signed-off-by: Austin Seipp <austin@well-typed.com>
4 years ago[ci skip] includes: detabify/dewhitespace rts/storage/MBlock.h
Austin Seipp [Wed, 20 Aug 2014 17:46:58 +0000 (12:46 -0500)] 
[ci skip] includes: detabify/dewhitespace rts/storage/MBlock.h

Signed-off-by: Austin Seipp <austin@well-typed.com>