1. 12 Jan, 2017 1 commit
  2. 11 Jan, 2017 6 commits
    • Edward Z. Yang's avatar
      Fix handling of closed type families in Backpack. · f59aad68
      Edward Z. Yang authored
      
      
      Summary:
      A few related problems:
      
      - CoAxioms, like DFuns, are implicit and never exported,
        so we have to make sure we treat them the same way as
        DFuns: in RnModIface we need to rename references to
        them with rnIfaceImplicit and in mergeSignatures we need
        to NOT check them directly for compatibility (the
        test on the type family will do this check for us.)
      
      - But actually, we weren't checking if the axioms WERE
        consistent.  This is because we were forwarding all
        embedded CoAxiom references in the type family TyThing
        to the merged version, but that reference was what
        checkBootDeclM was using as a comparison point.
        This is similar to a problem we saw with DFuns.
      
        To fix this, I refactored the handling of implicit entities in TcIface
        for Backpack.  See Note [The implicit TypeEnv] for the gory details.
        Instead of passing the TypeEnv around explicitly, we stuffed it in
        IfLclEnv.
      Signed-off-by: default avatarEdward Z. Yang <ezyang@cs.stanford.edu>
      
      Test Plan: validate
      
      Reviewers: bgamari, simonpj, austin
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2928
      f59aad68
    • Edward Z. Yang's avatar
      Revamp Backpack/hs-boot handling of type class signatures. · 5def07fa
      Edward Z. Yang authored
      
      
      Summary:
      A basket of fixes and improvements:
      
      - The permissible things that one can write in a type
        class definition in an hsig file has been reduced
        to encompass the following things:
      
          - Methods
          - Default method signatures (but NOT implementation)
          - MINIMAL pragma
      
        It is no longer necessary nor encouraged to specify
        that a method has a default if it is mentioned in
        a MINIMAL pragma; the MINIMAL pragma is assumed to
        provide the base truth as to what methods need to
        be implemented when writing instances of a type
        class.
      
      - Handling of default method signatures in hsig was
        previously buggy, as these identifiers were not exported,
        so we now treat them similarly to DFuns.
      
      - Default methods are merged, where methods with defaults
        override those without.
      
      - MINIMAL pragmas are merged by ORing together pragmas.
      
      - Matching has been relaxed: a method with a default can
        be used to fill a signature which did not declare the
        method as having a default, and a more relaxed MINIMAL
        pragma can be used (we check if the signature pragma
        implies the final implementation pragma, on the way
        fixing a bug with BooleanFormula.implies, see #13073)
      Signed-off-by: default avatarEdward Z. Yang <ezyang@cs.stanford.edu>
      
      Test Plan: validate
      
      Reviewers: simonpj, bgamari, austin
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2925
      
      GHC Trac Issues: #13041
      5def07fa
    • Edward Z. Yang's avatar
      Improve Backpack support for fixities. · e41c61fa
      Edward Z. Yang authored
      
      
      Summary:
      Two major bug-fixes:
      
          - Check that fixities match between hsig and implementation
      
          - Merge and preserve fixities when merging signatures
      Signed-off-by: default avatarEdward Z. Yang <ezyang@cs.stanford.edu>
      
      Test Plan: validate
      
      Reviewers: bgamari, simonpj, austin
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2919
      
      GHC Trac Issues: #13066
      e41c61fa
    • Edward Z. Yang's avatar
      Warn if you explicitly export an identifier with warning attached. · 0bbcf76a
      Edward Z. Yang authored
      
      
      Summary:
      This won't stop people from attempting to use this identifier
      (since it is still always going to be in the export list), but
      having an explicit reference to something people shouldn't
      use is a smell, so warn about it.
      Signed-off-by: default avatarEdward Z. Yang <ezyang@cs.stanford.edu>
      
      Test Plan: validate
      
      Reviewers: simonpj, austin, bgamari
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2907
      0bbcf76a
    • Edward Z. Yang's avatar
      Attach warnings to non-PVP compatible uses of signatures. · 9f169bcd
      Edward Z. Yang authored
      
      
      Summary:
      If you use an inherited signature from another package in your own code,
      the only valid PVP bound you can specify for this package is an *exact*
      version bound.  This is because the signature is used both covariantly
      (it provides declarations for import) and contravariantly (it specifies
      what is required).  However, this is a bit distressing if you want to
      use a PVP-style bound that allows for upgrading a package.  So there is
      a dichotomy:
      
          1. Any signatures that come from packages with exact bounds
          (this includes, in particular, signature packages, who are
          included solely to make declarations available), can be
          used without problem by modules, but
      
          2. Any signatures that come from packages that are version
          bounded (i.e., any package that also provides modules) must
          NOT be used, because if they were used, they could break
          under a PVP policy that allows relaxations in the needed
          requirements.
      
      To help users avoid situation (2), I've added a warning to all
      signature declarations that come solely from (2).  This is not
      perfect; you might still end up relying on some type identity
      specified by a signature in a version-bounded package, but it
      should help catch major errors.
      Signed-off-by: default avatarEdward Z. Yang <ezyang@cs.stanford.edu>
      
      Test Plan: validate
      
      Reviewers: simonpj, austin, bgamari
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2906
      9f169bcd
    • Edward Z. Yang's avatar
      Support for using only partial pieces of included signatures. · 5f9c6d2a
      Edward Z. Yang authored
      
      
      Summary:
      Generally speaking, it's not possible to "hide" a requirement from a
      package you include, because if there is some module relying on that
      requirement, well, you can't just wish it out of existence.
      
      However, some packages don't have any modules.  For these, we can
      validly thin out requirements; indeed, this is very convenient if
      someone has published a large signature package but you only want
      some of the definitions.
      
      This patchset tweaks the interpretation of export lists in
      signatures: in particular, they no longer need to refer to
      entities that are defined locally; they range over both the current
      signature as well as any signatures that were inherited from
      signature packages (defined by having zero exposed modules.)
      
      In the process of doing this, I cleaned up a number of other
      things:
      
      * rnModIface and rnModExports now report errors that occurred
        during renaming and can propagate these to the TcM monad.
        This is important because in the current semantics, you can
        thin out a type which is referenced by a value you keep;
        in this situation, we need to error (to ensure that all
        types in signatures are rooted, so that we can determine
        their identities).
      
      * I ended up introducing a new construct 'dependency signature;
        to bkp files, to make it easier to tell if we were depending
        on a signature package.  It's not difficult for Cabal to
        figure this out (I already have a patch for it.)
      Signed-off-by: default avatarEdward Z. Yang <ezyang@cs.stanford.edu>
      
      Test Plan: validate
      
      Reviewers: simonpj, austin, bgamari
      
      Subscribers: thomie, mpickering
      
      Differential Revision: https://phabricator.haskell.org/D2904
      
      GHC Trac Issues: #12994
      5f9c6d2a
  3. 10 Jan, 2017 7 commits
    • David Feuer's avatar
      Inline partially-applied wrappers · 2be364ac
      David Feuer authored
      Suppose we have
      
      ```
      data Node a = Node2 !Int a a | Node3 !Int a a a
      instance Traversable Node where
        traverse f (Node2 s x y) = Node2 s <$> f x <*> f y
        ...
      
      ```
      
      Since `Node2` is partially applied, we wouldn't inline its
      wrapper.  The result was that we'd box up the `Int#` to put
      the box in the closure passed to `fmap`. We now allow the wrapper
      to inline when partially applied, so GHC stores the `Int#`
      directly in the closure.
      
      Reviewers: rwbarton, mpickering, simonpj, austin, bgamari
      
      Reviewed By: simonpj, bgamari
      
      Subscribers: mpickering, thomie
      
      Differential Revision: https://phabricator.haskell.org/D2891
      
      GHC Trac Issues: #12990
      2be364ac
    • takano-akio's avatar
      Mark *FB functions INLINE[0] (Fixes #13001) · 09bce7ac
      takano-akio authored
      When fusion rules successfully fire, we are left with calls to
      *FB functions. They are higher-order functions, and therefore they
      often benefit from inlining. This is particularly important when
      then final consumer is a strict fold (foldl', length, etc.), because
      not inlining these functions means allocating a function closure
      for each element in the list, which often is more costly than what
      fusion eliminates.
      
      Nofib shows a slight increase in the binary size:
      
      ------------------------------------------------------------------------
             Program           Size    Allocs   Runtime   Elapsed  TotalMem
      ------------------------------------------------------------------------
         gen_regexps          -0.3%      0.0%     0.000     0.000      0.0%
              puzzle          +0.8%      0.0%     0.089     0.090      0.0%
             reptile          +0.8%     -0.0%     0.008     0.008      0.0%
      ------------------------------------------------------------------------
                 Min          -0.3%     -0.0%     -7.3%     -7.1%      0.0%
                 Max          +0.8%     +0.0%     +7.8%     +7.7%     +1.8%
      Geometric Mean          +0.0%     -0.0%     +0.2%     +0.2%     +0.0%
      ------------------------------------------------------------------------
      
      Reviewers: simonpj, austin, hvr, bgamari
      
      Reviewed By: simonpj
      
      Subscribers: simonpj, thomie
      
      Differential Revision: https://phabricator.haskell.org/D2951
      
      GHC Trac Issues: #13001
      09bce7ac
    • rwbarton's avatar
      testsuite driver: don't append to existing output files · 35a5b603
      rwbarton authored
      If you happen to have a T1234.run.stdout file lying aroud (probably
      from before the move to running tests in temporary subdirectories)
      it gets symlinked into the T1234.run directory since its name starts
      with T1234; and then program output gets appended to the existing
      file (through the symlink). We should open the file for writing
      instead, to replace the symlink with a new file.
      
      Test Plan: tested locally, + harbormaster
      
      Reviewers: austin, Phyx, bgamari
      
      Reviewed By: Phyx, bgamari
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2946
      35a5b603
    • johnleo's avatar
      Check that type variable does not reference itself in its kind signature · 8a76d32e
      johnleo authored
      This fixes #11592.
      
      Test Plan: validate
      
      Reviewers: simonpj, austin, bgamari, goldfire
      
      Reviewed By: goldfire
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2914
      
      GHC Trac Issues: #11592
      8a76d32e
    • dobenour's avatar
      Throw an exception on heap overflow · 12ad4d41
      dobenour authored
      This changes heap overflow to throw a HeapOverflow exception instead of
      killing the process.
      
      Test Plan: GHC CI
      
      Reviewers: simonmar, austin, hvr, erikd, bgamari
      
      Reviewed By: simonmar, bgamari
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2790
      
      GHC Trac Issues: #1791
      12ad4d41
    • Ben Gamari's avatar
      e8d74321
    • Alan Zimmerman's avatar
      Make HsIParamTy have a Located HsIPName · 1a6bdca0
      Alan Zimmerman authored
      To simplify API Annotations.
      
      Updates haddock submodule
      1a6bdca0
  4. 09 Jan, 2017 2 commits
  5. 08 Jan, 2017 1 commit
    • Ömer Sinan Ağacan's avatar
      Parse holes as infix operators · 6c869f90
      Ömer Sinan Ağacan authored
      Reported as #13050. Since holes are expressions but not identifiers,
      holes were not allowed in infix operator position. This patch introduces
      a new production in infix operator parser to allow this.
      
      Reviewers: simonpj, austin, bgamari
      
      Reviewed By: simonpj
      
      Subscribers: simonpj, RyanGlScott, thomie, mpickering
      
      Differential Revision: https://phabricator.haskell.org/D2910
      
      GHC Trac Issues: #13050
      6c869f90
  6. 07 Jan, 2017 1 commit
  7. 06 Jan, 2017 9 commits
    • Facundo Domínguez's avatar
      Have addModFinalizer expose the local type environment. · c1ed9557
      Facundo Domínguez authored
      Kind inference in ghci was interfered when renaming of type splices
      introduced the HsSpliced data constructor. This patch has kind
      inference skip over it.
      
      Test Plan: ./validate
      
      Reviewers: simonpj, rrnewton, bgamari, goldfire, austin
      
      Subscribers: thomie, mboes
      
      Differential Revision: https://phabricator.haskell.org/D2886
      
      GHC Trac Issues: #12985
      c1ed9557
    • Facundo Domínguez's avatar
      c5452cc1
    • Matthew Pickering's avatar
      54227a45
    • Facundo Domínguez's avatar
      Have addModFinalizer expose the local type environment. · e5d1ed9c
      Facundo Domínguez authored
      Summary:
      Kind inference in ghci was interfered when renaming of type splices
      introduced the HsSpliced data constructor. This patch has kind
      inference skip over it.
      
      Test Plan: ./validate
      
      Reviewers: simonpj, rrnewton, austin, goldfire, bgamari
      
      Reviewed By: goldfire, bgamari
      
      Subscribers: thomie, mboes
      
      Differential Revision: https://phabricator.haskell.org/D2886
      
      GHC Trac Issues: #12985
      e5d1ed9c
    • Matthew Pickering's avatar
      Add missing stderr file for T13035 · f3c7cf9b
      Matthew Pickering authored
      f3c7cf9b
    • Simon Marlow's avatar
      More fixes for #5654 · 3a18baff
      Simon Marlow authored
      * In stg_ap_0_fast, if we're evaluating a thunk, the thunk might
        evaluate to a function in which case we may have to adjust its CCS.
      
      * The interpreter has its own implementation of stg_ap_0_fast, so we
        have to do the same shenanigans with creating empty PAPs and copying
        PAPs there.
      
      * GHCi creates Cost Centres as children of CCS_MAIN, which enterFunCCS()
        wrongly assumed to imply that they were CAFs.  Now we use the is_caf
        flag for this, which we have to correctly initialise when we create a
        Cost Centre in GHCi.
      3a18baff
    • Ryan Scott's avatar
      Add performance test for #13056 · 50881100
      Ryan Scott authored
      This performance regression was fixed by commit
      517d03e4 (#12234). Let's add a performance test
      to ensure that it doesn't break again.
      50881100
    • Simon Peyton Jones's avatar
      Fix the implementation of the "push rules" · b4f2afe7
      Simon Peyton Jones authored
      Richard pointed out (comment:12 of Trac #13025) that my
      implementation of the coercion "push rules", newly added
      in exprIsConAppMaybe by commit b4c3a668, wasn't quite right.
      
      But in fact that means that the implementation of those same
      rules in Simplify.simplCast was wrong too.
      
      Hence this commit:
      
      * Refactor the push rules so they are implemented in just
        one place (CoreSubst.pushCoArgs, pushCoTyArg, pushCoValArg)
        The code in Simplify gets simpler, which is nice.
      
      * Fix the bug that Richard pointed out (to do with hetero-kinded
        coercions)
      
      Then compiler performance worsened, which led mt do discover
      two performance bugs:
      
      * The smart constructor Coercion.mkNthCo didn't have a case
        for ForAllCos, which meant we stupidly build a complicated
        coercion where a simple one would do
      
      * In OptCoercion there was one place where we used CoherenceCo
        (the data constructor) rather than mkCoherenceCo (the smart
        constructor), which meant that the the stupid complicated
        coercion wasn't optimised away
      
      For reasons I don't fully understand, T5321Fun did 2% less compiler
      allocation after all this, which is good.
      b4f2afe7
    • Simon Peyton Jones's avatar
      Avoid exponential blowup in FamInstEnv.normaliseType · 3540d1e1
      Simon Peyton Jones authored
      Trac #13035 showed up a nasty case where we took exponentially
      long to normalise a (actually rather simple) type.  Fortunately
      it was easy to fix: see Note [Normalisation and type synonyms].
      3540d1e1
  8. 05 Jan, 2017 2 commits
    • Joachim Breitner's avatar
      Add a CSE pass to Stg (#9291) · 19d5c731
      Joachim Breitner authored
      This CSE pass only targets data constructor applications. This is
      probably the best we can do, as function calls and primitive operations
      might have side-effects.
      
      Introduces the flag -fstg-cse, enabled by default with -O for now. It
      might also be a good candiate for -O2.
      
      Differential Revision: https://phabricator.haskell.org/D2871
      19d5c731
    • Simon Peyton Jones's avatar
      Ensure nested binders have Internal Names · baf9ebe5
      Simon Peyton Jones authored
      This is a long-standing bug.  A nested (non-top-level) binder
      in Core should not have an External Name, like M.x. But
      
      - Lint was not checking this invariant
      
      - The desugarer could generate programs that failed the
        invariant.  An example is in
        tests/deSugar/should_compile/T13043, which had
           let !_ = M.scState in ...
        This desugared to
           let ds = case M.scSate of M.scState { DEFAULT -> () }
           in case ds of () -> ...
      
        We were wrongly re-using that scrutinee as a case binder.
        And Trac #13043 showed that could ultimately lead to two
        top-level bindings with the same closure name.  Alas!
      
      - The desugarer had one other place (in DsUtils.mkCoreAppDs)
        that could generate bogus code
      
      This patch fixes all three bugs, and adds a regression test.
      baf9ebe5
  9. 02 Jan, 2017 2 commits
  10. 28 Dec, 2016 1 commit
    • Tamar Christina's avatar
      Fix various issues with testsuite code on Windows · a3704409
      Tamar Christina authored
      Summary:
      Previously we would make direct calls to `diff` using `os.system`.
      On Windows `os.system` is implemented using the standard
      idiom `CreateProcess .. WaitForSingleObject ..`.
      
      This again runs afoul with the `_exec` behaviour on Windows. So we ran
      into some trouble where sometimes `diff` would return before it's done.
      
      On tests which run multiple ways, such as `8086` what happens is that
      we think the diff is done and continue. The next way tries to set things
      up again by removing any previous directory. This would then fail with
      and error saying the directory can't be removed. Which is true, because
      the previous diff code/child is still running.
      
      We shouldn't make any external calls to anything using `os.system`.
      Instead just use `runCmd` which uses `timeout`. This also ensures that if
      we hit the cygwin bug where diff or any other utility hangs, we kill it and
      continue and not hang the entire test and leave hanging processes.
      
      Further more we also:
      Ignore error lines from `removeFile` from tools in the testsuite. This is a rather large
      hammer to work around the fact that `hsc2hs` often tries to remove it's own file too early.
      When this is patched the workaround can be removed. See Trac #9775
      
      We mark `prog003` as skip. Since this test randomly fails and passes. For stability it's disabled
      but it is a genuine bug which we should find. It's something with interface files being
      overwritten. See Trac #11317
      
      when `rmtree` hits a readonly file, the `onerror` handler is raised afterwards but not
      during the tree walk. It doesn't allow you to recover and continue as we thought.
      Instead you have to explicitly start again. This is why sometimes even though we
      call `cleanup` before `os.mkdirs`, it would sometimes fail with an error that the
      folder already exists. So we now do a second walk.
      
      A new verbosity level (4) will strip the silent flags from `MAKE` invocations so you can actually
      see what's going on.
      
      Test Plan: ./validate on build bots.
      
      Reviewers: bgamari, austin
      
      Reviewed By: bgamari
      
      Subscribers: mpickering, thomie, #ghc_windows_task_force
      
      Differential Revision: https://phabricator.haskell.org/D2894
      
      GHC Trac Issues: #12661, #11317, #9775
      a3704409
  11. 27 Dec, 2016 3 commits
  12. 26 Dec, 2016 1 commit
    • Joachim Breitner's avatar
      CallArity: Use exprIsCheap to detect thunks · 815099cc
      Joachim Breitner authored
      Originally, everything that is not in WHNF (`exprIsWHNF`) is considered
      a thunk, not eta-expanded, to avoid losing any sharing. This is also how
      the published papers on Call Arity describe it.
      
      In practice, there are thunks that do a just little work, such as
      pattern-matching on a variable, and the benefits of eta-expansion likely
      oughtweigh the cost of doing that repeatedly. Therefore, this
      implementation of Call Arity considers everything that is not cheap
      (`exprIsCheap`) as a thunk.
      
      Nofib reports -2.58% allocations for scs and -40.93% allocation for
      wheel-sieve1; the latter has - 2.92% runtime.
      815099cc
  13. 23 Dec, 2016 4 commits