1. 19 Apr, 2018 1 commit
    • Ryan Scott's avatar
      Fix #14710 with more validity checks during renaming · 447d1264
      Ryan Scott authored
      Summary:
      #14710 revealed two unfortunate regressions related to kind
      polymorphism that had crept in in recent GHC releases:
      
      1. While GHC was able to catch illegal uses of kind polymorphism
         (i.e., if `PolyKinds` wasn't enabled) in limited situations, it
         wasn't able to catch kind polymorphism of the following form:
      
      ```lang=haskell
      f :: forall a. a -> a
      f x = const x g
        where
          g :: Proxy (x :: a)
          g = Proxy
      ```
      
      Note that the variable `a` is being used as a kind variable in the
      type signature of `g`, but GHC happily accepts it, even without
      the use of `PolyKinds`.
      
      2. If you have `PolyKinds` (but not `TypeInType`) enabled, then GHC
         incorrectly accepts the following definition:
      
      ```lang=haskell
      f :: forall k (a :: k). Proxy a
      f = Proxy
      ```
      
      Even though `k` is explicitly bound and then later used as a kind
      variable within the same telescope.
      
      This patch fixes these two bugs as follows:
      
      1. Whenever we rename any `HsTyVar`, we check if the following three
         criteria are met:
      
         (a) It's a type variable
         (b) It's used at the kind level
         (c) `PolyKinds` is not enabled
      
         If so, then we have found an illegal use of kind polymorphism, so
         throw an error.
      
         This check replaces the `checkBadKindBndrs` function, which could
         only catch illegal uses of kind polymorphism in very limited
         situations (when the bad kind variable happened to be implicitly
         quantified in the same type signature).
      
      2. In `extract_hs_tv_bndrs`, we must error if `TypeInType` is not
         enabled and either of the following criteria are met:
      
         (a) An explicitly bound type variable is used in kind position
             in the body of a `forall` type.
         (b) An explicitly bound type variable is used in kind position
             in the kind of a bound type variable in a `forall` type.
      
         `extract_hs_tv_bndrs` was checking (a), but not (b). Easily fixed.
      
      Test Plan: ./validate
      
      Reviewers: goldfire, simonpj, bgamari, hvr
      
      Reviewed By: simonpj
      
      Subscribers: thomie, carter
      
      GHC Trac Issues: #14710
      
      Differential Revision: https://phabricator.haskell.org/D4554
      447d1264
  2. 17 Apr, 2018 5 commits
  3. 16 Apr, 2018 3 commits
  4. 13 Apr, 2018 18 commits
    • Ben Gamari's avatar
    • Sylvain Henry's avatar
      Enhanced constant folding · fea04def
      Sylvain Henry authored
      Until now GHC only supported basic constant folding (lit op lit, expr op
      0, etc.).
      
      This patch uses laws of +/-/* (associativity, commutativity,
      distributivity) to support some constant folding into nested
      expressions.
      
      Examples of new transformations:
      
         - simple nesting: (10 + x) + 10 becomes 20 + x
         - deep nesting: 5 + x + (y + (z + (t + 5))) becomes 10 + (x + (y + (z + t)))
         - distribution: (5 + x) * 6 becomes 30 + 6*x
         - simple factorization: 5 + x + (x + (x + (x + 5))) becomes 10 + (4 *x)
         - siblings: (5 + 4*x) - (3*x + 2) becomes 3 + x
      
      Test Plan: validate
      
      Reviewers: simonpj, austin, bgamari
      
      Reviewed By: bgamari
      
      Subscribers: thomie
      
      GHC Trac Issues: #9136
      
      Differential Revision: https://phabricator.haskell.org/D2858
      fea04def
    • Ben Gamari's avatar
      Configure option to disable dtrace · 4b831c27
      Ben Gamari authored
      Reviewers: hvr, bgamari
      
      Subscribers: lelf, thomie, carter
      
      Differential Revision: https://phabricator.haskell.org/D4575
      4b831c27
    • Andreas Klebinger's avatar
      Omit ways depending on rts flags for #12870 related tests. · 9e89092d
      Andreas Klebinger authored
      Some of these tests instruct the RTS to ignore all RTS flags being
      passed.  While this is intended it causes test failures for some ways
      like profiling which depend on passing RTS flags. So we skip these ways.
      
      Test Plan: testsuite/tests/rts/flags$ make slow
      
      Reviewers: bgamari, simonmar, alpmestan
      
      Reviewed By: alpmestan
      
      Subscribers: alpmestan, thomie, carter
      
      GHC Trac Issues: #12870
      
      Differential Revision: https://phabricator.haskell.org/D4585
      9e89092d
    • Andreas Klebinger's avatar
      Make shortcutting at the asm stage toggleable and default for O2. · 3c7f9e74
      Andreas Klebinger authored
      Shortcutting during the asm stage of codegen is often redundant as most
      cases get caught during the Cmm passes.  For example during compilation
      of all of nofib only 508 jumps are eleminated.
      
      For this reason I moved the pass from -O1 to -O2. I also made it
      toggleable with -fasm-shortcutting.
      
      Test Plan: ci
      
      Reviewers: bgamari
      
      Reviewed By: bgamari
      
      Subscribers: thomie, carter
      
      Differential Revision: https://phabricator.haskell.org/D4555
      3c7f9e74
    • Ben Gamari's avatar
      Declare `catchRetry#` lazy in its first argument · 00b8ecb7
      Ben Gamari authored
      As per the results on item 1 in T14998, declaring `catchRetry#` lazy in
      its first argument opens the possibility to remove `ExnStr` complexity
      from strictness demands at virtually no regressions in NoFib.
      
      This brings `catchRetry#` in line with other primops from the `catch*`
      family.
      
      Reviewers: bgamari, simonpj, nomeata
      
      Reviewed By: bgamari
      
      Subscribers: thomie, carter
      
      GHC Trac Issues: #14998, #11222
      
      Differential Revision: https://phabricator.haskell.org/D4573
      00b8ecb7
    • Ryan Scott's avatar
      Correct FixIOException's @since annotation retroactively · ce27c7d5
      Ryan Scott authored
      Summary:
      In D4113, a `FixIOException` data type was added with a
      `@since TODO` annotation, but it seems that `TODO` made it out into
      `base-4.11` itself. I've (retroactively) fixed this and added an
      entry to the `base-4.11` entry in the `changelog`.
      
      Test Plan: Read it
      
      Reviewers: dfeuer, hvr, bgamari
      
      Reviewed By: dfeuer
      
      Subscribers: thomie, carter
      
      GHC Trac Issues: #14356, #15025
      
      Differential Revision: https://phabricator.haskell.org/D4578
      ce27c7d5
    • Ben Gamari's avatar
      Revert "Fix processHeapClosureForDead CONSTR_NOCAF case:" · 9430901d
      Ben Gamari authored
      This reverts commit a303584e.
      9430901d
    • U-Maokai\andi's avatar
      Use newtype deriving for Hoopl code · 6a78a40b
      U-Maokai\andi authored
      Hoopl.Collections/.Label has newtype containers which derive
      Functor/Traversable.
      Enabling GeneralizedNewtypeDeriving improves allocation count and
      compile time when building these files for GHC.
      
      ```
      Vanilla, O1
      <<ghc: 378555664 bytes, 76 GCs, 8663140/18535016 avg/max bytes
      residency (5 samples), 63M in use, 0.000 INIT (0.000 elapsed), 0.219
      MUT (0.354 elapsed), 0.141 GC (0.138 elapsed) :ghc>>
      
      GeneralizedNewtypeDeriving , O1
      <<ghc: 301026536 bytes, 78 GCs, 8392886/17181088 avg/max bytes
      residency (5 samples), 63M in use, 0.000 INIT (0.000 elapsed), 0.156
      MUT (0.230 elapsed), 0.094 GC (0.106 elapsed) :ghc>>
      ```
      
      Test Plan: ci
      
      Reviewers: bgamari, simonmar, RyanGlScott
      
      Reviewed By: RyanGlScott
      
      Subscribers: mpickering, RyanGlScott, thomie, carter
      
      Differential Revision: https://phabricator.haskell.org/D4583
      6a78a40b
    • Ryan Scott's avatar
      Fix #9438 by converting a panic to an error message · 7613a812
      Ryan Scott authored
      Previously, GHC was quite eager to panic whenever it was fed
      an archive file when `DYNAMIC_GHC_PROGRAMS=YES`. This ought to be an
      explicit error message instead, so this patch accomplishes just that.
      
      Test Plan: make test TEST=T14708
      
      Reviewers: Phyx, hvr, bgamari
      
      Reviewed By: Phyx
      
      Subscribers: thomie, carter
      
      GHC Trac Issues: #9438, #14708, #15032
      
      Differential Revision: https://phabricator.haskell.org/D4589
      7613a812
    • Matthew Pickering's avatar
      Remove unused function: mkFunCos · 6f623030
      Matthew Pickering authored
      Reviewers: goldfire, bgamari, dfeuer
      
      Reviewed By: dfeuer
      
      Subscribers: dfeuer, thomie, carter
      
      Differential Revision: https://phabricator.haskell.org/D4587
      6f623030
    • Andrey Mokhov's avatar
      Fix rts.cabal.in · f78df87c
      Andrey Mokhov authored
      On Windows the FFI library is called `libCffi-6` instead of `libCffi`.
      This needs to be reflected in `rts.cabal.in` as otherwise we cannot
      properly `copy` and `register` the RTS package on Windows.
      
      See https://github.com/snowleopard/hadrian/issues/567
      
      Test Plan: Build GHC using Hadrian. Make build system does not use
      `rts.cabal.in`.
      
      Reviewers: bgamari, erikd, simonmar, Phyx
      
      Reviewed By: Phyx
      
      Subscribers: thomie, carter
      
      Differential Revision: https://phabricator.haskell.org/D4590
      f78df87c
    • Andreas Klebinger's avatar
      Update JMP_TBL targets during shortcutting in X86 NCG. · 120a2617
      Andreas Klebinger authored
      Without updating the JMP_TBL information the block list in
      JMP_TBL contained blocks which were eliminated in some circumstances.
      
      The actual assembly generation doesn't look at these fields so this
      didn't cause any bugs yet. However as long as we carry this information
      around we should make an effort to keep it correct.
      
      Especially since it's useful for debugging purposes and can be used
      for passes near the end of the codegen pipeline.
      In particular it's used by jumpDestsOfInstr which without these changes
      returns the wrong destinations.
      
      Test Plan: ci
      
      Reviewers: bgamari
      
      Subscribers: thomie, carter
      
      Differential Revision: https://phabricator.haskell.org/D4566
      120a2617
    • Ömer Sinan Ağacan's avatar
      Fix processHeapClosureForDead CONSTR_NOCAF case: · a303584e
      Ömer Sinan Ağacan authored
      CONSTR_NOCAF was introduced with 55d535da as a replacement for
      CONSTR_STATIC and CONSTR_NOCAF_STATIC, however, as explained in Note
      [static constructors], we copy CONSTR_NOCAFs (which can also be seen in
      evacuate) during GC, and they can become dead, like other CONSTR_X_Ys.
      processHeapClosureForDead is updated to reflect this.
      
      Reviewers: bgamari, simonmar, erikd
      
      Subscribers: thomie, carter
      
      GHC Trac Issues: #7836
      
      Differential Revision: https://phabricator.haskell.org/D4567
      a303584e
    • Michal Terepeta's avatar
      Revert "CmmPipeline: add a second pass of CmmCommonBlockElim" · 78ff6e54
      Michal Terepeta authored
      This reverts commit d5c4d46a.
      
      Please see #14989 for details.
      
      Test Plan: ./validate
      
      Reviewers: bgamari, simonmar
      
      Subscribers: thomie, carter
      
      GHC Trac Issues: #14989
      
      Differential Revision: https://phabricator.haskell.org/D4577
      78ff6e54
    • Takenobu Tani's avatar
      users-guide: Update release notes and language extensions · f02309fe
      Takenobu Tani authored
      Update release notes and language extensions for GHC 8.6.1.
      
      * Add `BlockArguments` and `NumericUndescores` in release note
      * Fix directive for `HexFloatLiterals` and `NumericUndescores`
      
      Test Plan: build
      
      Reviewers: bgamari
      
      Reviewed By: bgamari
      
      Subscribers: thomie, carter
      
      Differential Revision: https://phabricator.haskell.org/D4579
      f02309fe
    • Ryan Scott's avatar
      Bump version numbers: base-4.11.1.0, integer-gmp-1.0.2.0 · c4814ab6
      Ryan Scott authored
      This takes care of bumping the `base` and `integer-gmp`
      minor version numbers in anticipation of a GHC 8.4.2 release.
      
      While I was in town, I also filled in a `@since TODO` Haddock
      annotation for `powModSecInteger` in `integer-gmp` with
      `1.0.2.0`, and updated the changelog accordingly.
      
      Test Plan: ./validate
      
      Reviewers: hvr, goldfire, bgamari
      
      Reviewed By: bgamari
      
      Subscribers: thomie, carter
      
      GHC Trac Issues: #15025
      
      Differential Revision: https://phabricator.haskell.org/D4586
      c4814ab6
    • Alan Zimmerman's avatar
      TTG for HsBinds and Data instances Plan B · b1386942
      Alan Zimmerman authored
      Summary:
      - Add the balance of the TTG extensions for hsSyn/HsBinds
      
      - Move all the (now orphan) data instances into hsSyn/HsInstances and
      use TTG Data instances Plan B
      https://ghc.haskell.org/trac/ghc/wiki/ImplementingTreesThatGrow/Instances#PLANB
      
      Updates haddock submodule.
      
      Illustrative numbers
      
      Compiling HsInstances before using Plan B.
      
      Max residency ~ 5G
      <<ghc: 629,864,691,176 bytes, 5300 GCs,
             321075437/1087762592 avg/max bytes residency (23 samples),
             2953M in use, 0.000 INIT (0.000 elapsed),
             383.511 MUT (384.986 elapsed), 37.426 GC (37.444 elapsed) :ghc>>
      
      Using Plan B
      
      Max residency 1.1G
      
      <<ghc: 78,832,782,968 bytes, 2884 GCs,
             222140352/386470152 avg/max bytes residency (34 samples),
             1062M in use, 0.001 INIT (0.001 elapsed),
             56.612 MUT (62.917 elapsed), 32.974 GC (32.923 elapsed) :ghc>>
      
      Test Plan: ./validate
      
      Reviewers: shayan-najd, goldfire, bgamari
      
      Subscribers: goldfire, thomie, mpickering, carter
      
      Differential Revision: https://phabricator.haskell.org/D4581
      b1386942
  5. 12 Apr, 2018 3 commits
  6. 11 Apr, 2018 4 commits
  7. 10 Apr, 2018 6 commits
    • Joachim Breitner's avatar
      In Exitify, zap idInfo of abstracted variables (fixes #15005) · 3cfb12d8
      Joachim Breitner authored
      as helpfully outlined by SPJ.
      
      This commit copies a small bit code from `SetLevels` which could
      reasonably be put in `Id` as `zapAllIdinfo`; I did not do this to make
      merging this commmit into `ghc-8.4` easier.
      
      If this commit gets merged, then presumably after commit
      3f59d380 (test case) and
      ae0cff0a (other fixes to Exitify.hs).
      
      Differential Revision: https://phabricator.haskell.org/D4582
      3cfb12d8
    • Richard Eisenberg's avatar
      Discard reflexive casts during Simplify · 7bb7f991
      Richard Eisenberg authored
      Trac #14735 (derived from Trac #11735) found that 75% of compile
      time was being spent in simplCast. This patch is the first in a series
      to deal with that problem.
      
      This particular patch actually has very little effect on performance; it
      just refactors simplCast so that it builds Refl coercions less often.
      Refl coercions require us to compute the type to put inside them, and
      even if that's done lazily it is still work and code. Instead we use
      Maybe Coercion with Nothing for Refl. This change also percolates to
      pushCoTyArg and pushValArg.
      
      Reviewers: goldfire, bgamari, simonpj
      
      Reviewed By: simonpj
      
      Subscribers: rwbarton, thomie, carter
      
      GHC Trac Issues: #14737
      
      Differential Revision: https://phabricator.haskell.org/D4395
      7bb7f991
    • Ben Gamari's avatar
      Revert "Fix #14838 by marking TH-spliced code as FromSource" · c054162a
      Ben Gamari authored
      This reverts commit ffb2738f.
      
      Due to #14987.
      
      Reviewers: goldfire, RyanGlScott
      
      Reviewed By: RyanGlScott
      
      Subscribers: RyanGlScott, thomie, carter
      
      GHC Trac Issues: #14987, #14838
      
      Differential Revision: https://phabricator.haskell.org/D4545
      c054162a
    • Edward Z. Yang's avatar
      Move gmp/config.mk.in to config.mk.in, fix #14972 · 2534164a
      Edward Z. Yang authored
      
      
      Here's how the rube goldberg machine triggered the old bug:
      
      1. If you have a file gmp/config.mk.in, then Cabal will
      create a generated file in $DIST/build/gmp/config.mk
      
      2. When you attempt to load inplace integer-gmp via GHCi, it will
      ask gcc (aka clang on OS X) for the file name of 'gmp', with
      base directory set to $DIST/build
      
      3. There is a folder named 'gmp', and so this folder is returned
      as the 'library' for gmp
      
      4. GHCi loadArchive chokes to death trying to open a library
      that is actually a folder
      
      This patch solves the problem by breaking the chain at (1): if we
      don't put config.mk in a folder named gmp, NO PROBLEM.
      Signed-off-by: Edward Z. Yang's avatarEdward Z. Yang <ezyang@fb.com>
      
      Test Plan: validate
      
      Reviewers: angerman, hvr, bgamari
      
      Reviewed By: angerman
      
      Subscribers: erikd, thomie, carter
      
      GHC Trac Issues: #14972
      
      Differential Revision: https://phabricator.haskell.org/D4552
      2534164a
    • Edward Z. Yang's avatar
      Minor typofix in LoadArchive.c · 81e7980a
      Edward Z. Yang authored
      Test Plan: none
      
      Reviewers: bgamari, erikd, simonmar
      
      Reviewed By: bgamari
      
      Subscribers: thomie, carter
      
      Differential Revision: https://phabricator.haskell.org/D4551
      81e7980a
    • Ben Gamari's avatar
      rts/RetainerProfile: Handle BLOCKING_QUEUES · d5f6d7a0
      Ben Gamari authored
      push() considers BLOCKING_QUEUES to be an invalid closure type which
      should never be present on the stack. However, retainClosure made no
      accomodation for this and ended up pushing such a closure. This lead
      to #14947.
      
      Test Plan: Validate
      
      Reviewers: simonmar, erikd
      
      Reviewed By: simonmar
      
      Subscribers: thomie, carter, RyanGlScott
      
      GHC Trac Issues: #14947
      
      Differential Revision: https://phabricator.haskell.org/D4538
      d5f6d7a0