1. 31 Jul, 2018 4 commits
  2. 30 Jul, 2018 5 commits
    • Ben Gamari's avatar
      base: Make Foreign.Marshal.Alloc.allocBytes[Aligned] NOINLINE · 56590db0
      Ben Gamari authored
      As noted in #14346, touch# may be optimized away when the simplifier can see
      that the continuation passed to allocaBytes will not return. Marking CPS-style
      functions with NOINLINE ensures that the simplier can't draw any unsound
      conclusions.
      
      Ultimately the right solution here will be to do away with touch# and instead
      introduce a scoped primitive as is suggested in #14375.
      
      Note: This was present in 8.2 but was never merged to 8.4 in hopes that
      we would have #14375 implemented in time. This meant that the issue
      regressed again in 8.4. Thankfully we caught it in time to fix it for
      8.6.
      
      (cherry picked from commit 404bf05e)
      56590db0
    • Josh Price's avatar
      a698bbfe
    • Ben Gamari's avatar
      Bump terminfo submodule to 0.4.1.2 · c6262464
      Ben Gamari authored
      c6262464
    • Roland Senn's avatar
      GHC doesn't handle ./ prefixed paths correctly (#12674) · a7c8acda
      Roland Senn authored
      Summary: If a filename starts with a hypen, GHC keeps the prefixed "./" path.
      
      Test Plan: make test TEST=T12674
      
      Reviewers: Phyx, nomeata, bgamari, erikd
      
      Reviewed By: Phyx
      
      Subscribers: rwbarton, thomie, carter
      
      GHC Trac Issues: #12674
      
      Differential Revision: https://phabricator.haskell.org/D5009
      a7c8acda
    • Ryan Scott's avatar
      Fix #15385 by using addDictsDs in matchGuards · 9d388eb8
      Ryan Scott authored
      Summary:
      When coverage checking pattern-matches, we rely on the call
      sites in the desugarer to populate the local dictionaries and term
      evidence in scope using `addDictsDs` and `addTmCsDs`. But it turns
      out that only the call site for desugaring `case` expressions was
      actually doing this properly. In another part of the desugarer,
      `matchGuards` (which handles pattern guards), it did not update the
      local dictionaries in scope at all, leading to #15385.
      
      Fixing this is relatively straightforward: just augment the
      `BindStmt` case of `matchGuards` to use `addDictsDs` and `addTmCsDs`.
      Accomplishing this took a little bit of import/export tweaking:
      
      * We now need to export `collectEvVarsPat` from `HsPat.hs`.
      * To avoid an import cycle with `Check.hs`, I moved `isTrueLHsExpr`
        from `DsGRHSs.hs` to `DsUtils.hs`, which resides lower on the
        import chain.
      
      Test Plan: make test TEST=T15385
      
      Reviewers: simonpj, bgamari
      
      Reviewed By: simonpj
      
      Subscribers: rwbarton, thomie, carter
      
      GHC Trac Issues: #15385
      
      Differential Revision: https://phabricator.haskell.org/D4968
      9d388eb8
  3. 29 Jul, 2018 1 commit
    • Ningning Xie's avatar
      Fix #15453: bug in ForAllCo case in opt_trans_rule · 11de4380
      Ningning Xie authored
      Summary:
      Given
      
      ```
      co1 = \/ tv1 : eta1. r1
      co2 = \/ tv2 : eta2. r2
      ```
      
      We would like to optimize `co1; co2` so we push transitivity inside forall.
      It should be
      
      ```
      \/tv1 : (eta1;eta2).  (r1; r2[tv2 |-> tv1 |> eta1])
      ```
      
      It is implemented in the ForAllCo case in opt_trans_rule in OptCoercion.
      However current implementation is not right:
      
      ```
      r2' = substCoWithUnchecked [tv2] [TyVarTy tv1] r2 -- ill-kinded!
      ```
      
      This patch corrects it to be
      
      ```
      r2' = substCoWithUnchecked [tv2] [mkCastTy (TyVarTy tv1) eta1] r2
      ```
      
      Test Plan: validate
      
      Reviewers: bgamari, goldfire, RyanGlScott
      
      Reviewed By: RyanGlScott
      
      Subscribers: rwbarton, thomie, carter
      
      GHC Trac Issues: #15453
      
      Differential Revision: https://phabricator.haskell.org/D5018
      11de4380
  4. 28 Jul, 2018 1 commit
  5. 27 Jul, 2018 17 commits
    • Krzysztof Gogolewski's avatar
      Fix Ar crashing on odd-sized object files (Trac #15396) · 754c3a55
      Krzysztof Gogolewski authored
      Summary: All the work was done by Moritz Angermann.
      
      Test Plan: validate
      
      Reviewers: angerman, RyanGlScott, bgamari
      
      Reviewed By: angerman
      
      Subscribers: rwbarton, thomie, carter
      
      GHC Trac Issues: #15396
      
      Differential Revision: https://phabricator.haskell.org/D5013
      754c3a55
    • Krzysztof Gogolewski's avatar
      Remove dead code in testsuite driver · 2cb08d72
      Krzysztof Gogolewski authored
      Test Plan: validate
      
      Reviewers: bgamari, O7 GHC - Testsuite
      
      Reviewed By: bgamari
      
      Subscribers: rwbarton, thomie, carter
      
      Differential Revision: https://phabricator.haskell.org/D4972
      2cb08d72
    • Peter Trommler's avatar
      Fix endian issues in ghc-heap · d7cb1bbc
      Peter Trommler authored
      In test heap_all arity and n_args were swapped on big endian
      systems.
      
      Take care of endianness when reading parts of a machine word
      from a `Word`.
      
      This fixes one out of 36 failing tests reported in #15399.
      
      Test Plan: validate
      
      Reviewers: simonmar, bgamari, hvr, erikd
      
      Reviewed By: simonmar
      
      Subscribers: rwbarton, thomie, carter
      
      GHC Trac Issues: #15399
      
      Differential Revision: https://phabricator.haskell.org/D5001
      d7cb1bbc
    • Ben Gamari's avatar
      Disable GNUC_ATTR_HOT when compiling with DEBUG · 40e9ec98
      Ben Gamari authored
      Test Plan: Validate
      
      Reviewers: simonmar
      
      Reviewed By: simonmar
      
      Subscribers: rwbarton, thomie, carter
      
      Differential Revision: https://phabricator.haskell.org/D5000
      40e9ec98
    • Ben Gamari's avatar
      rts: More forceful cc debugging flags · ccdc0328
      Ben Gamari authored
      Reviewers: simonmar, alpmestan
      
      Reviewed By: alpmestan
      
      Subscribers: rwbarton, thomie, carter
      
      Differential Revision: https://phabricator.haskell.org/D4999
      ccdc0328
    • Michael Sloan's avatar
      Modifications to support loading GHC into GHCi · 60ecf43a
      Michael Sloan authored
      This change was previously part of
      [D4904](https://phabricator.haskell.org/D4904), but is being split off
      to aid in getting this reviewed and merged.
      
      * The compiler code is built with `NoImplicitPrelude`, but GHCi's
        modules are incompatible with it. So, this adds the pragma to all GHCi
        modules that didn't have it, and adds imports of Prelude.
      
      * In order to run GHC within itself, a `call of 'initGCStatistics`
        needed to be skipped. This uses CPP to skip it when
        `-DGHC_LOADED_INTO_GHCI` is set.
      
      * There is an environment variable workaround suggested by Ben Gamari
        [1], where `_GHC_TOP_DIR` can be used to specify GHC's top dir if `-B`
        isn't provided.  This can be used to solve a problem where the GHC being
        run within GHCi attempts to look in `inplace/lib/lib/` instead of
        `inplace/lib/`.
      
      [1]: https://phabricator.haskell.org/D4904#135438
      
      Reviewers: goldfire, bgamari, erikd, alpmestan
      
      Reviewed By: alpmestan
      
      Subscribers: alpmestan, lelf, rwbarton, thomie, carter
      
      Differential Revision: https://phabricator.haskell.org/D4986
      60ecf43a
    • Ningning Xie's avatar
      update core-spec for GRefl and re-factored Refl · e5f3de2c
      Ningning Xie authored
      Ticket #15192 introduced the generalized reflexive coercion `GRefl` and
      nominal reflexive `Refl`, and removed `CoherenceCo`. Update core-spec
      accordingly.  Not sure about notations though; suggestions on more
      concise notations would be great.
      
      Test Plan: Read core-spec.pdf
      
      Reviewers: goldfire, bgamari
      
      Reviewed By: goldfire
      
      Subscribers: rwbarton, thomie, carter
      
      Differential Revision: https://phabricator.haskell.org/D4984
      e5f3de2c
    • Krzysztof Gogolewski's avatar
      Add an expect_broken test for #14185 · 3581212e
      Krzysztof Gogolewski authored
      Test Plan: validate
      
      Reviewers: goldfire, bgamari, alpmestan
      
      Reviewed By: alpmestan
      
      Subscribers: rwbarton, thomie, carter
      
      GHC Trac Issues: #14185
      
      Differential Revision: https://phabricator.haskell.org/D4981
      3581212e
    • Simon Marlow's avatar
      Fix gcCAFs() · e431d75f
      Simon Marlow authored
      The test here should have been changed after D1106.  It was harmless
      but we caught fewer GC'd CAFs than we should have.
      
      Test Plan:
      Using `nofib/imaginary/primes` compiled with `-debug`.
      
      Before:
      ```
      > ./primes 100 +RTS -G1 -A32k -DG
      CAF gc'd at 0x0x7b0960
      CAF gc'd at 0x0x788728
      CAF gc'd at 0x0x790db0
      CAF gc'd at 0x0x790de0
      12 CAFs live
      CAF gc'd at 0x0x788880
      12 CAFs live
      12 CAFs live
      12 CAFs live
      12 CAFs live
      12 CAFs live
      12 CAFs live
      12 CAFs live
      12 CAFs live
      12 CAFs live
      12 CAFs live
      12 CAFs live
      547
      CAF gc'd at 0x0x7995c8
      13 CAFs live
      ```
      
      After:
      
      ```
      > ./primes 100 +RTS -G1 -A32k -DG
      CAF gc'd at 0x0x7b0960
      CAF gc'd at 0x0x788728
      CAF gc'd at 0x0x790db0
      CAF gc'd at 0x0x790de0
      12 CAFs live
      CAF gc'd at 0x0x788880
      12 CAFs live
      12 CAFs live
      12 CAFs live
      12 CAFs live
      12 CAFs live
      12 CAFs live
      12 CAFs live
      12 CAFs live
      12 CAFs live
      12 CAFs live
      12 CAFs live
      547
      CAF gc'd at 0x0x7995c8
      CAF gc'd at 0x0x790ea0
      12 CAFs live
      ```
      
      Reviewers: bgamari, osa1, erikd, noamz
      
      Reviewed By: bgamari
      
      Subscribers: rwbarton, thomie, carter
      
      Differential Revision: https://phabricator.haskell.org/D4963
      e431d75f
    • Ömer Sinan Ağacan's avatar
      Run StgCse after unarise, fixes #15300 · 3c311e50
      Ömer Sinan Ağacan authored
      Given two unboxed sum terms:
      
          (# 1 | #) :: (# Int | Int# #)
          (# 1 | #) :: (# Int | Int  #)
      
      These two terms are not equal as they unarise to different unboxed
      tuples. However StgCse was thinking that these are equal, and replacing
      one of these with a binder to the other.
      
      To not deal with unboxed sums in StgCse we now do it after unarise. For
      StgCse to maintain post-unarise invariants we factor-out case binder
      in-scopeness check to `stgCaseBndrInScope` and use it in StgCse.
      
      Also did some refactoring in SimplStg.
      
      Another way to fix this would be adding a special case in StgCse to not
      bring unboxed sum binders in scope:
      
          diff --git a/compiler/simplStg/StgCse.hs
      b/compiler/simplStg/StgCse.hs
          index 6c740ca4cb..93a0f8f6ad 100644
          --- a/compiler/simplStg/StgCse.hs
          +++ b/compiler/simplStg/StgCse.hs
          @@ -332,7 +332,11 @@ stgCseExpr env (StgLetNoEscape binds body)
           stgCseAlt :: CseEnv -> OutId -> InStgAlt -> OutStgAlt
           stgCseAlt env case_bndr (DataAlt dataCon, args, rhs)
               = let (env1, args') = substBndrs env args
          -          env2 = addDataCon case_bndr dataCon (map StgVarArg
      args') env1
          +          env2
          +            | isUnboxedSumCon dataCon
          +            = env1
          +            | otherwise
          +            = addDataCon case_bndr dataCon (map StgVarArg args')
      env1
                       -- see note [Case 2: CSEing case binders]
                     rhs' = stgCseExpr env2 rhs
                 in (DataAlt dataCon, args', rhs')
      
      I think this patch seems better in that it doesn't add a special case to
      StgCse.
      
      Test Plan:
      Validate.
      
      I tried to come up with a minimal example but failed. I thought a simple
      program like
      
          data T = T (# Int | Int #) (# Int# | Int #)
      
          case T (# 1 | #) (# 1 | #) of ...
      
      should be enough to trigger this bug, but for some reason StgCse
      doesn't do
      anything on this program.
      
      Reviewers: simonpj, bgamari
      
      Reviewed By: simonpj
      
      Subscribers: rwbarton, thomie, carter
      
      GHC Trac Issues: #15300
      
      Differential Revision: https://phabricator.haskell.org/D4962
      3c311e50
    • Michael Sloan's avatar
      Fail instead of panic-ing when qAddTopDecls has conversion error · 774f366e
      Michael Sloan authored
      See https://ghc.haskell.org/trac/ghc/ticket/14627 for an example where
      GHC panics when using qAddTopDecls on [d| f = Bool |]. Instead, it
      should be a normal error message, and that's what this change is for. It
      does not entirely resolve Trac#14627, since "Illegal variable name:
      'bool'" isn't a very good error for this cirumstance.
      
      Test Plan: Manually tested.
      
      Reviewers: goldfire, bgamari
      
      Reviewed By: goldfire
      
      Subscribers: rwbarton, thomie, carter
      
      Differential Revision: https://phabricator.haskell.org/D4914
      774f366e
    • Michael Sloan's avatar
      Add a script for running a ghci that can load and run ghc · 13d40ff6
      Michael Sloan authored
      Add scripts and .ghci files for loading GHC into GHCi
      
      Major credit to Csongor Kiss who wrote nearly all of settings.ghci
      
      Some small modifications to GHC are needed to make this work, and this
      diff depends on [D4986](https://phabricator.haskell.org/D4986) being
      merged.
      
      Test Plan:
      Manual for now. I have some thoughts on how to run the entire testsuite
      against
      GHC-in-GHCi.
      
      Reviewers: alpmestan, mpickering, goldfire, bgamari, erikd
      
      Reviewed By: alpmestan
      
      Subscribers: rwbarton, thomie, carter
      
      Differential Revision: https://phabricator.haskell.org/D4904
      13d40ff6
    • Simon Jakobi's avatar
      Make :doc work for the ghc library · 25e1ea99
      Simon Jakobi authored
      We already include -haddock in the GhcLibHcOpts in order to include
      the boot libraries' docs in their .hi-files.
      
      By including -haddock in the GhcStage2HcOpts and GhcStage3HcOpts, we
      make the docs for the ghc library also available to the GHCi :doc
      command.
      
      Reviewers: bgamari
      
      Reviewed By: bgamari
      
      Subscribers: rwbarton, thomie, carter
      
      Differential Revision: https://phabricator.haskell.org/D4913
      25e1ea99
    • Mitsutoshi Aoe's avatar
      rts: Flush eventlog in hs_init_ghc (fixes #15440) · 7a3e1b25
      Mitsutoshi Aoe authored
      Without this change RTS typically doesn't flush some important
      events until the process terminates or it doesn't write them at
      all in case it terminates abnormally.
      
      Here is a list of such events:
      
      * EVENT_WALL_CLOCK_TIME
      * EVENT_OS_PROCESS_PID
      * EVENT_OS_PROCESS_PPID
      * EVENT_RTS_IDENTIFIER
      * EVENT_PROGRAM_ARGS
      * EVENT_PROGRAM_ENV
      7a3e1b25
    • Ben Gamari's avatar
      Bump haddock submodule · 890f6468
      Ben Gamari authored
      890f6468
    • Simon Peyton Jones's avatar
      Small refactor in desugar of pattern matching · 45cfe651
      Simon Peyton Jones authored
      In reviewing Phab:D4968 for Trac #15385 I saw a small
      but simple refactor to avoid unnecessary work in the
      desugarer.
      
      This patch just arranges to call
         matchSinglePatVar v ...
      rather than
         matchSinglePat (Var v) ...
      
      The more specialised function already existed, as
         match_single_pat_var
      
      I also added more comments about decideBangHood
      45cfe651
    • Simon Peyton Jones's avatar
      Refactor (~) to reduce the suerpclass stack · f265008f
      Simon Peyton Jones authored
      The constraint (~) used to be (effectively):
        class a ~~ b => (a :: k) ~ (b :: k)
      
      but, with this patch, it is now defined uniformly with
      (~~) and Coercible like this:
        class a ~# b => (a :: k) ~ (b :: k)
      
      Result:
        * One less superclass selection when goinng from (~) to (~#)
          Better for compile time and better for debugging with -ddump-simpl
      
        * The code for (~), (~~), and Coercible looks uniform, and appears
          together, e.g. in TysWiredIn and ClsInst.matchGlobalInst.
          Previously the code for (~) was different, and unique.
      
      Not only is this simpler, but it also makes the compiler a bit faster;
        T12227: 9% less allocation
        T12545: 7% less allocation
      
      This patch fixes Trac #15421
      f265008f
  6. 25 Jul, 2018 9 commits
    • Simon Peyton Jones's avatar
      Comments only · 4c571f33
      Simon Peyton Jones authored
      4c571f33
    • Simon Peyton Jones's avatar
      Fix PrelRules.caseRules to account for out-of-range tags · 9897f678
      Simon Peyton Jones authored
      As Trac #15436 points out, it is possible to get
         case dataToTag# (x :: T) of
            DEFAULT -> blah1
            -1#     -> blah2
            0       -> blah3
      
      The (-1#) alterantive is unreachable, because dataToTag# returns
      tags in the range [0..n-1] where n is the number of data constructors
      in type T.
      
      This actually made GHC crash; now we simply discard the unreachable
      alterantive.  See Note [Unreachable caseRules alternatives]
      in PrelRules
      9897f678
    • Simon Peyton Jones's avatar
      Comments only · 0f5a63e3
      Simon Peyton Jones authored
      0f5a63e3
    • Simon Peyton Jones's avatar
      tc-tracing only · a434bcbc
      Simon Peyton Jones authored
      a434bcbc
    • Simon Peyton Jones's avatar
      Fix and document cloneWC · 857ef25e
      Simon Peyton Jones authored
      The cloneWC, cloneWanted, cloneImplication family are used by
        * TcHoleErrors
        * TcRule
      to clone the /bindings/ in a constraint, so that solving the
      constraint will not add bindings to the program. The idea is only
      to affect unifications.
      
      But I had it wrong -- I failed to clone the EvBindsVar of an
      implication.  That gave an assert failure, I think, as well as
      useless dead code.
      
      The fix is easy.  I'm not adding a test case.
      
      In the type 'TcEvidence.EvBindsVar', I also renamed the
      'NoEvBindsVar' constructor to 'CoEvBindsVar'.  It's not that we
      have /no/ evidence bindings, just that we can only have coercion
      bindings, done via HoleDest.
      857ef25e
    • Simon Peyton Jones's avatar
      Treat isConstraintKind more consistently · c5d31df7
      Simon Peyton Jones authored
      It turned out that we were not being consistent
      about our use of isConstraintKind.
      
      It's delicate, because the typechecker treats Constraint and Type as
      /distinct/, whereas they are the /same/ in the rest of the compiler
      (Trac #11715).
      
      And had it wrong, which led to Trac #15412.  This patch does the
      following:
      
      * Rename isConstraintKind      to tcIsConstraintKind
               returnsConstraintKind to tcReturnsConstraintKind
        to emphasise that they use the 'tcView' view of types.
      
      * Move these functions, and some related ones (tcIsLiftedTypeKind),
        from Kind.hs, to group together in Type.hs, alongside isPredTy.
      
      It feels very unsatisfactory that these 'tcX' functions live in Type,
      but it happens because isPredTy is called later in the compiler
      too.  But it's a consequence of the 'Constraint vs Type' dilemma.
      c5d31df7
    • Simon Peyton Jones's avatar
      Improve error message on un-satisfied import · f7d3054a
      Simon Peyton Jones authored
      Consider
        import M( C( a,b,c ) )
      where class C is defined as
        module M where
           class C x where
              a :: blah
              c :: blah
      
      Tnen (Trac #15413) we'd like to get an error message only about
      failing to import C( b ), not C( a,b,c ).
      
      This was fairly easy (and local) to do.
      
      Turned out that the existing tests mod81 and mod91 are adequate
      tests for the feature.
      f7d3054a
    • Simon Peyton Jones's avatar
      Set GenSigCtxt for the argument part of tcSubType · 12c0f03a
      Simon Peyton Jones authored
      The reason for this change is described in TcUnify
      Note [Settting the argument context], and Trac #15438.
      
      The only effect is on error messages, where it stops GHC
      reporting an outright falsity (about the type signature for
      a function) when it finds an errors in a higher-rank situation.
      
      The testsuite changes in this patch illustrate the problem.
      12c0f03a
    • Simon Peyton Jones's avatar
      Build more implications · 6c19112e
      Simon Peyton Jones authored
      The "non-local error" problem in Trac #14185 was due to the
      interaction of constraints from different function definitions.
      
      This patch makes a start towards fixing it.  It adds
      TcUnify.alwaysBuildImplication to unconditionally build an
      implication in some cases, to keep the constraints from different
      functions separate.
      
      See the new Note [When to build an implication] in TcUnify.
      
      But a lot of error messages change, so for now I have set
         alwaysBuildImplication = False
      
      Result: no operational change at all.  I'll get back to it!
      6c19112e
  7. 24 Jul, 2018 3 commits
    • Matthías Páll Gissurarson's avatar
      Clone relevant constraints to avoid side-effects on HoleDests. Fixes #15370. · 0dc86f6b
      Matthías Páll Gissurarson authored
      Summary: When looking for valid hole fits, the constraints relevant
      to the hole may sometimes contain a HoleDest. Previously,
      these were not cloned, which could cause the filling of filled
      coercion hole being, which would cause an assert to fail. This is now fixed.
      
      Test Plan: Regression test included.
      
      Reviewers: simonpj, bgamari, goldfire
      
      Reviewed By: simonpj
      
      Subscribers: rwbarton, thomie, carter
      
      GHC Trac Issues: #15370
      
      Differential Revision: https://phabricator.haskell.org/D5004
      0dc86f6b
    • Krzysztof Gogolewski's avatar
      Remove dead code in TcUnify · 47561c91
      Krzysztof Gogolewski authored
      Summary: RelaxedPolyRec is not used anymore
      
      Test Plan: validate
      
      Reviewers: bgamari, alpmestan
      
      Reviewed By: alpmestan
      
      Subscribers: rwbarton, thomie, carter
      
      Differential Revision: https://phabricator.haskell.org/D4983
      47561c91
    • Ryan Scott's avatar
      Suppress -Winaccessible-code in derived code · 44a7b9ba
      Ryan Scott authored
      Summary:
      It's rather unfortunate that derived code can produce inaccessible
      code warnings (as demonstrated in #8128, #8740, and #15398), since
      the programmer has no control over the generated code. This patch
      aims to suppress `-Winaccessible-code` in all derived code. It
      accomplishes this by doing the following:
      
      * Generalize the `ic_env :: TcLclEnv` field of `Implication` to
        be of type `Env TcGblEnc TcLclEnv` instead. This way, it also
        captures `DynFlags`, which record the flag state at the time
        the `Implication` was created.
      * When typechecking derived code, turn off `-Winaccessible-code`.
        This way, any insoluble given `Implication`s that are created when
        typechecking this derived code will remember that
        `-Winaccessible-code` was disabled.
      * During error reporting, consult the `DynFlags` of an
        `Implication` before making the decision to report an inaccessible
        code warning.
      
      Test Plan: make test TEST="T8128 T8740 T15398"
      
      Reviewers: simonpj, bgamari
      
      Reviewed By: simonpj
      
      Subscribers: monoidal, rwbarton, thomie, carter
      
      GHC Trac Issues: #8128, #8740, #15398
      
      Differential Revision: https://phabricator.haskell.org/D4993
      44a7b9ba