1. 03 Feb, 2017 1 commit
    • Sylvain Henry's avatar
      Ditch static flags · bbd3c399
      Sylvain Henry authored
      This patch converts the 4 lasting static flags (read from the command
      line and unsafely stored in immutable global variables) into dynamic
      flags. Most use cases have been converted into reading them from a DynFlags.
      
      In cases for which we don't have easy access to a DynFlags, we read from
      'unsafeGlobalDynFlags' that is set at the beginning of each 'runGhc'.
      It's not perfect (not thread-safe) but it is still better as we can
      set/unset these 4 flags before each run when using GHC API.
      
      Updates haddock submodule.
      
      Rebased and finished by: bgamari
      
      Test Plan: validate
      
      Reviewers: goldfire, erikd, hvr, austin, simonmar, bgamari
      
      Reviewed By: simonmar
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2839
      
      GHC Trac Issues: #8440
      bbd3c399
  2. 02 Feb, 2017 8 commits
    • Matthew Pickering's avatar
      Remove INLINE pragma on loopbreaker · 5728f4b8
      Matthew Pickering authored
      5728f4b8
    • Georgios Karachalias's avatar
      Exhaustiveness check for EmptyCase (Trac #10746) · b1035321
      Georgios Karachalias authored
      Empty case expressions have strict semantics so the problem boils down
      to inhabitation checking for the type of the scrutinee. 3 main functions
      added:
      
      - pmTopNormaliseType_maybe for the normalisation of the scrutinee type
      
      - inhabitationCandidates for generating the possible patterns of the
        appropriate type
      
      - checkEmptyCase' to filter out the candidates that give rise to
        unsatisfiable constraints.
      
      See Note [Checking EmptyCase Expressions] in Check
      and Note [Type normalisation for EmptyCase] in FamInstEnv
      
      Test Plan: validate
      
      Reviewers: simonpj, goldfire, dfeuer, austin, bgamari
      
      Reviewed By: bgamari
      
      Subscribers: mpickering, thomie
      
      Differential Revision: https://phabricator.haskell.org/D2105
      
      GHC Trac Issues: #10746
      b1035321
    • Gabor Greif's avatar
      Spelling fixes · 8dd82ead
      Gabor Greif authored
      8dd82ead
    • Ben Gamari's avatar
      Add support for StaticPointers in GHCi · eedb3df0
      Ben Gamari authored
      Here we add support to GHCi for StaticPointers. This process begins by
      adding remote GHCi messages for adding entries to the static pointer
      table. We then collect binders needing SPT entries after linking and
      send the interpreter a message adding entries with the appropriate
      fingerprints.
      
      Test Plan: `make test TEST=StaticPtr`
      
      Reviewers: facundominguez, mboes, simonpj, simonmar, goldfire, austin,
      hvr, erikd
      
      Reviewed By: simonpj, simonmar
      
      Subscribers: RyanGlScott, simonpj, thomie
      
      Differential Revision: https://phabricator.haskell.org/D2504
      
      GHC Trac Issues: #12356
      eedb3df0
    • Matthew Pickering's avatar
      Make interface loading for COMPLETE pragmas lazy · b16239a9
      Matthew Pickering authored
      Without this additional laziness we will loop forever trying
      to find the definitions of the conlikes referenced in the pragma.
      
      Fixes #13188
      
      Reviewers: austin, RyanGlScott, bgamari
      
      Reviewed By: bgamari
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D3058
      
      GHC Trac Issues: #13188
      b16239a9
    • Oleg Grenrus's avatar
      Introduce GHC.TypeNats module, change KnownNat evidence to be Natural · 1fcede43
      Oleg Grenrus authored
      Reviewers: dfeuer, austin, hvr, bgamari
      
      Reviewed By: bgamari
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D3024
      
      GHC Trac Issues: #13181
      1fcede43
    • Ben Gamari's avatar
      Don't tick top-level string literals · f5b275a2
      Ben Gamari authored
      This fixes a regression due to D2605 (see #8472) wherein top-level primitive
      strings would fail to be noticed by CoreToStg as they were wrapped in a
      tick. This resulted in a panic in CoreToStg due to inconsistent CAF information
      (or a Core Lint failure, if enabled). Here we document the invariant that
      unlifted expressions can only sit at top-level if of the form `Lit (MachStr
      ...)` with no ticks or other embellishments. Moreover, we fix instance of
      this in `Simplify.prepareRhs` and `FloatOut.wrapTick` where this
      invariant was being broken.
      
      Test Plan: Validate with `-g`. Run testsuite with `WAY=ghci`.
      
      Reviewers: austin, simonpj
      
      Reviewed By: simonpj
      
      Subscribers: simonpj, akio, scpmw, thomie
      
      Differential Revision: https://phabricator.haskell.org/D3051
      f5b275a2
    • Ben Gamari's avatar
      base: Derive Enum, Bounded for VecCount, VecElem · 5cb5b7a5
      Ben Gamari authored
      
      Test Plan: Validate
      
      Reviewers: RyanGlScott, austin, hvr
      
      Reviewed By: RyanGlScott
      
      Subscribers: goldfire, RyanGlScott, thomie
      
      Differential Revision: https://phabricator.haskell.org/D3059
      5cb5b7a5
  3. 01 Feb, 2017 3 commits
  4. 31 Jan, 2017 5 commits
    • Ben Gamari's avatar
      Export callStackDoc · 25e0cfc6
      Ben Gamari authored
      It's generally a pretty useful thing to have around.
      
      [skip ci]
      
      Test Plan: Build it
      
      Reviewers: austin, dfeuer
      
      Reviewed By: dfeuer
      
      Subscribers: dfeuer, thomie
      
      Differential Revision: https://phabricator.haskell.org/D3048
      25e0cfc6
    • Ben Gamari's avatar
      FloatOut: Allow floating through breakpoint ticks · 44f079f7
      Ben Gamari authored
      I believe this is actually a completely valid thing to do, despite the
      arguments put forth in #10052. All that was missing was logic in
      SetLevels to correctly substitute the cloned binders into the
      breakpoint's free variable list.
      
      This is a prerequisite for enabling StaticPointer support in the
      interpreter.
      
      Test Plan: Validate
      
      Reviewers: austin, scpmw
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D3049
      44f079f7
    • David Feuer's avatar
      Mark reallyUnsafePtrEquality# as can_fail · b3576ed2
      David Feuer authored
      As described in the note, floating `reallyUnsafePtrEquality#`
      out can make it much less precise. Marking it `can_fail` will
      prevent it from floating out, which I believe is particularly
      important in light of 5a9a1738,
      and should also help prevent let/app invariant failures as seen
      in #11444 and #13027.
      
      Reviewers: simonpj, austin, bgamari
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2987
      
      GHC Trac Issues: #13027, #11444
      b3576ed2
    • Daniel Haraj's avatar
      Use top-level instances to solve superclasses where possible · 748b7974
      Daniel Haraj authored
      This patch introduces a new flag `-fsolve-constant-dicts` which makes the
      constraint solver solve super class constraints with available dictionaries if
      possible. The flag is enabled by `-O1`.
      
      The motivation of this patch is that the compiler can produce more efficient
      code if the constraint solver used top-level instance declarations to solve
      constraints that are currently solved givens and their superclasses. In
      particular, as it currently stands, the compiler imposes a performance penalty
      on the common use-case where superclasses are bundled together for user
      convenience. The performance penalty applies to constraint synonyms as
      well. This example illustrates the issue:
      
      ```
      {-# LANGUAGE ConstraintKinds, MultiParamTypeClasses, FlexibleContexts #-}
      module B where
      
      class M a b where m :: a -> b
      
      type C a b = (Num a, M a b)
      
      f :: C Int b => b -> Int -> Int
      f _ x = x + 1
      ```
      
      Output without the patch, notice that we get the instance for `Num Int` by
      using the class selector `p1`.
      
      ```
      f :: forall b_arz. C Int b_arz => b_arz -> Int -> Int
      f =
        \ (@ b_a1EB) ($d(%,%)_a1EC :: C Int b_a1EB) _ (eta1_B1 :: Int) ->
          + @ Int
            (GHC.Classes.$p1(%,%) @ (Num Int) @ (M Int b_a1EB) $d(%,%)_a1EC)
            eta1_B1
            B.f1
      ```
      
      Output with the patch, nicely optimised code!
      
      ```
      f :: forall b. C Int b => b -> Int -> Int
      f =
        \ (@ b) _ _ (x_azg :: Int) ->
          case x_azg of { GHC.Types.I# x1_a1DP ->
          GHC.Types.I# (GHC.Prim.+# x1_a1DP 1#)
          }
      ```
      
      Reviewers: simonpj, bgamari, austin
      
      Reviewed By: simonpj
      
      Subscribers: mpickering, rwbarton, thomie
      
      Differential Revision: https://phabricator.haskell.org/D2714
      
      GHC Trac Issues: #12791, #5835
      748b7974
    • alexbiehl's avatar
      Fix binary instance for SrcStrictness · c71f0c4e
      alexbiehl authored
      Summary: Found while revisiting the binary serialization for interface files.
      
      Test Plan: Building and validating currently
      
      Reviewers: austin, bgamari, mpickering
      
      Reviewed By: mpickering
      
      Subscribers: mpickering, thomie
      
      Differential Revision: https://phabricator.haskell.org/D3050
      c71f0c4e
  5. 30 Jan, 2017 5 commits
    • Matthew Pickering's avatar
      Print COMPLETE pragmas in --show-iface · 5f8e2344
      Matthew Pickering authored
      Reviewers: austin, bgamari
      
      Reviewed By: bgamari
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D3032
      5f8e2344
    • Iavor S. Diatchki's avatar
      Fixes bug #11046 · 55935738
      Iavor S. Diatchki authored
      For some time now, type-level operators such as '+' have been treated as
      type constructors, rahter than type variables.  This pathc fixes TH's
      `lookupName` function to account for this behavior.
      
      Reviewers: bgamari, austin, goldfire, RyanGlScott
      
      Reviewed By: RyanGlScott
      
      Subscribers: Phyx, thomie
      
      Differential Revision: https://phabricator.haskell.org/D3025
      
      GHC Trac Issues: #11046
      55935738
    • Matthew Pickering's avatar
      Add a flag to emit error messages as JSON · 91691117
      Matthew Pickering authored
      This patch adds the flag `-ddump-json` which dumps all the compiler
      output as a JSON array. This allows tooling to more easily parse GHC's
      output to display to users.
      
      The flag is currently experimental and will hopefully be refined for the
      next release.  In particular I have avoided any changes which involve
      significant refactoring and provided what is easy given the current
      infrastructure.
      
      Reviewers: austin, bgamari
      
      Reviewed By: bgamari
      
      Subscribers: DanielG, gracjan, thomie
      
      Differential Revision: https://phabricator.haskell.org/D3010
      
      GHC Trac Issues: #13190
      91691117
    • Ryan Scott's avatar
      Check that a default type signature aligns with the non-default signature · 7363d538
      Ryan Scott authored
      Before, GHC was extremely permissive about the form a default type
      signature could take on in a class declaration. Notably, it would accept
      garbage like this:
      
        class Monad m => MonadSupply m where
          fresh :: m Integer
          default fresh :: MonadTrans t => t m Integer
          fresh = lift fresh
      
      And then give an extremely confusing error message when you actually
      tried to declare an empty instance of MonadSupply. We now do extra
      validity checking of default type signatures to ensure that they align
      with their non-default type signature counterparts. That is, a default
      type signature is allowed to differ from the non-default one only in its
      context - they must otherwise be alpha-equivalent.
      
      Fixes #12918.
      
      Test Plan: ./validate
      
      Reviewers: goldfire, simonpj, austin, bgamari
      
      Reviewed By: bgamari
      
      Subscribers: mpickering, dfeuer, thomie
      
      Differential Revision: https://phabricator.haskell.org/D2983
      
      GHC Trac Issues: #12918
      7363d538
    • Erik de Castro Lopo's avatar
      Fix deprecation warnings from containers · d2cf5dea
      Erik de Castro Lopo authored
      The functions that were causing warnings were deprecated in containers
      0.5 and GHC is already using containers 0.5.9.1.
      
      Test Plan: validate
      
      Reviewers: rwbarton, bgamari, hsyl20, austin, dfeuer
      
      Reviewed By: dfeuer
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D3036
      d2cf5dea
  6. 29 Jan, 2017 1 commit
    • Sergei Trofimovich's avatar
      UNREG: fix "_bytes" string literal forward declaration · 34a02055
      Sergei Trofimovich authored
      
      
      Typical UNREG build failure looks like that:
      
        ghc-unreg/includes/Stg.h:226:46: error:
           note: in definition of macro 'EI_'
           #define EI_(X)          extern StgWordArray (X) GNU_ATTRIBUTE(aligned (8))
                                                        ^
            |
        226 | #define EI_(X)          extern StgWordArray (X) GNU_ATTRIBUTE(aligned (8))
            |                                              ^
      
        /tmp/ghc10489_0/ghc_3.hc:1754:6: error:
           note: previous definition of 'ghczmprim_GHCziTypes_zdtcTyCon2_bytes' was here
           char ghczmprim_GHCziTypes_zdtcTyCon2_bytes[] = "TyCon";
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
             |
        1754 | char ghczmprim_GHCziTypes_zdtcTyCon2_bytes[] = "TyCon";
             |      ^
      
      As we see here "_bytes" string literals are defined as 'char []'
      array, not 'StgWord []'.
      
      The change special-cases "_bytes" string literals to have
      correct declaration type.
      Signed-off-by: default avatarSergei Trofimovich <siarheit@google.com>
      34a02055
  7. 28 Jan, 2017 1 commit
    • Ryan Scott's avatar
      Convert pprTrace in isPredTy to a WARN · bc42e2b0
      Ryan Scott authored
      Summary:
      There was a `pprTrace` in `isPredTy` that could fire under certain
      scenarios, causing normal GHC users to see debugging output. This turns it into
      a less chatty `WARN`, and expounds on the comment below it to add the scenario
      in #13187 which triggered the `pprTrace`.
      
      Reviewers: goldfire, austin, bgamari
      
      Reviewed By: goldfire, bgamari
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D3033
      
      GHC Trac Issues: #13187
      bc42e2b0
  8. 26 Jan, 2017 9 commits
    • Ryan Scott's avatar
      Don't unnecessarily qualify TH-converted instances with empty contexts · ad3d2dfa
      Ryan Scott authored
      Summary:
      The addition of rigorous pretty-printer tests
      (499e4382) had the unfortunate
      side-effect of revealing a bug in `hsSyn/Convert.hs` wherein instances are
      _always_ qualified with an instance context, even if the context is empty. This
      led to instances like this:
      
      ```
      instance Foo Int
      ```
      
      being pretty-printed like this!
      
      ```
      instance () => Foo Int
      ```
      
      We can prevent this by checking if the context is empty before adding an
      HsQualTy to the type.
      
      Also does some refactoring around HsForAllTys in `Convert` while I was in town.
      
      Fixes #13183.
      
      Test Plan: ./validate
      
      Reviewers: goldfire, bgamari, austin, alanz
      
      Reviewed By: alanz
      
      Subscribers: mpickering, thomie
      
      Differential Revision: https://phabricator.haskell.org/D3018
      
      GHC Trac Issues: #13183
      ad3d2dfa
    • Gabor Greif's avatar
      Prune unneeded Derive* language pragmas · 50544eea
      Gabor Greif authored
      50544eea
    • Alan Zimmerman's avatar
      Make type import/export API Annotation friendly · 0d1cb157
      Alan Zimmerman authored
      Summary:
      At the moment an export of the form
      
         type C(..)
      
      is parsed by the rule
      
      ```
        |  'type' oqtycon           {% amms (mkTypeImpExp (sLL $1 $> (unLoc $2)))
                                           [mj AnnType $1,mj AnnVal $2] }
      ```
      
      This means that the origiinal oqtycon loses its location which is then retained
      in the AnnVal annotation.
      
      The problem is if the oqtycon has its own annotations, these get lost.
      
      e.g. in
      
        type (?)(..)
      
      the parens annotations for (?) get lost.
      
      This patch adds a wrapper around the name in the IE type to
      
      (a) provide a distinct location for the adornment annotation and
      
      (b) identify the specific adornment, for use in the pretty printer rather than
      occName magic.
      
      Updates haddock submodule
      
      Test Plan: ./validate
      
      Reviewers: mpickering, dfeuer, bgamari, austin
      
      Reviewed By: dfeuer
      
      Subscribers: dfeuer, thomie, mpickering
      
      Differential Revision: https://phabricator.haskell.org/D3016
      
      GHC Trac Issues: #13163
      0d1cb157
    • Gabor Greif's avatar
      Typos in comments [ci skip] · ff9355e4
      Gabor Greif authored
      ff9355e4
    • Ryan Scott's avatar
      Nix typo and redundant where-clauses · 88a89b76
      Ryan Scott authored
      88a89b76
    • Ryan Scott's avatar
      Add pragCompleteDName to templateHaskellNames · e4ab8ba7
      Ryan Scott authored
      95dc6dc0 forgot to add `pragCompleteDName`
      to the list of `templateHaskellNames`, which caused a panic if you actually
      tried to splice a `COMPLETE` pragma using Template Haskell. This applies the
      easy fix and augments the regression test to check for this in the future.
      e4ab8ba7
    • David Feuer's avatar
      Generalize the type of runRW# · c344005b
      David Feuer authored
      * Generalize the type of `runRW#` to allow arbitrary return types.
      
      * Use `runRW#` to implement `Control.Monad.ST.Lazy.runST` (this
      provides evidence that it actually works properly with the generalized
      type).
      
      * Adjust the type signature in the definition of `oneShot` to match
      the one it is given in `MkId`.
      
      Reviewers: simonmar, austin, bgamari, hvr
      
      Reviewed By: bgamari
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D3012
      
      GHC Trac Issues: #13178
      c344005b
    • Matthew Pickering's avatar
      Template Haskell support for COMPLETE pragmas · 95dc6dc0
      Matthew Pickering authored
      Reviewers: RyanGlScott, austin, goldfire, bgamari
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2997
      
      GHC Trac Issues: #13098
      95dc6dc0
    • Matthew Pickering's avatar
      COMPLETE pragmas for enhanced pattern exhaustiveness checking · 1a3f1eeb
      Matthew Pickering authored
      This patch adds a new pragma so that users can specify `COMPLETE` sets of
      `ConLike`s in order to sate the pattern match checker.
      
      A function which matches on all the patterns in a complete grouping
      will not cause the exhaustiveness checker to emit warnings.
      
      ```
      pattern P :: ()
      pattern P = ()
      
      {-# COMPLETE P #-}
      
      foo P = ()
      ```
      
      This example would previously have caused the checker to warn that
      all cases were not matched even though matching on `P` is sufficient to
      make `foo` covering. With the addition of the pragma, the compiler
      will recognise that matching on `P` alone is enough and not emit
      any warnings.
      
      Reviewers: goldfire, gkaracha, alanz, austin, bgamari
      
      Reviewed By: alanz
      
      Subscribers: lelf, nomeata, gkaracha, thomie
      
      Differential Revision: https://phabricator.haskell.org/D2669
      
      GHC Trac Issues: #8779
      1a3f1eeb
  9. 25 Jan, 2017 1 commit
  10. 24 Jan, 2017 6 commits
    • Ben Gamari's avatar
      Bump Win32 version. · 2aaafc8b
      Ben Gamari authored
      Bump the version of `Win32` to `2.5.0.0` which is a major update and includes
      fixes for wrong alignments and wrong 64-bit types. Strangely enough this also
      seems to resolve #12713, where `T10858` was failing due to too-low allocations.
      
      The underlying type aliases have changed, so there is a potential
      for user programs not to compile anymore, but the types were incorrect.
      
      This also requires a bump in the `directory`, `Cabal`, and `process`
      submodules.
      
      Original author: Tamar Christina <tamar@zhox.com>
      
      Test Plan: ./validate
      
      Reviewers: bgamari, RyanGlScott, austin
      
      Subscribers: hvr, RyanGlScott, thomie, #ghc_windows_task_force
      
      Differential Revision: https://phabricator.haskell.org/D2938
      2aaafc8b
    • Ben Gamari's avatar
      HscTypes: Use foldl' instead of foldr · 2cc67adb
      Ben Gamari authored
      In this case we are building a map, for which `foldl'` is much better
      suited. This has a small but consistent impact on compiler allocations,
      ```
              -1 s.d.                -----          -0.161%
              +1 s.d.                -----          -0.011%
              Average                -----          -0.086%
      ```
      
      Test Plan: Validate
      
      Reviewers: austin
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2967
      2cc67adb
    • Ben Gamari's avatar
      nativeGen: Use `foldl'` instead of `foldr` in free register accumulation · efc8e3b1
      Ben Gamari authored
      Manipulations of `FreeRegs` values are all just bit-operations on a
      word. Turning these `foldr`s into `foldl'`s has a very small but consistent
      effect on compiler allocations,
      ```
              -1 s.d.                -----          -0.065%
              +1 s.d.                -----          -0.018%
              Average                -----          -0.042%
      ```
      
      Test Plan: Validate
      
      Reviewers: austin
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2966
      efc8e3b1
    • Ben Gamari's avatar
      UniqSet: Implement unionManyUniqSets in terms of foldl' instead of foldr · deb75cbf
      Ben Gamari authored
      foldr generally isn't a good choice for folds where the result can't be
      consumed incrementally. This gives a very modest improvement in
      compiler allocations,
      ```
              -1 s.d.                -----          -0.182%
              +1 s.d.                -----          -0.050%
              Average                -----          -0.116%
      ```
      This is clearly semantics-preserving since we are constructing a set.
      
      Test Plan: Validate
      
      Reviewers: austin
      
      Subscribers: dfeuer, thomie
      
      Differential Revision: https://phabricator.haskell.org/D2965
      deb75cbf
    • David Feuer's avatar
      Partially revert D3001 · 99f81828
      David Feuer authored
      D3001 accidentally changed the meaning of `containsSpan`. Revert
      that change.
      
      Reviewers: austin, bgamari
      
      Reviewed By: bgamari
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D3015
      99f81828
    • Ryan Scott's avatar
      Don't put foralls in front of TH-spliced GADT constructors that don't need them · 9fd87ef8
      Ryan Scott authored
      Summary:
      It turns out that D2974 broke this program
      (see https://phabricator.haskell.org/rGHC729a5e452db5#58801):
      
      ```lang=haskell
      {-# LANGUAGE ConstraintKinds #-}
      {-# LANGUAGE GADTs #-}
      {-# LANGUAGE KindSignatures #-}
      {-# LANGUAGE TemplateHaskell #-}
      {-# OPTIONS_GHC -ddump-splices #-}
      module Bug where
      
      import GHC.Exts (Constraint)
      
      $([d| data Dec13 :: (* -> Constraint) -> * where
              MkDec13 :: c a => a -> Dec13 c
          |])
      ```
      
      This was actually due to a long-standing bug in `hsSyn/Convert` that put
      unnecessary `forall`s in front of GADT constructors that didn't have any
      explicitly quantified type variables.
      
      This cargo-cults the code in `Convert` that handles `ForallT` and adapts
      it to `ForallC`. Fixes #13123 (for real this time).
      
      Test Plan: make test TEST=T13123
      
      Reviewers: goldfire, austin, bgamari
      
      Reviewed By: bgamari
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D3002
      
      GHC Trac Issues: #13123
      9fd87ef8