Enable GHC API tests by default.

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
testsuite: T7815 requires SMP support from ghc

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
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>
testsuite: disable memcpy asm comparison tests on UNREG

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
testsuite: mark testwsdeque mark as faulty on NOSMP builds

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
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>
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
testsuite: added 'bytes allocated' for T9339 wordsize(32)

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
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.
testsuite: add 16-byte case for T9329

Exposes Issue #9512 on amd64

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
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.
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.
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]
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
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
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
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.
Improve documentation of record wildcards

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

Triggered by Trac #9437
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
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