Skip to content
Snippets Groups Projects
  1. Aug 29, 2023
  2. Jul 23, 2023
    • Vladislav Zavialov's avatar
      Visible forall in types of terms: Part 1 (#22326) · 33b6850a
      Vladislav Zavialov authored and Marge Bot's avatar Marge Bot committed
      This patch implements part 1 of GHC Proposal #281,
      introducing explicit `type` patterns and `type` arguments.
      
      Summary of the changes:
      
      1. New extension flag:
           RequiredTypeArguments
      
      2. New user-facing syntax:
           `type p` patterns    (represented by EmbTyPat)
           `type e` expressions (represented by HsEmbTy)
      
      3. Functions with required type arguments (visible forall)
         can now be defined and applied:
            idv :: forall a -> a -> a    -- signature   (relevant change: checkVdqOK in GHC/Tc/Validity.hs)
            idv (type a) (x :: a) = x    -- definition  (relevant change: tcPats in GHC/Tc/Gen/Pat.hs)
            x = idv (type Int) 42        -- usage       (relevant change: tcInstFun in GHC/Tc/Gen/App.hs)
      
      4. template-haskell support:
            TH.TypeE corresponds to HsEmbTy
            TH.TypeP corresponds to EmbTyPat
      
      5. Test cases and a new User's Guide section
      
      Changes *not* included here are the t2t (term-to-type) transformation
      and term variable capture; those belong to part 2.
      33b6850a
  3. Jul 03, 2023
  4. Mar 21, 2023
    • Andrei Borzenkov's avatar
      Rename () into Unit, (,,...,,) into Tuple<n> (#21294) · a13affce
      Andrei Borzenkov authored and Marge Bot's avatar Marge Bot committed
      
      This patch implements a part of GHC Proposal #475.
      The key change is in GHC.Tuple.Prim:
      
        - data () = ()
        - data (a,b) = (a,b)
        - data (a,b,c) = (a,b,c)
        ...
        + data Unit = ()
        + data Tuple2 a b = (a,b)
        + data Tuple3 a b c = (a,b,c)
        ...
      
      And the rest of the patch makes sure that Unit and Tuple<n>
      are pretty-printed as () and (,,...,,) in various contexts.
      
      Updates the haddock submodule.
      
      Co-authored-by: default avatarVladislav Zavialov <vlad.z.4096@gmail.com>
      a13affce
  5. Nov 29, 2022
  6. Nov 12, 2022
  7. Nov 11, 2022
    • Krzysztof Gogolewski's avatar
      Use a more efficient printer for code generation (#21853) · 3c37d30b
      Krzysztof Gogolewski authored
      
      The changes in `GHC.Utils.Outputable` are the bulk of the patch
      and drive the rest.
      The types `HLine` and `HDoc` in Outputable can be used instead of `SDoc`
      and support printing directly to a handle with `bPutHDoc`.
      See Note [SDoc versus HDoc] and Note [HLine versus HDoc].
      
      The classes `IsLine` and `IsDoc` are used to make the existing code polymorphic
      over `HLine`/`HDoc` and `SDoc`. This is done for X86, PPC, AArch64, DWARF
      and dependencies (printing module names, labels etc.).
      
      Co-authored-by: default avatarAlexis King <lexi.lambda@gmail.com>
      
      Metric Decrease:
          CoOpt_Read
          ManyAlternatives
          ManyConstructors
          T10421
          T12425
          T12707
          T13035
          T13056
          T13253
          T13379
          T18140
          T18282
          T18698a
          T18698b
          T1969
          T20049
          T21839c
          T21839r
          T3064
          T3294
          T4801
          T5321FD
          T5321Fun
          T5631
          T6048
          T783
          T9198
          T9233
      3c37d30b
  8. Oct 19, 2022
  9. Jul 16, 2022
  10. Jul 13, 2022
  11. May 18, 2022
    • Sylvain Henry's avatar
      Don't store LlvmConfig into DynFlags · ef3c8d9e
      Sylvain Henry authored and Marge Bot's avatar Marge Bot committed
      LlvmConfig contains information read from llvm-passes and llvm-targets
      files in GHC's top directory. Reading these files is done only when
      needed (i.e. when the LLVM backend is used) and cached for the whole
      compiler session. This patch changes the way this is done:
      
      - Split LlvmConfig into LlvmConfig and LlvmConfigCache
      
      - Store LlvmConfigCache in HscEnv instead of DynFlags: there is no
        good reason to store it in DynFlags. As it is fixed per session, we
        store it in the session state instead (HscEnv).
      
      - Initializing LlvmConfigCache required some changes to driver functions
        such as newHscEnv. I've used the opportunity to untangle initHscEnv
        from initGhcMonad (in top-level GHC module) and to move it to
        GHC.Driver.Main, close to newHscEnv.
      
      - I've also made `cmmPipeline` independent of HscEnv in order to remove
        the call to newHscEnv in regalloc_unit_tests.
      ef3c8d9e
  12. Apr 07, 2022
    • Vladislav Zavialov's avatar
      Rename [] to List (#21294) · 02279a9c
      Vladislav Zavialov authored and Marge Bot's avatar Marge Bot committed
      This patch implements a small part of GHC Proposal #475.
      The key change is in GHC.Types:
      
      	- data [] a = [] | a : [a]
      	+ data List a = [] | a : List a
      
      And the rest of the patch makes sure that List is pretty-printed as []
      in various contexts.
      
      Updates the haddock submodule.
      02279a9c
  13. Mar 26, 2021
    • Sylvain Henry's avatar
      Remove UniqSupply from NameCache · 532c6a54
      Sylvain Henry authored and Marge Bot's avatar Marge Bot committed
      As suggested by @alexbiehl, this patch replaces the always updated
      UniqSupply in NameCache with a fixed Char and use it with `uniqFromMask`
      to generate uniques.
      
      This required some refactoring because getting a new unique from the
      NameCache can't be done in pure code anymore, in particular not in an
      atomic update function for `atomicModifyIORef`. So we use an MVar
      instead to store the OrigNameCache field.
      
      For some reason, T12545 increases (+1%) on i386 while it decreases on
      other CI runners.
      
      T9630 ghc/peak increases only with the dwarf build on CI (+16%).
      
      Metric Decrease:
          T12425
          T12545
          T9198
          T12234
      
      Metric Increase:
          T12545
          T9630
      
      Update haddock submodule
      532c6a54
    • Sylvain Henry's avatar
      Refactor NameCache · 872a9444
      Sylvain Henry authored and Marge Bot's avatar Marge Bot committed
      * Make NameCache the mutable one and replace NameCacheUpdater with it
      
      * Remove NameCache related code duplicated into haddock
      
      Bump haddock submodule
      872a9444
  14. Mar 10, 2021
  15. Feb 06, 2021
  16. Dec 24, 2020
  17. Dec 14, 2020
  18. Oct 25, 2020
  19. Aug 21, 2020
    • Sylvain Henry's avatar
      NCG: Dwarf configuration · 659eb31b
      Sylvain Henry authored and Marge Bot's avatar Marge Bot committed
      * remove references to DynFlags in GHC.CmmToAsm.Dwarf
      * add specific Dwarf options in NCGConfig instead of directly querying
        the debug level
      659eb31b
  20. Aug 12, 2020
    • Sylvain Henry's avatar
      DynFlags: disentangle Outputable · accbc242
      Sylvain Henry authored and Marge Bot's avatar Marge Bot committed
      - put panic related functions into GHC.Utils.Panic
      - put trace related functions using DynFlags in GHC.Driver.Ppr
      
      One step closer making Outputable fully independent of DynFlags.
      
      Bump haddock submodule
      accbc242
  21. Jun 05, 2020
    • Simon Peyton Jones's avatar
      Simple subsumption · 2b792fac
      Simon Peyton Jones authored
      This patch simplifies GHC to use simple subsumption.
        Ticket #17775
      
      Implements GHC proposal #287
         https://github.com/ghc-proposals/ghc-proposals/blob/master/
         proposals/0287-simplify-subsumption.rst
      
      All the motivation is described there; I will not repeat it here.
      The implementation payload:
       * tcSubType and friends become noticably simpler, because it no
         longer uses eta-expansion when checking subsumption.
       * No deeplyInstantiate or deeplySkolemise
      
      That in turn means that some tests fail, by design; they can all
      be fixed by eta expansion.  There is a list of such changes below.
      
      Implementing the patch led me into a variety of sticky corners, so
      the patch includes several othe changes, some quite significant:
      
      * I made String wired-in, so that
          "foo" :: String   rather than
          "foo" :: [Char]
        This improves error messages, and fixes #15679
      
      * The pattern match checker relies on knowing about in-scope equality
        constraints, andd adds them to the desugarer's environment using
        addTyCsDs.  But the co_fn in a FunBind was missed, and for some reason
        simple-subsumption ends up with dictionaries there. So I added a
        call to addTyCsDs.  This is really part of #18049.
      
      * I moved the ic_telescope field out of Implication and into
        ForAllSkol instead.  This is a nice win; just expresses the code
        much better.
      
      * There was a bug in GHC.Tc.TyCl.Instance.tcDataFamInstHeader.
        We called checkDataKindSig inside tc_kind_sig, /before/
        solveEqualities and zonking.  Obviously wrong, easily fixed.
      
      * solveLocalEqualitiesX: there was a whole mess in here, around
        failing fast enough.  I discovered a bad latent bug where we
        could successfully kind-check a type signature, and use it,
        but have unsolved constraints that could fill in coercion
        holes in that signature --  aargh.
      
        It's all explained in Note [Failure in local type signatures]
        in GHC.Tc.Solver. Much better now.
      
      * I fixed a serious bug in anonymous type holes. IN
          f :: Int -> (forall a. a -> _) -> Int
        that "_" should be a unification variable at the /outer/
        level; it cannot be instantiated to 'a'.  This was plain
        wrong.  New fields mode_lvl and mode_holes in TcTyMode,
        and auxiliary data type GHC.Tc.Gen.HsType.HoleMode.
      
        This fixes #16292, but makes no progress towards the more
        ambitious #16082
      
      * I got sucked into an enormous refactoring of the reporting of
        equality errors in GHC.Tc.Errors, especially in
            mkEqErr1
            mkTyVarEqErr
            misMatchMsg
            misMatchMsgOrCND
        In particular, the very tricky mkExpectedActualMsg function
        is gone.
      
        It took me a full day.  But the result is far easier to understand.
        (Still not easy!)  This led to various minor improvements in error
        output, and an enormous number of test-case error wibbles.
      
        One particular point: for occurs-check errors I now just say
           Can't match 'a' against '[a]'
        rather than using the intimidating language of "occurs check".
      
      * Pretty-printing AbsBinds
      
      Tests review
      
      * Eta expansions
         T11305: one eta expansion
         T12082: one eta expansion (undefined)
         T13585a: one eta expansion
         T3102:  one eta expansion
         T3692:  two eta expansions (tricky)
         T2239:  two eta expansions
         T16473: one eta
         determ004: two eta expansions (undefined)
         annfail06: two eta (undefined)
         T17923: four eta expansions (a strange program indeed!)
         tcrun035: one eta expansion
      
      * Ambiguity check at higher rank.  Now that we have simple
        subsumption, a type like
           f :: (forall a. Eq a => Int) -> Int
        is no longer ambiguous, because we could write
           g :: (forall a. Eq a => Int) -> Int
           g = f
        and it'd typecheck just fine.  But f's type is a bit
        suspicious, and we might want to consider making the
        ambiguity check do a check on each sub-term.  Meanwhile,
        these tests are accepted, whereas they were previously
        rejected as ambiguous:
           T7220a
           T15438
           T10503
           T9222
      
      * Some more interesting error message wibbles
         T13381: Fine: one error (Int ~ Exp Int)
                 rather than two (Int ~ Exp Int, Exp Int ~ Int)
         T9834:  Small change in error (improvement)
         T10619: Improved
         T2414:  Small change, due to order of unification, fine
         T2534:  A very simple case in which a change of unification order
                 means we get tow unsolved constraints instead of one
         tc211: bizarre impredicative tests; just accept this for now
      
      Updates Cabal and haddock submodules.
      
      Metric Increase:
        T12150
        T12234
        T5837
        haddock.base
      Metric Decrease:
        haddock.compiler
        haddock.Cabal
        haddock.base
      
      Merge note: This appears to break the
      `UnliftedNewtypesDifficultUnification` test. It has been marked as
      broken in the interest of merging.
      
      (cherry picked from commit 66b7b195)
      2b792fac
  22. May 26, 2020
    • Zubin's avatar
      Add info about typeclass evidence to .hie files · 53814a64
      Zubin authored and Marge Bot's avatar Marge Bot committed
      See `testsuite/tests/hiefile/should_run/HieQueries.hs` and
      `testsuite/tests/hiefile/should_run/HieQueries.stdout` for an example of this
      
      We add two new fields, `EvidenceVarBind` and `EvidenceVarUse` to the
      `ContextInfo` associated with an Identifier. These are associated with the
      appropriate identifiers for the evidence variables collected when we come across
      `HsWrappers`, `TcEvBinds` and `IPBinds` while traversing the AST.
      
      Instance dictionary and superclass selector dictionaries from `tcg_insts` and
      classes defined in `tcg_tcs` are also recorded in the AST as originating from
      their definition span
      
      This allows us to save a complete picture of the evidence constructed by the
      constraint solver, and will let us report this to the user, enabling features
      like going to the instance definition from the invocation of a class method(or
      any other method taking a constraint) and finding all usages of a particular
      instance.
      
      Additionally,
      
      - Mark NodeInfo with an origin so we can differentiate between bindings
        origininating in the source vs those in ghc
      - Along with typeclass evidence info, also include information on Implicit
        Parameters
      - Add a few utility functions to HieUtils in order to query the new info
      
      Updates haddock submodule
      53814a64
  23. May 14, 2020
    • Ryan Scott's avatar
      Factor out HsPatSigType for pat sigs/RULE term sigs (#16762) · 102cfd67
      Ryan Scott authored and Marge Bot's avatar Marge Bot committed
      This implements chunks (2) and (3) of
      ghc/ghc#16762 (comment 270170). Namely,
      it introduces a dedicated `HsPatSigType` AST type, which represents
      the types that can appear in pattern signatures and term-level `RULE`
      binders. Previously, these were represented with `LHsSigWcType`.
      Although `LHsSigWcType` is isomorphic to `HsPatSigType`, the intended
      semantics of the two types are slightly different, as evidenced by
      the fact that they have different code paths in the renamer and
      typechecker.
      
      See also the new `Note [Pattern signature binders and scoping]` in
      `GHC.Hs.Types`.
      102cfd67
  24. May 06, 2020
    • Zubin's avatar
      Allow atomic update of NameCache in readHieFile · 9f3e6884
      Zubin authored and Marge Bot's avatar Marge Bot committed
      The situation arises in ghcide where multiple different threads may need to
      update the name cache, therefore with the older interface it could happen
      that you start reading a hie file with name cache A and produce name cache
      A + B, but another thread in the meantime updated the namecache to A +
      C. Therefore if you write the new namecache you will lose the A' updates
      from the second thread.
      
      Updates haddock submodule
      9f3e6884
  25. Apr 18, 2020
    • Sylvain Henry's avatar
      Modules (#13009) · 15312bbb
      Sylvain Henry authored
      * SysTools
      * Parser
      * GHC.Builtin
      * GHC.Iface.Recomp
      * Settings
      
      Update Haddock submodule
      
      Metric Decrease:
          Naperian
          parsing001
      15312bbb
  26. Apr 10, 2020
    • Ömer Sinan Ağacan's avatar
      testsuite: Move no_lint to the top level, tweak hie002 · 723062ed
      Ömer Sinan Ağacan authored
      - We don't want to benchmark linting so disable lints in hie002 perf
        test
      
      - Move no_lint to the top-level to be able to use it in tests other than
        those in `testsuite/tests/perf/compiler`.
      
      - Filter out -dstg-lint in no_lint.
      
      - hie002 allocation numbers on 32-bit are unstable, so skip it on 32-bit
      
      Metric Decrease:
          hie002
          ManyConstructors
          T12150
          T12234
          T13035
          T1969
          T4801
          T9233
          T9961
      723062ed
  27. Mar 29, 2020
  28. Feb 22, 2020
  29. Jan 06, 2020
  30. Oct 07, 2019
    • Ben Gamari's avatar
      Refactor, document, and optimize LLVM configuration loading · b2577081
      Ben Gamari authored and Marge Bot's avatar Marge Bot committed
      As described in the new Note [LLVM Configuration] in SysTools, we now
      load llvm-targets and llvm-passes lazily to avoid the overhead of doing
      so when -fllvm isn't used (also known as "the common case").
      
      Noticed in #17003.
      
      Metric Decrease:
          T12234
          T12150
      b2577081
  31. Aug 07, 2019
  32. Feb 27, 2019
    • Vladislav Zavialov's avatar
      Fix intermittent hie002 failure · 2e8f6649
      Vladislav Zavialov authored and Marge Bot's avatar Marge Bot committed
      hie002 is a performance test that used to fail unpredictably:
      
      	max_bytes_used Decrease from x86_64-linux-deb9-debug baseline @ HEAD~2:
      	    Expected    hie002 (normal) max_bytes_used: 1190923992.0 +/-20%
      	    Lower bound hie002 (normal) max_bytes_used:    952739193
      	    Upper bound hie002 (normal) max_bytes_used:   1429108791
      	    Actual      hie002 (normal) max_bytes_used:    726270784
      	    Deviation   hie002 (normal) max_bytes_used:        -39.0 %
      	peak_megabytes_allocated Decrease from x86_64-linux-deb9-debug baseline @ HEAD~2:
      	    Expected    hie002 (normal) peak_megabytes_allocated: 2538.0 +/-20%
      	    Lower bound hie002 (normal) peak_megabytes_allocated:   2030
      	    Upper bound hie002 (normal) peak_megabytes_allocated:   3046
      	    Actual      hie002 (normal) peak_megabytes_allocated:   1587
      	    Deviation   hie002 (normal) peak_megabytes_allocated:  -37.5 %
      	*** unexpected stat test failure for hie002(normal)
      
      'max_bytes_used' and 'peak_megabytes_allocated' are too unstable without careful
      control of the runtime configuration. We fix this by using a more predictable
      metric, 'bytes allocated'.
      2e8f6649
  33. Dec 11, 2018
Loading