1. 29 Mar, 2020 1 commit
  2. 26 Mar, 2020 3 commits
    • Joachim Breitner's avatar
      Use run-time tablesNextToCode in compiler exclusively (#15548) · 1c446220
      Joachim Breitner authored
       - There is no more use of the TABLES_NEXT_TO_CODE CPP macro in
         `compiler/`. GHCI_TABLES_NEXT_TO_CODE is also removed entirely.
         The field within `PlatformMisc` within `DynFlags` is used instead.
       - The field is still not exposed as a CLI flag. We might consider some
         way to ensure the right RTS / libraries are used before doing that.
      Original reviewers:
      Original subscribers: TerrorJack, rwbarton, carter
      Original Differential Revision: https://phabricator.haskell.org/D5082
    • Sylvain Henry's avatar
      DynFlags refactoring III · 0de03cd7
      Sylvain Henry authored
      Use Platform instead of DynFlags when possible:
      * `tARGET_MIN_INT` et al. replaced with `platformMinInt` et al.
      * no more DynFlags in PreRules: added a new `RuleOpts` datatype
      * don't use `wORD_SIZE` in the compiler
      * make `wordAlignment` use `Platform`
      * make `dOUBLE_SIZE` a constant
      Metric Decrease:
    • Peter Trommler's avatar
      Do not panic on linker errors · 262e42aa
      Peter Trommler authored
  3. 25 Mar, 2020 1 commit
  4. 23 Mar, 2020 1 commit
    • Josef Svenningsson's avatar
      Fix ApplicativeDo regression #17835 · 19f12557
      Josef Svenningsson authored
      A previous fix for #15344 made sure that monadic 'fail' is used properly
      when translating ApplicativeDo. However, it didn't properly account
      for when a 'fail' will be inserted which resulted in some programs
      failing with a type error.
  5. 21 Mar, 2020 2 commits
    • Richard Eisenberg's avatar
      Update core spec to reflect changes to Core. · 9a96ff6b
      Richard Eisenberg authored
      Key changes:
       * Adds a new rule for forall-coercions over coercion variables, which
      was implemented but conspicuously missing from the spec.
       * Adds treatment for FunCo.
       * Adds treatment for ForAllTy over coercion variables.
       * Improves commentary (including restoring a Note lost in
      03d48526) in the source.
      No changes to running code.
    • Richard Eisenberg's avatar
      Simplify treatment of heterogeneous equality · 73a7383e
      Richard Eisenberg authored
      Previously, if we had a [W] (a :: k1) ~ (rhs :: k2), we would
      spit out a [D] k1 ~ k2 and part the W as irreducible, hoping for
      a unification. But we needn't do this. Instead, we now spit out
      a [W] co :: k2 ~ k1 and then use co to cast the rhs of the original
      Wanted. This means that we retain the connection between the
      spat-out constraint and the original.
      The problem with this new approach is that we cannot use the
      casted equality for substitution; it's too like wanteds-rewriting-
      wanteds. So, we forbid CTyEqCans that mention coercion holes.
      All the details are in Note [Equalities with incompatible kinds]
      in TcCanonical.
      There are a few knock-on effects, documented where they occur.
      While debugging an error in this patch, Simon and I ran into
      infelicities in how patterns and matches are printed; we made
      small improvements.
      This patch includes mitigations for #17828, which causes spurious
      pattern-match warnings. When #17828 is fixed, these lines should
      be removed.
  6. 19 Mar, 2020 2 commits
  7. 18 Mar, 2020 1 commit
  8. 17 Mar, 2020 4 commits
    • Richard Eisenberg's avatar
      Fix #17021 by checking more return kinds · 53ff2cd0
      Richard Eisenberg authored
      All the details are in new Note [Datatype return kinds] in
      Test case: typecheck/should_fail/T17021{,b}
      Updates haddock submodule
    • Ömer Sinan Ağacan's avatar
      Don't update ModDetails with CafInfos when opts are disabled · 5800ebfe
      Ömer Sinan Ağacan authored
      This is consistent with the interface file behavior where we omit
      HsNoCafRefs annotations with -fomit-interface-pragmas (implied by -O0).
      ModDetails and ModIface are just different representations of the same
      thing, so they really need to be in sync. This patch does the right
      thing and does not need too much explanation, but here's an example of a
      problem not doing this causes in !2842:
          -- MyInteger.hs
          module MyInteger
            ( MyInteger (MyInteger)
            , ToMyInteger (toMyInteger)
            ) where
          newtype MyInteger = MyInteger Integer
          class ToMyInteger a where
            toMyInteger :: a -> MyInteger
          instance ToMyInteger Integer where
            toMyInteger = MyInteger {- . succ -}
          -- Main.hs
          module Main
            ( main
            ) where
          import MyInteger (MyInteger (MyInteger), toMyInteger)
          main :: IO ()
          main = do
            let (MyInteger i) = (id . toMyInteger) (41 :: Integer)
            print i
      If I build this with -O0, without this fix, we generate a ModDetails with
      accurate LFInfo for toMyInteger (MyInteger.$fToMyIntegerInteger) which says that
      it's a LFReEntrant with arity 1. This means in the use site (Main) we tag the
          R3 = MyInteger.$fToMyIntegerInteger_closure + 1;
          R2 = GHC.Base.id_closure;
          R1 = GHC.Base.._closure;
          Sp = Sp - 16;
          call stg_ap_ppp_fast(R4, R3, R2, R1) args: 24, res: 0, upd: 24;
      Now we change the definition by uncommenting the `succ` part and it becomes a thunk:
          MyInteger.$fToMyIntegerInteger [InlPrag=INLINE (sat-args=0)]
            :: MyInteger.ToMyInteger GHC.Integer.Type.Integer
          [GblId[DFunId(nt)]] =
              {} \u [] $ctoMyInteger_rEA;
      and its LFInfo is now LFThunk. This change in LFInfo makes a difference in the
      use site: we can no longer tag it.
      But becuase the interface fingerprint does not change (because ModIface does not
      change) we don't rebuild Main and tag the thunk.
      (1.2% increase in allocations when building T12545 on armv7 because we
      generate more code without CafInfos)
      Metric Increase:
    • Simon Peyton Jones's avatar
      Implement mapTyCo like foldTyCo · beffa147
      Simon Peyton Jones authored
      This patch makes mapType use the successful idiom described
      in TyCoRep
         Note [Specialising foldType]
      I have not yet changed any functions to use mapType, though there
      may be some suitable candidates.
      This patch should be a no-op in terms of functionality but,
      because it inlines the mapper itself, I'm hoping that there may
      be some modest perf improvements.
      Metric Decrease:
    • Sylvain Henry's avatar
      Modules: Core (#13009) · 18a346a4
      Sylvain Henry authored
      Update submodule: haddock
  9. 15 Mar, 2020 3 commits
    • Judah Jacobson's avatar
      Add a -no-haddock flag. · c35c545d
      Judah Jacobson authored
      This flag undoes the effect of a previous "-haddock" flag.  Having both flags makes it easier
      for build systems to enable Haddock parsing in a set of global flags, but then disable it locally for
      specific targets (e.g., third-party packages whose comments don't pass the validation in the latest GHC).
      I added the flag to expected-undocumented-flags.txt since `-haddock` was alreadyin that list.
    • Sylvain Henry's avatar
      Refactor CmmToAsm (disentangle DynFlags) · 2e82465f
      Sylvain Henry authored
      This patch disentangles a bit more DynFlags from the native code
      generator (CmmToAsm).
      In more details:
      - add a new NCGConfig datatype in GHC.CmmToAsm.Config which contains the
        configuration of a native code generation session
      - explicitly pass NCGConfig/Platform arguments when necessary
      - as a consequence `sdocWithPlatform` is gone and there are only a few
        `sdocWithDynFlags` left
      - remove the use of `unsafeGlobalDynFlags` from GHC.CmmToAsm.CFG
      - remove `sdocDebugLevel` (now we pass the debug level via NCGConfig)
      There are still some places where DynFlags is used, especially because
      of pretty-printing (CLabel), because of Cmm helpers (such as
      `cmmExprType`) and because of `Outputable` instance for the
      instructions. These are left for future refactoring as this patch is
      already big.
    • Brian Foley's avatar
      Remove some dead code · b4774598
      Brian Foley authored
      From the notes.ghc.drop list found using weeder in #17713
  10. 14 Mar, 2020 4 commits
    • Krzysztof Gogolewski's avatar
    • Simon Peyton Jones's avatar
      Improve CSE.combineAlts · 88f7a762
      Simon Peyton Jones authored
      This patch improves the way that CSE combines identical
      alternatives.  See #17901.
      I'm still not happy about the duplication between CSE.combineAlts
      and GHC.Core.Utils.combineIdenticalAlts; see the Notes with those
      functions.  But this patch is a step forward.
      Metric Decrease:
    • Simon Peyton Jones's avatar
      Simple refactor of cheapEqExpr · 2f8c7767
      Simon Peyton Jones authored
      No change in functionality.  Just seems tidier (and signficantly more
      efficient) to deal with ticks directly than to call stripTicksTopE.
    • Simon Peyton Jones's avatar
      Fix Lint · c12a2ec5
      Simon Peyton Jones authored
      Ticket #17590 pointed out a bug in the way the linter dealt with
      type lets, exposed by the new uniqAway story.
      The fix is described in Note [Linting type lets]. I ended up
      putting the in-scope Ids in a different env field, le_ids,
      rather than (as before) sneaking them into the TCvSubst.
      Surprisingly tiresome, but done.
      Metric Decrease:
  11. 13 Mar, 2020 1 commit
    • Sylvain Henry's avatar
      Rename isDllName · 44fad4a9
      Sylvain Henry authored
      I wanted to fix the dangling comment in `isDllName` ("This is the cause
      of #", #8696 is already mentioned earlier). I took the opportunity to
      change the function name to better reflect what it does.
  12. 12 Mar, 2020 6 commits
    • Simon Peyton Jones's avatar
      Expose compulsory unfoldings always · 3a259092
      Simon Peyton Jones authored
      The unsafeCoerce# patch requires that unsafeCoerce# has
      a compulsory unfolding that is always available.  So we have
      to be careful to expose compulsory unfoldings unconditionally
      and consistently.
      We didn't get this quite right: #17871.  This patch fixes
      it.  No real surprises here.
      See Note [Always expose compulsory unfoldings] in GHC.Iface.Tidy
    • Kirill Elagin's avatar
      pretty-printer: Do not print ApplicativeDo join · 5cb93af7
      Kirill Elagin authored
      * Do not print `join` in ApplictiveStmt, unless ppr-debug
      * Print parens around multiple parallel binds
      When ApplicativeDo is enabled, the renamer analyses the statements of a
      `do` block and in certain cases marks them as needing to be rewritten
      using `join`.
      For example, if you have:
      foo = do
        a <- e1
        b <- e2
        doSomething a b
      it will be desugared into:
      foo = join (doSomething <$> e1 <*> e2)
      After renaming but before desugaring the expression is stored
      essentially as:
      foo = do
        [will need join] (a <- e1 | b <- e2)
        [no return] doSomething a b
      Before this change, the pretty printer would print a call to `join`,
      even though it is not needed at this stage at all. The expression will be
      actually rewritten into one using join only at desugaring, at which
      point a literal call to join will be inserted.
    • Kirill Elagin's avatar
      pretty-printer: Properly parenthesise LastStmt · 1f9db3e7
      Kirill Elagin authored
      After ApplicatveDo strips the last `return` during renaming, the pretty
      printer has to restore it. However, if the return was followed by `$`,
      the dollar was stripped too and not restored.
      For example, the last stamement in:
        foo = do
          x <- ...
          return $ f x
      would be printed as:
          return f x
      This commit preserved the dolar, so it becomes:
          return $ f x
    • Sylvain Henry's avatar
      Use a Set to represent Ways · a6989971
      Sylvain Henry authored
      Should make `member` queries faster and avoid messing up with missing
      Metric Increase:
    • Sylvain Henry's avatar
      Refactor interpreterDynamic and interpreterProfiled · bc41e471
      Sylvain Henry authored
      * `interpreterDynamic` and `interpreterProfiled` now take `Interp`
        parameters instead of DynFlags
      * slight refactoring of `ExternalInterp` so that we can read the iserv
        configuration (which is pure) without reading an MVar.
    • Sylvain Henry's avatar
      Refactor GHC.Driver.Session (Ways and Flags) · 8e6febce
      Sylvain Henry authored
      * extract flags and ways into their own modules (with some renaming)
      * remove one SOURCE import of GHC.Driver.Session from GHC.Driver.Phases
      * when GHC uses dynamic linking (WayDyn), `interpWays` was only
        reporting WayDyn even if the host was profiled (WayProf).  Now it
        returns both as expected (might fix #16803).
      * `mkBuildTag :: [Way] -> String` wasn't reporting a canonical tag for
        differently ordered lists. Now we sort and nub the list to fix this.
  13. 11 Mar, 2020 1 commit
    • Sylvain Henry's avatar
      Split GHC.Iface.Utils module · 20800b9a
      Sylvain Henry authored
      * GHC.Iface.Recomp: recompilation avoidance stuff
      * GHC.Iface.Make: mkIface*
      Moved `writeIfaceFile` into GHC.Iface.Load alongside `readIface` and
      renamed it `writeIface` for consistency.
  14. 10 Mar, 2020 3 commits
    • Krzysztof Gogolewski's avatar
      Typos in comments [skip ci] · abf5736b
      Krzysztof Gogolewski authored
    • Krzysztof Gogolewski's avatar
      Misc cleanup · 3300eeac
      Krzysztof Gogolewski authored
      - Remove Note [Existentials in shift_con_pat].
        The function shift_con_pat has been removed 15 years ago in 23f40f0e.
      - Remove kcLookupTcTyCon - it's the same as tcLookupTcTyCon
      - Remove ASSERT in tyConAppArgN. It's already done by getNth,
        and it's the only reason getNth exists.
      - Remove unused function nextRole
    • Ben Price's avatar
      Clarify a Lint message · 5ba01d83
      Ben Price authored
      When developing a plugin I had a shadowing problem, where I generated
        app = \f{v r7B} x{v r7B} -> f{v r7B} x{v r7B}
      This is obviously wrong, since the occurrence of `f` to the right of the
      arrow refers to the `x` binder (they share a Unique). However, it is
      rather confusing when Lint reports
        Mismatch in type between binder and occurrence
        Var: x{v rB7}
      since it is printing the binder, rather than the occurrence.
      It is rather easy to read this as claiming there is something wrong with
      the `x` occurrence!
      We change the report to explicitly print both the binder and the
      occurrence variables.
  15. 09 Mar, 2020 1 commit
  16. 02 Mar, 2020 2 commits
    • Roland Senn's avatar
      Set `ImpredicativeTypes` during :print command. (#14828) · 7c0c76fb
      Roland Senn authored
      If ImpredicativeTypes is not enabled, then `:print <term>` will fail if the
      type of <term> has nested `forall`s or `=>`s.
      This is because the GHCi debugger's internals will attempt to unify a
      metavariable with the type of <term> and then display the result, but if the
      type has nested `forall`s or `=>`s, then unification will fail.
      As a result, `:print` will bail out and the unhelpful result will be
      `<term> = (_t1::t1)` (where `t1` is a metavariable).
      Beware: <term> can have nested `forall`s even if its definition doesn't use
      RankNTypes! Here is an example from #14828:
        class Functor f where
          fmap :: (a -> b) -> f a -> f b
      Somewhat surprisingly, `:print fmap` considers the type of fmap to have
      nested foralls. This is because the GHCi debugger sees the type
      `fmap :: forall f. Functor f => forall a b. (a -> b) -> f a -> f b`.
      We could envision deeply instantiating this type to get the type
      `forall f a b. Functor f => (a -> b) -> f a -> f b`,
      but this trick wouldn't work for higher-rank types.
      Instead, we adopt a simpler fix: enable `ImpredicativeTypes` when using
      `:print` and friends in the GHCi debugger. This is allows metavariables
      to unify with types that have nested (or higher-rank) `forall`s/`=>`s,
      which makes `:print fmap` display as
      `fmap = (_t1::forall a b. Functor f => (a -> b) -> f a -> f b)`, as expected.
      Although ImpredicativeTypes is a somewhat unpredictable from a type inference
      perspective, there is no danger in using it in the GHCi debugger, since all
      of the terms that the GHCi debugger deals with have already been typechecked.
    • Krzysztof Gogolewski's avatar
      Remove dead code · 3cf7303b
      Krzysztof Gogolewski authored
      * The names in PrelName and THNames are no longer used
        since TH merged types and kinds, Typeable is kind-polymorphic,
        .net support was removed
      * unqualQuasiQuote no longer used since 6f8ff0bb
  17. 29 Feb, 2020 4 commits
    • Roland Senn's avatar
      Show breakpoint locations of breakpoints which were ignored during :force (#2950) · 3979485b
      Roland Senn authored
      GHCi is split up into 2 major parts: The user-interface (UI)
      and the byte-code interpreter. With `-fexternal-interpreter`
      they even run in different processes. Communication between
      the UI and the Interpreter (called `iserv`) is done using
      messages over a pipe. This is called `Remote GHCI` and
      explained in the Note [Remote GHCi] in `compiler/ghci/GHCi.hs`.
      To process a `:force` command the UI sends a `Seq` message
      to the `iserv` process. Then `iserv` does the effective
      evaluation of the value. When during this process a breakpoint
      is hit, the `iserv` process has no additional information to
      enhance the `Ignoring breakpoint` output with the breakpoint
      To be able to print additional breakpoint information,
      there are 2 possible implementation choices:
      1. Store the needed information in the `iserv` process.
      2. Print the `Ignoring breakpoint` from the UI process.
      For option 1 we need to store the breakpoint info redu...
    • Ömer Sinan Ağacan's avatar
      Simplify IfaceIdInfo type · 04d30137
      Ömer Sinan Ağacan authored
      IfaceIdInfo type is confusing: there's practically no difference between
      `NoInfo` and `HasInfo []`. The comments say NoInfo is used when
      -fomit-interface-pragmas is enabled, but we don't need to distinguish
      `NoInfo` from `HasInfo []` in when reading the interface so the
      distinction is not important.
      This patch simplifies the type by removing NoInfo. When we have no info
      we use an empty list.
      With this change we no longer read the info list lazily when reading an
      IfaceInfoItem, but when reading an IfaceId the ifIdInfo field is
      read lazily, so I doubt this is going to be a problem.
    • Sylvain Henry's avatar
      Refactor runtime interpreter code · 18757cab
      Sylvain Henry authored
      In #14335 we want to be able to use both the internal interpreter (for
      the plugins) and the external interpreter (for TH and GHCi) at the same
      This patch performs some preliminary refactoring: the `hsc_interp` field
      of HscEnv replaces `hsc_iserv` and is now used to indicate which
      interpreter (internal, external) to use to execute TH and GHCi.
      Opt_ExternalInterpreter flag and iserv options in DynFlags are now
      queried only when we set the session DynFlags. It should help making GHC
      multi-target in the future by selecting an interpreter according to the
      selected target.
    • Ömer Sinan Ağacan's avatar
      Document and refactor a few things around bitmap scavenging · b5fb58fd
      Ömer Sinan Ağacan authored
      - Added a few comments in StgPAP
      - Added a few comments and assertions in scavenge_small_bitmap and
      - Did tiny refactor in GHC.Data.Bitmap: added some comments, deleted
        dead code, used PlatformWordSize type.