Test #9200. (polykinds/T9200)
Change definition of CUSK for data and class definitions (#9200).

Now, a CUSK is when (and only when) all type variables are annotated.
This allows classes to participate in polymorphic recursion.
Added more testing for #9200. (polykinds/T9200b)
Change treatment of CUSKs for synonyms and families (#9200).
Remove NonParametricKinds (#9200)

This commit also removes 'KindCheckingStrategy' and related gubbins,
instead including the notion of a CUSK into HsDecls.
Update manual (#9200).
Testsuite wibbles around #9200
shouldInlinePrimOp: Fix Int overflow

There were two overflow issues in shouldInlinePrimOp. The first one is
due to a negative CmmInt literal being created if the array size was
given as larger than 2^63-1 (on a 64-bit platform.) This meant that
large array sizes could compare as being smaller than
maxInlineAllocSize.

The second issue is that we casted the Integer to an Int in the
comparison, which again meant that large array sizes could compare as
being smaller than maxInlineAllocSize.

The attempt to allocate a large array inline then caused a segfault.

Fixes #9416.
Add some Haddocks to SMRep
StgCmmPrim: add note to stop using fixed size signed types for sizes

We use fixed size signed types to e.g. represent array sizes. This
means that the size can overflow.
Have ghc-pkg use an old-style package key when it's not provided.

Summary:
When this occurs, it means that the user is using an old version of Cabal.
In that case, don't barf out: just go ahead and install it as an old-style
package key.  The user won't be able to link multiple versions together,
but that should not be a problem because their Cabal can't handle it anyway.

What happens if old-style are mixed up with new-style?  Well, currently
with Cabal, it's indistinguishable.  However, if at some later point we
add private dependencies, libraries compiled with old style linker names
are incompatible with each other.  We'll cross that road when we come
to it.

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

Test Plan: validate

Reviewers: tibbe, hvr, austin

Subscribers: simonmar, relrod, ezyang, carter

Differential Revision: https://phabricator.haskell.org/D154
Explicitly version test for package key support.

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
Remove out of date TODO

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
Implement new CLZ and CTZ primops (re #9340)

This implements the new primops

  clz#, clz32#, clz64#,
  ctz#, ctz32#, ctz64#

which provide efficient implementations of the popular
count-leading-zero and count-trailing-zero respectively
(see testcase for a pure Haskell reference implementation).

On x86, NCG as well as LLVM generates code based on the BSF/BSR
instructions (which need extra logic to make the 0-case well-defined).

Test Plan: validate and succesful tests on i686 and amd64

Reviewers: rwbarton, simonmar, ezyang, austin

Subscribers: simonmar, relrod, ezyang, carter

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

GHC Trac Issues: #9340
Declare `ghc-head` to be haddock's upstream branch

This will affect commands such as

   git submodule update --remote utils/haddock

to use `ghc-head` instead of the default `master` branch
LlvmMangler: Be more selective when mangling object types

Summary:
We previously did a wholesale replace of `%function` to `%object` to
mangle object `.type` annotations. This is bad as it can end up
replacing appearances of `"%function"` in the user's code. We now look
for a proper `.type` keyword before performing the replacement.

Thanks to @rwbarton for pointing out the bug.

Test Plan:
Previously,

    $ echo 'main = putStrLn "@function"' > test.hs
    $ ghc -fllvm test.hs
    $ ./test
    @object

Now,
    $ echo 'main = putStrLn "@function"' > test.hs
    $ ghc -fllvm test.hs
    $ ./test
    @function

Reviewers: rwbarton, austin

Reviewed By: rwbarton, austin

Subscribers: phaskell, simonmar, relrod, ezyang, carter

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

GHC Trac Issues: #9439
Make configure's sed(1) expression for GHC_LDFLAGS more BSD-friendly.
Implement {resize,shrink}MutableByteArray# primops

The two new primops with the type-signatures

  resizeMutableByteArray# :: MutableByteArray# s -> Int#
                          -> State# s -> (# State# s, MutableByteArray# s #)

  shrinkMutableByteArray# :: MutableByteArray# s -> Int#
                          -> State# s -> State# s

allow to resize MutableByteArray#s in-place (when possible), and are useful
for algorithms where memory is temporarily over-allocated. The motivating
use-case is for implementing integer backends, where the final target size of
the result is either N or N+1, and only known after the operation has been
performed.

A future commit will implement a stateful variant of the
`sizeofMutableByteArray#` operation (see #9447 for details), since now the
size of a `MutableByteArray#` may change over its lifetime (i.e before
it gets frozen or GCed).

Test Plan: ./validate --slow

Reviewers: ezyang, austin, simonmar

Reviewed By: austin, simonmar

Differential Revision: https://phabricator.haskell.org/D133
Fix typos 'resizze'
Revert "Fix typos 'resizze'"
this is z-encoding (as hvr tells me)

This reverts commit 425d5178af55620efa00e6e16426f491c63ad533.