1. 01 Aug, 2018 4 commits
    • Christiaan Baaij's avatar
      Plugin dependency information is stored separately · 52065e95
      Christiaan Baaij authored
      We need to store the used plugins so that we recompile
      a module when a plugin that it uses is recompiled.
      
      However, storing the `ModuleName`s of the plugins used by a
      module in the `dep_mods` field made the rest of GHC think
      that they belong in the HPT, causing at least the issues
      reported in #15234
      
      We therefor store the `ModuleName`s of the plugins in a
      new field, `dep_plgins`, which is only used the the
      recompilation logic.
      
      Reviewers: mpickering, bgamari
      
      Reviewed By: mpickering, bgamari
      
      Subscribers: alpmestan, rwbarton, thomie, carter
      
      GHC Trac Issues: #15234
      
      Differential Revision: https://phabricator.haskell.org/D4937
      52065e95
    • Richard Eisenberg's avatar
      Remove the type-checking knot. · f8618a9b
      Richard Eisenberg authored
      Bug #15380 hangs because a knot-tied TyCon ended up in a kind.
      Looking at the code in tcInferApps, I'm amazed this hasn't happened
      before! I couldn't think of a good way to fix it (with dependent
      types, we can't really keep types out of kinds, after all), so
      I just went ahead and removed the knot.
      
      This was remarkably easy to do. In tcTyVar, when we find a TcTyCon,
      just use it. (Previously, we looked up the knot-tied TyCon and used
      that.) Then, during the final zonk, replace TcTyCons with the real,
      full-blooded TyCons in the global environment. It's all very easy.
      
      The new bit is explained in the existing
      Note [Type checking recursive type and class declarations]
      in TcTyClsDecls.
      
      Naturally, I removed various references to the knot and the
      zonkTcTypeInKnot (and related) functions. Now, we can print types
      during type checking with abandon!
      
      NB: There is a teensy error message regression with this patch,
      around the ordering of quantified type variables. This ordering
      problem is fixed (I believe) with the patch for #14880. The ordering
      affects only internal variables that cannot be instantiated with
      any kind of visible type application.
      
      There is also a teensy regression around the printing of types
      in TH splices. I think this is really a TH bug and will file
      separately.
      
      Test case: dependent/should_fail/T15380
      f8618a9b
    • Ben Gamari's avatar
      Revert "Don't inline functions with RULES too early" · 1df50a0f
      Ben Gamari authored
      This commit causes significant performance regressions:
      ```
      bytes allocated value is too high:
          Expected    T9872d(normal) bytes allocated: 578498120 +/-5%
          Lower bound T9872d(normal) bytes allocated: 549573214
          Upper bound T9872d(normal) bytes allocated: 607423026
          Actual      T9872d(normal) bytes allocated: 677179968
          Deviation   T9872d(normal) bytes allocated:      17.1 %
      bytes allocated value is too high:
          Expected    T9872c(normal) bytes allocated: 3096670112 +/-5%
          Lower bound T9872c(normal) bytes allocated: 2941836606
          Upper bound T9872c(normal) bytes allocated: 3251503618
          Actual      T9872c(normal) bytes allocated: 3601872536
          Deviation   T9872c(normal) bytes allocated:       16.3 %
      bytes allocated value is too high:
          Expected    T9872b(normal) bytes allocated: 3730686224 +/-5%
          Lower bound T9872b(normal) bytes allocated: 3544151912
          Upper bound T9872b(normal) bytes allocated: 3917220536
          Actual      T9872b(normal) bytes allocated: 4374298272
          Deviation   T9872b(normal) bytes allocated:       17.3 %
      bytes allocated value is too high:
          Expected    T9872a(normal) bytes allocated: 2729927408 +/-5%
          Lower bound T9872a(normal) bytes allocated: 2593431037
          Upper bound T9872a(normal) bytes allocated: 2866423779
          Actual      T9872a(normal) bytes allocated: 3225788896
          Deviation   T9872a(normal) bytes allocated:       18.2 %
      ```
      It's not clear that this was intentional so I'm going to revert for now.
      
      This reverts commit 2110738b.
      1df50a0f
    • Ben Gamari's avatar
      rts: Fix unused function · 9bd48643
      Ben Gamari authored
      9bd48643
  2. 31 Jul, 2018 9 commits
  3. 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
  4. 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
  5. 28 Jul, 2018 1 commit
  6. 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
  7. 25 Jul, 2018 3 commits