1. 26 Mar, 2020 1 commit
    • 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:
          T13035
          T1969
      0de03cd7
  2. 18 Mar, 2020 1 commit
  3. 17 Mar, 2020 1 commit
  4. 27 Feb, 2020 1 commit
    • Sebastian Graf's avatar
      PmCheck: Implement Long-distance information with Covered sets · 74311e10
      Sebastian Graf authored
      Consider
      
      ```hs
      data T = A | B | C
      
      f :: T -> Int
      f A = 1
      f x = case x of
        A -> 2
        B -> 3
        C -> 4
      ```
      
      Clearly, the RHS returning 2 is redundant. But we don't currently see
      that, because our approximation to the covered set of the inner case
      expression just picks up the positive information from surrounding
      pattern matches. It lacks the context sensivity that `x` can't be `A`
      anymore!
      
      Therefore, we adopt the conceptually and practically superior approach
      of reusing the covered set of a particular GRHS from an outer pattern
      match. In this case, we begin checking the `case` expression with the
      covered set of `f`s second clause, which encodes the information that
      `x` can't be `A` anymore. After this MR, we will successfully warn about
      the RHS returning 2 being redundant.
      
      Perhaps surprisingly, this was a great simplification to the code of
      both the coverage checker and the desugarer.
      
      Found a redundant case alternative in `unix` submodule, so we have to
      bump it with a fix.
      
      Metric Decrease:
          T12227
      74311e10
  5. 26 Feb, 2020 1 commit
  6. 22 Feb, 2020 1 commit
  7. 14 Feb, 2020 1 commit
  8. 08 Feb, 2020 1 commit
    • Richard Eisenberg's avatar
      Introduce IsPass; refactor wrappers. · 7755ffc2
      Richard Eisenberg authored
      There are two main payloads of this patch:
      
      1. This introduces IsPass, which allows e.g. printing
         code to ask what pass it is running in (Renamed vs
         Typechecked) and thus print extension fields. See
         Note [IsPass] in Hs.Extension
      
      2. This moves the HsWrap constructor into an extension
         field, where it rightly belongs. This is done for
         HsExpr and HsCmd, but not for HsPat, which is left
         as an exercise for the reader.
      
      There is also some refactoring around SyntaxExprs, but this
      is really just incidental.
      
      This patch subsumes !1721 (sorry @chreekat).
      
      Along the way, there is a bit of refactoring in GHC.Hs.Extension,
      including the removal of NameOrRdrName in favor of NoGhcTc.
      This meant that we had no real need for GHC.Hs.PlaceHolder, so
      I got rid of it.
      
      Updates haddock submodule.
      
      -------------------------
      Metric Decrease:
          haddock.compiler
      -------------------------
      7755ffc2
  9. 27 Jan, 2020 1 commit
  10. 13 Jan, 2020 1 commit
  11. 07 Jan, 2020 1 commit
  12. 30 Nov, 2019 1 commit
  13. 01 Oct, 2019 1 commit
  14. 20 Sep, 2019 1 commit
  15. 16 Sep, 2019 1 commit
    • Sebastian Graf's avatar
      Encode shape information in `PmOracle` · 7915afc6
      Sebastian Graf authored
      Previously, we had an elaborate mechanism for selecting the warnings to
      generate in the presence of different `COMPLETE` matching groups that,
      albeit finely-tuned, produced wrong results from an end user's
      perspective in some cases (#13363).
      
      The underlying issue is that at the point where the `ConVar` case has to
      commit to a particular `COMPLETE` group, there's not enough information
      to do so and the status quo was to just enumerate all possible complete
      sets nondeterministically.  The `getResult` function would then pick the
      outcome according to metrics defined in accordance to the user's guide.
      But crucially, it lacked knowledge about the order in which affected
      clauses appear, leading to the surprising behavior in #13363.
      
      In !1010 we taught the term oracle to reason about literal values a
      variable can certainly not take on. This MR extends that idea to
      `ConLike`s and thereby fixes #13363: Instead of committing to a
      particular `COMPLETE` group in the `ConVar` case, we now split off the
      matching constructor incrementally and record the newly covered case as
      a refutable shape in the oracle. Whenever the set of refutable shapes
      covers any `COMPLETE` set, the oracle recognises vacuosity of the
      uncovered set.
      
      This patch goes a step further: Since at this point the information
      in value abstractions is merely a cut down representation of what the
      oracle knows, value abstractions degenerate to a single `Id`, the
      semantics of which is determined by the oracle state `Delta`.
      Value vectors become lists of `[Id]` given meaning to by a single
      `Delta`, value set abstractions (of which the uncovered set is an
      instance) correspond to a union of `Delta`s which instantiate the
      same `[Id]` (akin to models of formula).
      
      Fixes #11528 #13021, #13363, #13965, #14059, #14253, #14851, #15753, #17096, #17149
      
      -------------------------
      Metric Decrease:
          ManyAlternatives
          T11195
      -------------------------
      7915afc6
  16. 09 Jul, 2019 1 commit
    • Ryan Scott's avatar
      Use an empty data type in TTG extension constructors (#15247) · 6a03d77b
      Ryan Scott authored
      To avoid having to `panic` any time a TTG extension constructor is
      consumed, this MR introduces an uninhabited 'NoExtCon' type and uses
      that in every extension constructor's type family instance where it
      is appropriate. This also introduces a 'noExtCon' function which
      eliminates a 'NoExtCon', much like 'Data.Void.absurd' eliminates
      a 'Void'.
      
      I also renamed the existing `NoExt` type to `NoExtField` to better
      distinguish it from `NoExtCon`. Unsurprisingly, there is a lot of
      code churn resulting from this.
      
      Bumps the Haddock submodule. Fixes #15247.
      6a03d77b
  17. 15 Mar, 2019 1 commit
  18. 03 Dec, 2018 1 commit
    • Alec Theriault's avatar
      Warn on all out-of-range literals in pats/exprs · 75a8349b
      Alec Theriault authored
      Summary:
      These changes were motivated by #13256. While poking around, I
      realized we weren't very consistent in our "-Woverflowed-literals"
      warnings. This patch fixes that by:
      
        * warning earlier on in the pipeline (ie. before we've desugared
          'Int' patterns into 'I# Int#')
        * handling 'HsLit' as well as 'HsOverLit' (this covers unboxed
          literals)
        * covering more pattern / expression forms
      
      4/6 of the warnings in the 'Overflow' test are due to this patch. The
      other two are mostly for completeness.
      
      Also fixed a missing empty-enumeration warning for 'Natural'.
      
      This warnings were tripped up by the 'Bounded Word' instance (see #9505),
      but the fix was obvious and simple: use unboxed word literals.
      
      Test Plan: make TEST=Overflow && make TEST=T10930
      
      Reviewers: hvr, bgamari, RyanGlScott
      
      Reviewed By: RyanGlScott
      
      Subscribers: RyanGlScott, rwbarton, carter
      
      GHC Trac Issues: #13256, #10930
      
      Differential Revision: https://phabricator.haskell.org/D5181
      75a8349b
  19. 24 Nov, 2018 1 commit
  20. 22 Nov, 2018 1 commit
    • Sylvain Henry's avatar
      Rename literal constructors · 13bb4bf4
      Sylvain Henry authored
      In a previous patch we replaced some built-in literal constructors
      (MachInt, MachWord, etc.) with a single LitNumber constructor.
      
      In this patch we replace the `Mach` prefix of the remaining constructors
      with `Lit` for consistency (e.g., LitChar, LitLabel, etc.).
      
      Sadly the name `LitString` was already taken for a kind of FastString
      and it would become misleading to have both `LitStr` (literal
      constructor renamed after `MachStr`) and `LitString` (FastString
      variant). Hence this patch renames the FastString variant `PtrString`
      (which is more accurate) and the literal string constructor now uses the
      least surprising `LitString` name.
      
      Both `Literal` and `LitString/PtrString` have recently seen breaking
      changes so doing this kind of renaming now shouldn't harm much.
      
      Reviewers: hvr, goldfire, bgamari, simonmar, jrtc27, tdammers
      
      Subscribers: tdammers, rwbarton, thomie, carter
      
      Differential Revision: https://phabricator.haskell.org/D4881
      13bb4bf4
  21. 27 Oct, 2018 1 commit
    • mayac's avatar
      More explicit foralls (GHC Proposal 0007) · 512eeb9b
      mayac authored
      Allow the user to explicitly bind type/kind variables in type and data
      family instances (including associated instances), closed type family
      equations, and RULES pragmas. Follows the specification of GHC
      Proposal 0007, also fixes #2600. Advised by Richard Eisenberg.
      
      This modifies the Template Haskell AST -- old code may break!
      
      Other Changes:
      - convert HsRule to a record
      - make rnHsSigWcType more general
      - add repMaybe to DsMeta
      
      Includes submodule update for Haddock.
      
      Test Plan: validate
      
      Reviewers: goldfire, bgamari, alanz
      
      Subscribers: simonpj, RyanGlScott, goldfire, rwbarton,
                   thomie, mpickering, carter
      
      GHC Trac Issues: #2600, #14268
      
      Differential Revision: https://phabricator.haskell.org/D4894
      512eeb9b
  22. 21 Aug, 2018 1 commit
    • Andreas Klebinger's avatar
      Replace most occurences of foldl with foldl'. · 09c1d5af
      Andreas Klebinger authored
      This patch adds foldl' to GhcPrelude and changes must occurences
      of foldl to foldl'. This leads to better performance especially
      for quick builds where GHC does not perform strictness analysis.
      
      It does change strictness behaviour when we use foldl' to turn
      a argument list into function applications. But this is only a
      drawback if code looks ONLY at the last argument but not at the first.
      And as the benchmarks show leads to fewer allocations in practice
      at O2.
      
      Compiler performance for Nofib:
      
      O2 Allocations:
              -1 s.d.                -----            -0.0%
              +1 s.d.                -----            -0.0%
              Average                -----            -0.0%
      
      O2 Compile Time:
              -1 s.d.                -----            -2.8%
              +1 s.d.                -----            +1.3%
              Average                -----            -0.8%
      
      O0 Allocations:
              -1 s.d.                -----            -0.2%
              +1 s.d.                -----            -0.1%
              Average                -----            -0.2%
      
      Test Plan: ci
      
      Reviewers: goldfire, bgamari, simonmar, tdammers, monoidal
      
      Reviewed By: bgamari, monoidal
      
      Subscribers: tdammers, rwbarton, thomie, carter
      
      Differential Revision: https://phabricator.haskell.org/D4929
      09c1d5af
  23. 27 Jul, 2018 1 commit
    • 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
  24. 03 Jun, 2018 1 commit
    • Tao He's avatar
      Improve exhaustiveness checking for literal values and patterns, fix #14546 · 1f88f541
      Tao He authored
      Currently, we parse both the **integral literal** value and the patterns
      as `OverLit HsIntegral`.  For example:
      
      ```
        case 0::Int of
            0 -> putStrLn "A"
            1 -> putStrLn "B"
            _ -> putStrLn "C"
      ```
      
      When checking the exhaustiveness of pattern matching, we translate the
      `0` in value position as `PmOLit`, but translate the `0` and `1` in
      pattern position as `PmSLit`. The inconsistency leads to the failure of
      `eqPmLit` to detect the equality and report warning of "Pattern match is
      redundant" on pattern `0`, as reported in #14546. In this patch we
      remove the specialization of `OverLit` patterns, and keep the overloaded
      number literal in pattern as it is to maintain the consistency.  Now we
      can capture the exhaustiveness of pattern `0` and the redundancy of
      pattern `1` and `_`.
      
      For **string literals**, we parse the string literals as `HsString`.
      When  `OverloadedStrings` is enabled, it further be turned as `HsOverLit
      HsIsString`, whether it's type is `String` or not. For example:
      
      ```
        case "foo" of
            "foo" -> putStrLn "A"
            "bar" -> putStrLn "B"
            "baz" -> putStrLn "C"
      ```
      
      Previously, the overloaded string values are translated to `PmOLit` and
      the non-overloaded string values are translated to `PmSLit`. However the
      string patterns, both overloaded and non-overloaded, are translated to
      list of characters. The inconsistency leads to wrong warnings about
      redundant and non-exhaustive pattern matching warnings, as reported
      in #14546.
      
      In order to catch the redundant pattern in following case:
      
      ```
        case "foo" of
            ('f':_) -> putStrLn "A"
            "bar" -> putStrLn "B"
      ```
      
      In this patch, we translate non-overloaded string literals, both in
      value position and pattern position, as list of characters. For
      overloaded string literals, we only translate it to list of characters
      only when it's type is `stringTy`, since we know nothing about the
      `toString` methods.  But we know that if two overloaded strings are
      syntax equal, then they are equal. Then if it's type is not `stringTy`,
      we just translate it to `PmOLit`. We can still capture the
      exhaustiveness of pattern `"foo"` and the redundancy of pattern `"bar"`
      and `"baz"` in the following code:
      
      ```
      {-# LANGUAGE OverloadedStrings #-}
      main = do
        case "foo" of
            "foo" -> putStrLn "A"
            "bar" -> putStrLn "B"
            "baz" -> putStrLn "C"
      ```
      
      Test Plan: make test TEST="T14546"
      
      Reviewers: bgamari, simonpj
      
      Reviewed By: bgamari, simonpj
      
      Subscribers: simonpj, thomie, carter
      
      GHC Trac Issues: #14546
      
      Differential Revision: https://phabricator.haskell.org/D4571
      1f88f541
  25. 02 Jun, 2018 1 commit
    • Ben Gamari's avatar
      vectorise: Put it out of its misery · faee23bb
      Ben Gamari authored
      Poor DPH and its vectoriser have long been languishing; sadly it seems there is
      little chance that the effort will be rekindled. Every few years we discuss
      what to do with this mass of code and at least once we have agreed that it
      should be archived on a branch and removed from `master`. Here we do just that,
      eliminating heaps of dead code in the process.
      
      Here we drop the ParallelArrays extension, the vectoriser, and the `vector` and
      `primitive` submodules.
      
      Test Plan: Validate
      
      Reviewers: simonpj, simonmar, hvr, goldfire, alanz
      
      Reviewed By: simonmar
      
      Subscribers: goldfire, rwbarton, thomie, mpickering, carter
      
      Differential Revision: https://phabricator.haskell.org/D4761
      faee23bb
  26. 21 May, 2018 1 commit
    • Simon Peyton Jones's avatar
      Remove TcType.toTcType · b7e80ae0
      Simon Peyton Jones authored
      In the olden days we insisted that only TcTyVars could appear
      in a TcType.  But now we are more accommodating; see TcType
        Note [TcTyVars and TyVars in the typechecker]
      
      This patch removes a function that converted a Type to a TcType.
      It didn't do anything useful except statisfy an invariant that
      we no longer have.  Now it's gone.
      b7e80ae0
  27. 27 Apr, 2018 1 commit
    • Alan Zimmerman's avatar
      TTG : complete for balance of hsSyn AST · c3823cba
      Alan Zimmerman authored
      Summary:
      - remove PostRn/PostTc fields
      - remove the HsVect In/Out distinction for Type, Class and Instance
      - remove PlaceHolder in favour of NoExt
      - Simplify OutputableX constraint
      
      Updates haddock submodule
      
      Test Plan: ./validate
      
      Reviewers: goldfire, bgamari
      
      Subscribers: goldfire, thomie, mpickering, carter
      
      Differential Revision: https://phabricator.haskell.org/D4625
      c3823cba
  28. 09 Apr, 2018 1 commit
  29. 26 Jan, 2018 1 commit
    • Joachim Breitner's avatar
      Turn EvTerm (almost) into CoreExpr (#14691) · 0e022e56
      Joachim Breitner authored
      Ideally, I'd like to do
      
          type EvTerm = CoreExpr
      
      and the type checker builds the evidence terms as it goes. This failed,
      becuase the evidence for `Typeable` refers to local identifiers that are
      added *after* the typechecker solves constraints. Therefore, `EvTerm`
      stays a data type with two constructors: `EvExpr` for `CoreExpr`
      evidence, and `EvTypeable` for the others.
      
      Delted `Note [Memoising typeOf]`, its reference (and presumably
      relevance) was removed in 8fa4bf9a.
      
      Differential Revision: https://phabricator.haskell.org/D4341
      0e022e56
  30. 21 Nov, 2017 1 commit
    • Ben Gamari's avatar
      Revert "trees that grow" work · 314bc314
      Ben Gamari authored
      As documented in #14490, the Data instances currently blow up
      compilation time by too much to stomach. Alan will continue working on
      this in a branch and we will perhaps merge to 8.2 before 8.2.1 to avoid
      having to perform painful cherry-picks in 8.2 minor releases.
      
      Reverts haddock submodule.
      
      This reverts commit 47ad6578.
      This reverts commit e3ec2e7a.
      This reverts commit 438dd1cb.
      This reverts commit 0ff152c9.
      314bc314
  31. 14 Nov, 2017 1 commit
  32. 11 Nov, 2017 1 commit
  33. 08 Nov, 2017 1 commit
  34. 07 Nov, 2017 2 commits
  35. 03 Nov, 2017 1 commit
  36. 19 Sep, 2017 1 commit
    • Herbert Valerio Riedel's avatar
      compiler: introduce custom "GhcPrelude" Prelude · f63bc730
      Herbert Valerio Riedel authored
      This switches the compiler/ component to get compiled with
      -XNoImplicitPrelude and a `import GhcPrelude` is inserted in all
      modules.
      
      This is motivated by the upcoming "Prelude" re-export of
      `Semigroup((<>))` which would cause lots of name clashes in every
      modulewhich imports also `Outputable`
      
      Reviewers: austin, goldfire, bgamari, alanz, simonmar
      
      Reviewed By: bgamari
      
      Subscribers: goldfire, rwbarton, thomie, mpickering, bgamari
      
      Differential Revision: https://phabricator.haskell.org/D3989
      f63bc730
  37. 31 Jul, 2017 1 commit
  38. 27 Jun, 2017 1 commit
    • Ben Gamari's avatar
      Treat banged bindings as FunBinds · 6567c815
      Ben Gamari authored
      This is another attempt at resolving #13594 by treating strict variable
      binds as FunBinds instead of PatBinds (as suggested in comment:1).
      
      Test Plan: Validate
      
      Reviewers: austin, alanz
      
      Subscribers: rwbarton, thomie, mpickering
      
      GHC Trac Issues: #13594
      
      Differential Revision: https://phabricator.haskell.org/D3670
      6567c815
  39. 05 Jun, 2017 1 commit
    • Alan Zimmerman's avatar
      Udate hsSyn AST to use Trees that Grow · 8e6ec0fa
      Alan Zimmerman authored
      Summary:
      See https://ghc.haskell.org/trac/ghc/wiki/ImplementingTreesThatGrow
      
      This commit prepares the ground for a full extensible AST, by replacing the type
      parameter for the hsSyn data types with a set of indices into type families,
      
          data GhcPs -- ^ Index for GHC parser output
          data GhcRn -- ^ Index for GHC renamer output
          data GhcTc -- ^ Index for GHC typechecker output
      
      These are now used instead of `RdrName`, `Name` and `Id`/`TcId`/`Var`
      
      Where the original name type is required in a polymorphic context, this is
      accessible via the IdP type family, defined as
      
          type family IdP p
          type instance IdP GhcPs = RdrName
          type instance IdP GhcRn = Name
          type instance IdP GhcTc = Id
      
      These types are declared in the new 'hsSyn/HsExtension.hs' module.
      
      To gain a better understanding of the extension mechanism, it has been applied
      to `HsLit` only, also replacing the `SourceText` fields in them with extension
      types.
      
      To preserve extension generality, a type class is introduced to capture the
      `SourceText` interface, which must be honoured by all of the extension points
      which originally had a `SourceText`.  The class is defined as
      
          class HasSourceText a where
            -- Provide setters to mimic existing constructors
            noSourceText  :: a
            sourceText    :: String -> a
      
            setSourceText :: SourceText -> a
            getSourceText :: a -> SourceText
      
      And the constraint is captured in `SourceTextX`, which is a constraint type
      listing all the extension points that make use of the class.
      
      Updating Haddock submodule to match.
      
      Test Plan: ./validate
      
      Reviewers: simonpj, shayan-najd, goldfire, austin, bgamari
      
      Subscribers: rwbarton, thomie, mpickering
      
      Differential Revision: https://phabricator.haskell.org/D3609
      8e6ec0fa