1. 14 May, 2018 3 commits
    • Ryan Scott's avatar
      Fix #14875 by introducing PprPrec, and using it · 21e1a00c
      Ryan Scott authored
      Trying to determine when to insert parentheses during TH
      conversion is a bit of a mess. There is an assortment of functions
      that try to detect this, such as:
      * `hsExprNeedsParens`
      * `isCompoundHsType`
      * `hsPatNeedsParens`
      * `isCompoundPat`
      * etc.
      To make things worse, each of them have slightly different semantics.
      Plus, they don't work well in the presence of explicit type
      signatures, as #14875 demonstrates.
      All of these problems can be alleviated with the use of an explicit
      precedence argument (much like what `showsPrec` currently does). To
      accomplish this, I introduce a new `PprPrec` data type, and define
      standard predences for things like function application, infix
      operators, function arrows, and explicit type signatures (that last
      one is new). I then added `PprPrec` arguments to the various
      `-NeedsParens` functions, and use them to make smarter decisions
      about when things need to be parenthesized.
      A nice side effect is that functions like `isCompoundHsType` are
      now completely unneeded, since they're simply aliases for
      `hsTypeNeedsParens appPrec`. As a result, I did a bit of refactoring
      to remove these sorts of functions. I also did a pass over various
      utility functions in GHC for constructing AST forms and used more
      appropriate precedences where convenient.
      Along the way, I also ripped out the existing `TyPrec`
      data type (which was tailor-made for pretty-printing `Type`s) and
      replaced it with `PprPrec` for consistency.
      Test Plan: make test TEST=T14875
      Reviewers: alanz, goldfire, bgamari
      Reviewed By: bgamari
      Subscribers: rwbarton, thomie, carter
      GHC Trac Issues: #14875
      Differential Revision: https://phabricator.haskell.org/D4688
    • Matthew Pickering's avatar
      Add note documenting refineDefaultAlt · bf6cad8b
      Matthew Pickering authored
      Reviewers: sjakobi, bgamari
      Reviewed By: sjakobi
      Subscribers: rwbarton, thomie, carter
      Differential Revision: https://phabricator.haskell.org/D4687
    • Chaitanya Koparkar's avatar
      GHCi: Include a note in the hint to expose a hidden package · 30c887d3
      Chaitanya Koparkar authored
      Test Plan: validate
      Reviewers: bgamari, RyanGlScott, osa1
      Reviewed By: bgamari
      Subscribers: rwbarton, thomie, carter
      GHC Trac Issues: #15055
      Differential Revision: https://phabricator.haskell.org/D4669
  2. 13 May, 2018 5 commits
    • David Feuer's avatar
      Remove unused things from utils/Digraph · cdbe00fe
      David Feuer authored
      `utils/Digraph` had a bunch of code that wasn't actually being used,
      much of which wasn't documented at all, some of which was clearly
      ill-considered, and some of which was documented as being inefficient.
      Remove all unused code from that module except for the obvious and
      innocuous `emptyG`.
      Reviewers: bgamari
      Reviewed By: bgamari
      Subscribers: rwbarton, thomie, carter
      Differential Revision: https://phabricator.haskell.org/D4676
    • Sylvain Henry's avatar
      Refactor LitString · 7c665f9c
      Sylvain Henry authored
      Refactor LitString so that the string length is computed at most once
      and then stored.
      Also remove strlen and memcmp wrappers (it seems like they were a
      workaround for a very old GCC when using -fvia-C).
      Bumps haddock submodule.
      Reviewers: bgamari, dfeuer, nickkuk
      Reviewed By: bgamari, nickkuk
      Subscribers: nickkuk, dfeuer, thomie, carter
      Differential Revision: https://phabricator.haskell.org/D4630
    • Ben Gamari's avatar
      TcInteract: Ensure that tycons have representations before solving for Typeable · f0212a93
      Ben Gamari authored
      Summary: This fixes #15067.
      Test Plan: Validate
      Subscribers: thomie, carter, RyanGlScott
      GHC Trac Issues: #15067
      Differential Revision: https://phabricator.haskell.org/D4623
    • Matthew Pickering's avatar
      Simplify -ddump-json implementation · 6ab7cf99
      Matthew Pickering authored
      This patch takes the much simpler route of whenever the compiler tries
      to output something. We just dump a JSON document there and then.
      I think this should be sufficient to work with and anything more refined
      quickly got complicated as it was necessary to demarcate message scopes
      and so on.
      Reviewers: bgamari, dfeuer
      Reviewed By: bgamari
      Subscribers: Phyx, dfeuer, rwbarton, thomie, carter
      GHC Trac Issues: #14078
      Differential Revision: https://phabricator.haskell.org/D4532
    • Herbert Valerio Riedel's avatar
      Emit info-level log message when package envs are loaded · 00049e2d
      Herbert Valerio Riedel authored
      A common complaint with the new package environment files feature is
      that it's not obvious when package environments have been picked up.
      This patch applies the same strategy that was already used for `.ghci` files
      (which exhibit similar potential for confusion, c.f. #11389) to package
      environment files.
      For instance, this new notification looks like below for a GHCi invocation which
      loads both, a GHCi configuration as well as a package environment:
        GHCi, version 8.5.20180512: http://www.haskell.org/ghc/  :? for help
        Loaded package environment from /tmp/parsec-
        Loaded GHCi configuration from /home/hvr/.ghci
      Addresses #15145
      Reviewed By: bgamari, angerman
      GHC Trac Issues: #15145
      Differential Revision: https://phabricator.haskell.org/D4689
  3. 12 May, 2018 2 commits
  4. 10 May, 2018 2 commits
    • Simon Marlow's avatar
      Revert "Add -fghci-leak-check to check for space leaks" · 87e169a3
      Simon Marlow authored
      This reverts commit 5fe6aaa3.
    • Ömer Sinan Ağacan's avatar
      Fix #15038 · b2ff5dde
      Ömer Sinan Ağacan authored
      We introduce a new Id for unused pointer values in unboxed sums that is
      not CAFFY. Because the Id is not CAFFY it doesn't make non-CAFFY
      definitions CAFFY, fixing #15038.
      To make sure anything referenced by the new id will be retained we get a
      stable pointer to in on RTS startup.
      Test Plan: Passes validate
      Reviewers: simonmar, simonpj, hvr, bgamari, erikd
      Reviewed By: simonmar
      Subscribers: rwbarton, thomie, carter
      GHC Trac Issues: #15038
      Differential Revision: https://phabricator.haskell.org/D4680
  5. 09 May, 2018 1 commit
    • Simon Marlow's avatar
      Add -fghci-leak-check to check for space leaks · 5fe6aaa3
      Simon Marlow authored
      Space leaks in GHCi emerge from time to time and tend to come back again
      after they get fixed. This is an attempt to limit regressions by
      * adding a reliable detection for some classes of space leaks in GHCi
      * turning on leak checking for all GHCi tests in the test suite, so that
        we'll notice if the leak appears again.
      The idea for detecting space leaks is quite simple:
      * find some data that we expect to be GC'd later, make a weak pointer to it
      * when we expect the data to be dead, do a `performGC` and then check
        the status of the weak pointer.
      It would be nice to apply this trick to lots of things in GHC,
      e.g. ensuring that HsSyn is not retained after the desugarer, or
      ensuring that CoreSyn from the previous simplifier pass is not retained.
      Test Plan: validate
      Reviewers: bgamari, simonpj, erikd, niteria
      Subscribers: thomie, carter
      GHC Trac Issues: #15111
      Differential Revision: https://phabricator.haskell.org/D4658
  6. 08 May, 2018 7 commits
  7. 05 May, 2018 4 commits
  8. 04 May, 2018 1 commit
    • Simon Peyton Jones's avatar
      Simplify callSiteInline a little · 33de71fa
      Simon Peyton Jones authored
      This patch has virtually no effect on anything (according to a
      nofib run).  But it simplifies the definition of interesting_call
      by being a bit less gung-ho about inlining nested function
      bindings.  See Note [Nested functions]
              Program           Size    Allocs   Runtime   Elapsed  TotalMem
                 anna          +0.2%     -0.0%     0.163     0.163      0.0%
         binary-trees          +0.1%     +0.0%     -4.5%     -4.5%      0.0%
            cacheprof          -0.1%     +0.1%     -4.7%     -4.8%     +2.7%
                fasta          +0.2%      0.0%     +2.6%     +3.0%      0.0%
                fluid          -0.0%     -0.6%     0.011     0.011      0.0%
               gamteb          -0.1%     -0.0%     0.069     0.070      0.0%
                  hpg          +0.1%     +0.0%     +0.7%     +0.7%      0.0%
                infer          +0.3%     +0.2%     0.097     0.098      0.0%
               lambda          -0.1%     -0.0%     +2.0%     +2.0%      0.0%
               n-body          +0.1%     -0.1%     -0.1%     -0.1%      0.0%
               simple          -0.2%     -0.2%     +0.6%     +0.6%      0.0%
        spectral-norm          +0.1%     -0.0%     -0.1%     -0.1%      0.0%
                  tak          -0.0%     -0.1%     0.024     0.024      0.0%
                  Min          -0.4%     -0.6%     -5.3%     -5.3%      0.0%
                  Max          +0.3%     +0.2%     +3.3%     +3.3%    +15.0%
       Geometric Mean          -0.0%     -0.0%     -0.3%     -0.3%     +0.2%
  9. 03 May, 2018 4 commits
    • Chaitanya Koparkar's avatar
      GHCi: Improve the error message for hidden packages · 721e8264
      Chaitanya Koparkar authored
      Test Plan: make test TEST=T15055
      Reviewers: bgamari, RyanGlScott, osa1, Iceland_jack
      Reviewed By: osa1
      Subscribers: ulysses4ever, thomie, carter
      GHC Trac Issues: #15055
      Differential Revision: https://phabricator.haskell.org/D4621
    • niteria's avatar
      Correctly add unwinding info in manifestSp and makeFixupBlocks · 6132d7c5
      niteria authored
      In `manifestSp` the unwind info was before the relevant instruction, not
      after.  I added some notes to establish semantics.  Also removes
      redundant annotation in stg_catch_frame.
      For `makeFixupBlocks` it looks like we were off by `wORD_SIZE dflags`.
      I'm not sure why, but it lines up with `manifestSp`.  In fact it lines
      up so well so that I can consolidate the Sp unwind logic in
      `maybeAddUnwind`.  I detected the problems with `makeFixupBlocks` by
      running T14779b after patching D4559.
      Test Plan: added a new test
      Reviewers: bgamari, scpmw, simonmar, erikd
      Reviewed By: bgamari
      Subscribers: thomie, carter
      GHC Trac Issues: #14999
      Differential Revision: https://phabricator.haskell.org/D4606
    • Bertram Felgenhauer's avatar
      Compute DW_FORM_block length correctly; also fixes #15068 · 358b5080
      Bertram Felgenhauer authored
      Before this patch, the pprUnwindwExpr function computed the length of
      by the following assembly fragment:
      	.uleb128 1f-.-1
      	<expression data>
      That is, to compute the length, it takes the difference of the label 1
      and the address of the .uleb128 directive, and subtracts 1.
      In #15068 it was reported that `as` from binutils 4.30 has trouble with
      evaluating the `.` part of the expression. However, there is actually a
      problem with the expression, if the length of the data ever becomes
      larger than 128: In that case, the .uleb128 directive will emit more
      than 1 byte, and the computed length will be wrong.
      The present patch changes the assembly fragment to use two labels,
      which fixes both these problems.
      	.uleb128 2f-1f
      	<expression data>
      Test Plan: validate
      Reviewers: bgamari, osa1
      Reviewed By: bgamari
      Subscribers: thomie, carter
      GHC Trac Issues: #15068
      Differential Revision: https://phabricator.haskell.org/D4654
    • David Feuer's avatar
      Set arity for absentError · 198db048
      David Feuer authored
      * The note on how to prevent stable unfoldings from leading to
        `case` on `absentError` was wrong. Make it reflect reality.
      * Reviewing the above change, Simon noticed that we didn't
        set an arity for `absentError`, which definitely has arity 1.
        It may not matter much, since `absentError` usually vanishes
        quickly, but we might as well set it properly, so now we do.
      Reviewers: simonpj, bgamari
      Reviewed By: simonpj
      Subscribers: thomie, carter
      Differential Revision: https://phabricator.haskell.org/D4655
  10. 02 May, 2018 1 commit
  11. 01 May, 2018 2 commits
    • Simon Peyton Jones's avatar
      Preserve join-point arity in CoreOpt · d4cc74f1
      Simon Peyton Jones authored
      Trac #15108 showed that the simple optimiser in CoreOpt
      was accidentally eta-reducing a join point, so it didn't meet
      its arity invariant.
      This patch fixes it.  See Note [Preserve join-binding arity].
    • Simon Peyton Jones's avatar
      Don't crash when pretty-printing bad joins · 07cc6039
      Simon Peyton Jones authored
      Trac #15108 showed that the Core pretty-printer would
      crash if it found a join-point binding with too few lambda
      on the RHS.  That is super-unhelpful!  Lint will find it,
      but pretty-printing should not crash.
      This patch just makes the pretty printer behave more robustly;
      it leaves the job of error reporting to Lint.
  12. 27 Apr, 2018 8 commits
    • Simon Peyton Jones's avatar
      Better linting for types · 6da5b877
      Simon Peyton Jones authored
      Trac #15057 described deficiencies in the linting for types
      involving type synonyms.  This patch fixes an earlier attempt.
      The moving parts are desrcribed in
        Note [Linting type synonym applications]
      Not a big deal.
    • Simon Peyton Jones's avatar
      Make out-of-scope errors more prominent · 08003e7f
      Simon Peyton Jones authored
      Generally, when the type checker reports an error, more serious
      ones suppress less serious ones.
      A "variable out of scope" error is arguably the most serious of all,
      so this patch moves it to the front of the list instead of the end.
      This patch also fixes Trac #14149, which had
      -fdefer-out-of-scope-variables, but also had a solid type error.
      As things stood, the type error was not reported at all, and
      compilation "succeeded" with error code 0.  Yikes.
      Note that
      - "Hole errors" (including out of scope) are never suppressed.
        (maybeReportHoleError vs maybeReportError in TcErorrs)
        They can just get drowned by the noise.
      - But with the new orientation, out of scope errors will suppress
        type errors.  That would be easy to change.
    • Simon Peyton Jones's avatar
      Refactor tcExtendLocalFamInst a bit · 0c01224b
      Simon Peyton Jones authored
      This patch just pulls out FamInst.loadDependentFamInstModules
      as a separate function, and adds better comments.
      Provoked by Trac #14759, comment:10.
    • Simon Peyton Jones's avatar
      Comments only: the FVAnn invariant · 69119b20
      Simon Peyton Jones authored
    • Simon Peyton Jones's avatar
      Minor refactoring in Exitify · 512f5038
      Simon Peyton Jones authored
      No change in behaviour here, just some modest
      refactoring as I tried to understand the code
    • Alan Zimmerman's avatar
      TTG : complete for balance of hsSyn AST · c3823cba
      Alan Zimmerman authored
      - remove PostRn/PostTc fields
      - remove the HsVect In/Out distinction for Type, Class and Instance
      - remove PlaceHolder in favour of NoExt
      - Simplify OutputableX constraint
      Updates haddock submodule
      Test Plan: ./validate
      Reviewers: goldfire, bgamari
      Subscribers: goldfire, thomie, mpickering, carter
      Differential Revision: https://phabricator.haskell.org/D4625
    • Simon Peyton Jones's avatar
      Rename a local variable · 313720a4
      Simon Peyton Jones authored
    • Simon Peyton Jones's avatar
      Refactor in OccurAnal · 705dcb0d
      Simon Peyton Jones authored
      * (+++)                    -->  andUDs
      * combineAltsUsageDetails  -->  orUDs
      * combineUsageDetailsList  -->  andUDsList
      * Change some andUDsList to a fold for efficiency
      No change in behaviour