1. 24 Jan, 2021 4 commits
    • Sebastian Graf's avatar
      CoreToStg.Prep: Speculative evaluation · b18d9e97
      Sebastian Graf authored
      From `Note [Speculative evaluation]`:
      Since call-by-value is much cheaper than call-by-need, we case-bind
      arguments that are either
        1. Strictly evaluated anyway, according to the StrictSig of the
           callee, or
        2. ok-for-spec, according to 'exprOkForSpeculation'
      While (1) is a no-brainer and always beneficial, (2) is a bit
      more subtle, as the careful haddock for 'exprOkForSpeculation'
      points out. Still, by case-binding the argument we don't need
      to allocate a thunk for it, whose closure must be retained as
      long as the callee might evaluate it. And if it is evaluated on
      most code paths anyway, we get to turn the unknown eval in the
      callee into a known call at the call site.
      NoFib Results:
              Program         Allocs    Instrs
                 ansi          -9.4%    -10.4%
             maillist          -0.1%     -0.1%
            paraffins          -0.7%     -0.5%
                  scc          -0.0%     +0.1%
             treejoin          -0.0%     -0.1%
                  Min          -9.4%    -10.4%
                  Max           0.0%     +0.1%
       Geometric Mean          -0.1%     -0.1%
      Fixes #19224.
    • John Ericson's avatar
      Track the dependencies of `GHC.Hs.Expr.Types` · 8ec6d62a
      John Ericson authored
      Thery is still, in my view, far too numerous, but I believe this won't
      be too hard to improve upon. At the very lease, we can always add more
      extension points!
    • John Ericson's avatar
      Separate AST from GhcPass (#18936) · 81f06655
      John Ericson authored
      There are two splits.
      The first spit is:
       - `Language.Haskell.Syntax.Extension`
       - `GHC.Hs.Extension`
      where the former now just contains helpers like `NoExtCon` and all the
      families, and the latter is everything having to do with `GhcPass`.
      The second split is:
       - `Language.Haskell.Syntax.<mod>`
       - `GHC.Hs.<mod>`
      Where the former contains all the data definitions, and the few helpers
      that don't use `GhcPass`, and the latter contains everything else. The
      second modules also reexport the former.
      See the issue for more details, but in short answer is we're trying to
      grasp at the modularity TTG is supposed to offer, after a long time of
      mainly just getting the safety benefits of more complete pattern
      matching on the AST.
      Now, we have an AST datatype which, without `GhcPass` is decently
      stripped of GHC-specific concerns. Whereas before, not was it
      GHC-specific, it was aware of all the GHC phases despite the
      parameterization, with the instances and parametric data structure
      For what it's worth there are also some smaller, imminent benefits:
      - The latter change also splits a strongly connected component in two,
        since none of the `Language.Haskell.Syntax.*` modules import the older
      - A few TTG violations (Using GhcPass directly in the AST) in `Expr` are
        now more explicitly accounted for with new type families to provide the
        necessary indirection.
      Future work:
      - I don't see why all the type families should live in
        `Language.Haskell.Syntax.Extension`. That seems anti-modular for
        little benefit. All the ones used just once can be moved next to the
        AST type they serve as an extension point for.
      - Decide what to do with the `Outputable` instances. Some of these are
        no orphans because they referred to `GhcPass`, and had to be moved. I
        think the types could be generalized so they don't refer to `GhcPass`
        and therefore can be moved back, but having gotten flak for increasing
        the size and complexity types when generalizing before, I did *not*
        want to do this.
      - We should triage the remaining contents of `GHC.Hs.<mod>`. The
        renaming helpers are somewhat odd for needing `GhcPass`. We might
        consider if they are a) in fact only needed by one phase b) can be
        generalized to be non-GhcPass-specific (e.g. take a callback rather
        than GADT-match with `IsPass`) and then they can live in
      For more details, see
      Bumps Haddock submodule
    • Cheng Shao's avatar
      Add _validatebuild to .gitignore · e6e1cf74
      Cheng Shao authored
      [ci skip]
  2. 23 Jan, 2021 6 commits
  3. 22 Jan, 2021 26 commits
    • Cheng Shao's avatar
      Remove legacy comment in validate script · 420ef55a
      Cheng Shao authored
      The validate flavour is already defined and used in hadrian, so this
      legacy comment should be removed.
    • Andreas Klebinger's avatar
      Make DmdAnalOpts a newtype · 7b6bb480
      Andreas Klebinger authored
    • Andreas Klebinger's avatar
    • Sylvain Henry's avatar
      Enhance nested TransCo pretty-printing · 13d876ba
      Sylvain Henry authored
      Nested TransCo were printed with a lot of indentation, e.g.:
          `cast` (Sub (Sym (Foo.D:R:Index[0] <Bool>_N <'[]>_N)) ; ((Index
                                                                      (Sym (SubDef (<1>_N,
                                                                      <'[Bool]>_N)_R ; ...
      With this patch we print them as follows:
          `cast` (Sub (Sym (Foo.D:R:Index[0] <Bool>_N <'[]>_N))
                  ; (Index (Sym (SubDef (<1>_N, <1>_N))) <'[Bool]>_N)_R
                  ; Sub (Sym (Foo.D:R:Index[1] <1>_N <Int>_N <'[Bool]>_N))
                  ; (Index (Sym (SubDef (<2>_N, <1>_N))) <'[Int, Bool]>_N)_R
    • Cheng Shao's avatar
      Optimize some rts_mk/rts_get functions in RtsAPI.c · 532337cb
      Cheng Shao authored
      - All rts_mk functions return the tagged closure address
      - rts_mkChar/rts_mkInt avoid allocation when the argument is within the
        CHARLIKE/INTLIKE range
      - rts_getBool avoids a memory load by checking the closure tag
      - In rts_mkInt64/rts_mkWord64, allocated closure payload size is either
        1 or 2 words depending on target architecture word size
    • Stefan Schulze Frielinghaus's avatar
      CmmToC: Fix translation of Cmm literals to word sized literals · 637ae302
      Stefan Schulze Frielinghaus authored
      For big-endian machines remove the byte swap in the non-recursive call
      of goSubWord since the integer is already in proper format.
    • Oleg Grenrus's avatar
      Change replicateM doctest example · 4bb9a349
      Oleg Grenrus authored
    • Ben Gamari's avatar
      gitlab-ci: Fix perf metric pushing · fcbf21aa
      Ben Gamari authored
      Previously we would inexplicably append the key to id_rsa.
      Fixes #19225.
    • Sylvain Henry's avatar
      LLVM: fix sized shift primops (#19215) · db16302c
      Sylvain Henry authored
      Ensure that shift amount parameter has the same type as the parameter to
    • Sylvain Henry's avatar
      Core: introduce Alt/AnnAlt/IfaceAlt datatypes · 957b5376
      Sylvain Henry authored
      Alt, AnnAlt and IfaceAlt were using triples. This patch makes them use
      dedicated types so that we can try to make some fields strict (for
      example) in the future.
    • Sylvain Henry's avatar
      Enhance Data instance generation · 887eb6ec
      Sylvain Henry authored
      Use `mkConstrTag` to explicitly pass the constructor tag instead of
      using `mkConstr` which queries the tag at runtime by querying the index
      of the constructor name (a string) in the list of constructor names.
      Perf improvement:
          T16577(normal) ghc/alloc 11325573876.0  9249786992.0 -18.3% GOOD
      Thanks to @sgraf812 for suggesting an additional list fusion fix during
      Metric Decrease:
    • John Ericson's avatar
      Test constant folding for sized types · 6fbfde95
      John Ericson authored
    • John Ericson's avatar
      Add missing fixed-sized primops and constant folding · 0eaf63b6
      John Ericson authored
      - `inversePrimOp` is renamed to `semiInversePrimOp` to indicate the
        given primop is only a right inverse, not left inverse (and
        contra-wise for the primop which we are giving rules for). This
        explains why are new usage is not incorrect.
      - The removed `subsumedByPrimOp` calls were actually dead as the match
        on ill-typed code. @hsyl20 pointed this out in
        !4390 (comment 311912),
      Metric Decrease:
    • John Ericson's avatar
      Cleanup primop constant folding rules in a few ways · faf164db
      John Ericson authored
       - `leftZero`, `rightZero` and `zeroElem` could all be written using `isZeroLit`
       - "modulo 1" rules could be written with `nonOneLit 1 $> Lit zero<type>`
      All are due to @hsyl20; thanks!
    • John Ericson's avatar
      C-- shift amount is always native size, not shiftee size · 22d01924
      John Ericson authored
      This isn't a bug yet, because we only shift native-sized types, but I
      hope to change that.
    • John Ericson's avatar
    • Alfredo Di Napoli's avatar
      Fix tests relying on same-line diagnostic ordering · c36a4f63
      Alfredo Di Napoli authored
      This commit fixes 19 tests which were failing due to the use of
      `consBag` / `snocBag`, which have been now replaced by `addMessage`.
      This means that now GHC would output things in different order but
      only for /diagnostics on the same line/, so this is just reflecting
      that. The "normal" order of messages is still guaranteed.
    • Alfredo Di Napoli's avatar
      Parameterise Messages over e · a64f21e9
      Alfredo Di Napoli authored
      This commit paves the way to a richer and more structured representation
      of GHC error messages, as per GHC proposal #306. More specifically
      'Messages' from 'GHC.Types.Error' now gains an extra type parameter,
      that we instantiate to 'ErrDoc' for now. Later, this will allow us to
      replace ErrDoc with something more structure (for example messages
      coming from the parser, the typechecker etc).
    • Simon Peyton Jones's avatar
      Fix error recovery in solveEqualities · 34950fb8
      Simon Peyton Jones authored
      As #19142 showed, with -fdefer-type-errors we were allowing
      compilation to proceed despite a fatal kind error. This patch
      fixes it, as described in the new note in GHC.Tc.Solver,
           Note [Wrapping failing kind equalities]
      Also fixes #19158
      Also when checking
         default( ty1, ty2, ... )
      only consider a possible default (C ty2) if ty2 is kind-compatible
      with C.  Previously we could form kind-incompatible constraints, with
      who knows what kind of chaos resulting.  (Actually, no chaos results,
      but that's only by accident.  It's plain wrong to form the constraint
      (Num Either) for example.)  I just happened to notice
      this during fixing #19142.
    • Matthew Pickering's avatar
      ghc-heap: Allow more control about decoding CCS fields · a255b4e3
      Matthew Pickering authored
      We have to be careful not to decode too much, too eagerly, as in
      ghc-debug this will lead to references to memory locations outside of
      the currently copied closure.
      Fixes #19038
    • Sylvain Henry's avatar
      Factorize and document binder collect functions · 29173f88
      Sylvain Henry authored
      Parameterize collect*Binders functions with a flag indicating if
      evidence binders should be collected.
      The related note in GHC.Hs.Utils has been updated.
      Bump haddock submodule
    • Sylvain Henry's avatar
      Arrows: collect evidence binders · 01ea56a2
      Sylvain Henry authored
      Evidence binders were not collected by
      GHC.HsToCore.Arrows.collectStmtBinders, hence bindings for dictionaries
      were not taken into account while computing local variables in
      statements. As a consequence we had a transformation similar to this:
          data Point a where Point :: RealFloat a => a -> Point a
              p -< ...
              returnA -< ... (Point 0)
      ===> { Type-checking }
              let $dRealFloat_xyz = GHC.Float.$fRealFloatFloat
              p -< ...
              returnA -< ... (Point $dRealFloat_xyz 0)
      ===> { Arrows HsToCore }
          first ...
          >>> arr (\(p, ()) -> case p of ... ->
                  let $dRealFloat_xyz = GHC.Float.$fRealFloatFloat
                  in case .. of () -> ())
          >>> \((),()) -> ... (Point $dRealFloat_xyz 0) -- dictionary not in scope
      Now evidences are passed in the environment if necessary and we get:
      ===> { Arrows HsToCore }
          first ...
          >>> arr (\(p, ()) -> case p of ... ->
                  let $dRealFloat_xyz = GHC.Float.$fRealFloatFloat
                  in case .. of () -> $dRealFloat_xyz)
          >>> \(ds,()) ->
                  let $dRealFloat_xyz = ds
                  in ... (Point $dRealFloat_xyz 0) -- dictionary in scope
      Note that collectStmtBinders has been copy-pasted from GHC.Hs.Utils.
      This ought to be factorized but Note [Dictionary binders in ConPatOut]
      claims that:
          Do *not* gather (a) dictionary and (b) dictionary bindings as
          binders of a ConPatOut pattern.  For most calls it doesn't matter,
          because it's pre-typechecker and there are no ConPatOuts.  But it
          does matter more in the desugarer; for example,
          GHC.HsToCore.Utils.mkSelectorBinds uses collectPatBinders.  In a
          lazy pattern, for example f ~(C x y) = ..., we want to generate
          bindings for x,y but not for dictionaries bound by C.  (The type
          checker ensures they would not be used.)
          Desugaring of arrow case expressions needs these bindings (see
          GHC.HsToCore.Arrows and arrowcase1), but SPJ (Jan 2007) says it's
          safer for it to use its own pat-binder-collector:
      Accordingly to the last sentence, this patch doesn't make any attempt at
      factorizing both codes.
      Fix #18950
    • Ben Gamari's avatar
      dataToTag#: Avoid unnecessary entry · b4b2be61
      Ben Gamari authored
      When the pointer is already tagged we can avoid entering the closure.
    • Ben Gamari's avatar
      Use pointer tag in dataToTag# · 2ed96c68
      Ben Gamari authored
      While looking at !2873 I noticed that dataToTag# previously didn't look
      at a pointer's tag to determine its constructor. To be fair, there is a
      bit of a trade-off here: using the pointer tag requires a bit more code
      and another branch. On the other hand, it allows us to eliminate looking
      at the info table in many cases (especially now since we tag large
      constructor families; see #14373).
    • Andreas Klebinger's avatar
      When deriving Eq always use tag based comparisons for nullary constructors · 092f0532
      Andreas Klebinger authored
      Instead of producing auxiliary con2tag bindings we now rely on
      dataToTag#, eliminating a fair bit of generated code.
      Co-Authored-By: Ben Gamari's avatarBen Gamari <ben@well-typed.com>
    • Sylvain Henry's avatar
      Fix wrong comment about UnitState · 1ff61314
      Sylvain Henry authored
      [CI skip]
  4. 19 Jan, 2021 1 commit
    • Cheng Shao's avatar
      Correct documentation in System.Mem.Weak · 6cfdca9f
      Cheng Shao authored
      [ci skip] Since #13167 is closed, exceptions thrown in finalizers are
      ignored and doesn't affect other finalizers in the same batch. This MR
      updates the documentation in System.Mem.Weak to reflect that.
  5. 18 Jan, 2021 3 commits