Skip to content
Snippets Groups Projects
  1. Feb 05, 2024
    • Simon Peyton Jones's avatar
      Stop dropping a case whose binder is demanded · cfd68290
      Simon Peyton Jones authored and Marge Bot's avatar Marge Bot committed
      This MR fixes #24251.
      
      See Note [Case-to-let for strictly-used binders]
      in GHC.Core.Opt.Simplify.Iteration, plus #24251, for
      lots of discussion.
      
      Final Nofib changes over 0.1%:
      +-----------------------------------------
      |        imaginary/digits-of-e2    -2.16%
      |                imaginary/rfib    -0.15%
      |                    real/fluid    -0.10%
      |                   real/gamteb    -1.47%
      |                       real/gg    -0.20%
      |                 real/maillist    +0.19%
      |                      real/pic    -0.23%
      |                      real/scs    -0.43%
      |               shootout/n-body    -0.41%
      |        shootout/spectral-norm    -0.12%
      +========================================
      |                     geom mean    -0.05%
      
      Pleasingly, overall executable size is down by just over 1%.
      
      Compile times (in perf/compiler) wobble around a bit +/- 0.5%, but the
      geometric mean is -0.1% which seems good.
      cfd68290
  2. Dec 14, 2023
  3. Oct 18, 2023
  4. Sep 15, 2023
  5. Jul 06, 2023
  6. Jun 13, 2023
  7. May 15, 2023
    • Matthew Farkas-Dyck's avatar
      Unbreak some tests with latest GNU grep, which now warns about stray '\'. · e305e60c
      Matthew Farkas-Dyck authored and Marge Bot's avatar Marge Bot committed
      Confusingly, the testsuite mangled the error to say "stray /".
      
      We also migrate some tests from grep to grep -E, as it seems the author actually wanted an "POSIX extended" (a.k.a. sane) regex.
      
      Background: POSIX specifies 2 "regex" syntaxen: "basic" and "extended". Of these, only "extended" syntax is actually a regular expression. Furthermore, "basic" syntax is inconsistent in its use of the '\' character — sometimes it escapes a regex metacharacter, but sometimes it unescapes it, i.e. it makes an otherwise normal character become a metacharacter. This baffles me and it seems also the authors of these tests. Also, the regex(7) man page (at least on Linux) says "basic" syntax is obsolete. Nearly all modern tools and libraries are consistent in this use of the '\' character (of which many use "extended" syntax by default).
      e305e60c
  8. Mar 03, 2023
  9. Feb 24, 2023
  10. Feb 06, 2023
    • Sylvain Henry's avatar
      JS: replace "js" architecture with "javascript" · 6636b670
      Sylvain Henry authored and Marge Bot's avatar Marge Bot committed
      
      Despite Cabal supporting any architecture name, `cabal --check` only
      supports a few built-in ones. Sadly `cabal --check` is used by Hackage
      hence using any non built-in name in a package (e.g. `arch(js)`) is
      rejected and the package is prevented from being uploaded on Hackage.
      
      Luckily built-in support for the `javascript` architecture was added for
      GHCJS a while ago. In order to allow newer `base` to be uploaded on
      Hackage we make the switch from `js` to `javascript` architecture.
      
      Fixes #22740.
      
      Co-authored-by: default avatarBen Gamari <ben@smart-cactus.org>
      6636b670
  11. Feb 02, 2023
    • jeffrey young's avatar
      CI: JavaScript backend runs testsuite · 394b91ce
      jeffrey young authored and Marge Bot's avatar Marge Bot committed
      This MR runs the testsuite for the JS backend. Note that this is a
      temporary solution until !9515 is merged.
      
      Key point: The CI runs hadrian on the built cross compiler _but not_ on
      the bindist.
      
      Other Highlights:
      
       - stm submodule gets a bump to mark tests as broken
       - several tests are marked as broken or are fixed by adding more
       - conditions to their test runner instance.
      
      List of working commit messages:
      
      CI: test cross target _and_ emulator
      
      CI: JS: Try run testsuite with hadrian
      
      JS.CI: cleanup and simplify hadrian invocation
      
      use single bracket, print info
      
      JS CI: remove call to test_compiler from hadrian
      
      don't build haddock
      
      JS: mark more tests as broken
      
      Tracked in #22576
      
      JS testsuite: don't skip sum_mod test
      
      Its expected to fail, yet we skipped it which automatically makes it
      succeed leading to an unexpected success,
      
      JS testsuite: don't mark T12035j as skip
      
      leads to an unexpected pass
      
      JS testsuite: remove broken on T14075
      
      leads to unexpected pass
      
      JS testsuite: mark more tests as broken
      
      JS testsuite: mark T11760 in base as broken
      
      JS testsuite: mark ManyUnbSums broken
      
      submodules: bump process and hpc for JS tests
      
      Both submodules has needed tests skipped or marked broken for th JS
      backend. This commit now adds these changes to GHC.
      
      See:
      
      HPC: hpc/hpc!21
      
      Process: https://github.com/haskell/process/pull/268
      
      remove js_broken on now passing tests
      
      separate wasm and js backend ci
      
      test: T11760: add threaded, non-moving only_ways
      
      test: T10296a add req_c
      
      T13894: skip for JS backend
      
      tests: jspace, T22333: mark as js_broken(22573)
      
      test: T22513i mark as req_th
      
      stm submodule: mark stm055, T16707 broken for JS
      
      tests: js_broken(22374) on unpack_sums_6, T12010
      
      dont run diff on JS CI, cleanup
      
      fixup: More CI cleanup
      
      fix: align text to master
      
      fix: align exceptions submodule to master
      
      CI: Bump DOCKER_REV
      
      Bump to ci-images commit that has a deb11 build with node. Required for
      !9552
      
      testsuite: mark T22669 as js_skip
      
      See #22669
      
      This test tests that .o-boot files aren't created when run in using the
      interpreter backend. Thus this is not relevant for the JS backend.
      
      testsuite: mark T22671 as broken on JS
      
      See #22835
      
      base.testsuite: mark Chan002 fragile for JS
      
      see #22836
      
      revert: submodule process bump
      
      bump stm submodule
      
      New hash includes skips for the JS backend.
      
      testsuite: mark RnPatternSynonymFail broken on JS
      
      Requires TH:
       - see !9779
       - and #22261
      
      compiler: GHC.hs ifdef import Utils.Panic.Plain
      394b91ce
  12. Jan 24, 2023
  13. Dec 14, 2022
  14. Nov 29, 2022
  15. Nov 03, 2022
  16. Oct 25, 2022
    • Simon Peyton Jones's avatar
      Make the specialiser handle polymorphic specialisation · 5a997e16
      Simon Peyton Jones authored and Marge Bot's avatar Marge Bot committed
      Ticket #13873 unexpectedly showed that a SPECIALISE pragma made a
      program run (a lot) slower, because less specialisation took place
      overall. It turned out that the specialiser was missing opportunities
      because of quantified type variables.
      
      It was quite easy to fix. The story is given in
          Note [Specialising polymorphic dictionaries]
      
      Two other minor fixes in the specialiser
      
      * There is no benefit in specialising data constructor /wrappers/.
        (They can appear overloaded because they are given a dictionary
        to store in the constructor.)  Small guard in canSpecImport.
      
      * There was a buglet in the UnspecArg case of specHeader, in the
        case where there is a dead binder. We need a LitRubbish filler
        for the specUnfolding stuff.  I expanded
        Note [Drop dead args from specialisations] to explain.
      
      There is a 4% increase in compile time for T15164, because we generate
      more specialised code.  This seems OK.
      
      Metric Increase:
          T15164
      5a997e16
  17. Oct 14, 2022
  18. Sep 28, 2022
    • Bodigrim's avatar
      Avoid Data.List.group; prefer Data.List.NonEmpty.group · 2f050687
      Bodigrim authored and Marge Bot's avatar Marge Bot committed
      This allows to avoid further partiality, e. g., map head . group is
      replaced by map NE.head . NE.group, and there are less panic calls.
      2f050687
    • Simon Peyton Jones's avatar
      Refactor UnfoldingSource and IfaceUnfolding · addeefc0
      Simon Peyton Jones authored and Marge Bot's avatar Marge Bot committed
      I finally got tired of the way that IfaceUnfolding reflected
      a previous structure of unfoldings, not the current one. This
      MR refactors UnfoldingSource and IfaceUnfolding to be simpler
      and more consistent.
      
      It's largely just a refactor, but in UnfoldingSource (which moves
      to GHC.Types.Basic, since it is now used in IfaceSyn too), I
      distinguish between /user-specified/ and /system-generated/ stable
      unfoldings.
      
          data UnfoldingSource
            = VanillaSrc
            | StableUserSrc   -- From a user-specified pragma
            | StableSystemSrc -- From a system-generated unfolding
            | CompulsorySrc
      
      This has a minor effect in CSE (see the use of isisStableUserUnfolding
      in GHC.Core.Opt.CSE), which I tripped over when working on
      specialisation, but it seems like a Good Thing to know anyway.
      addeefc0
  19. Sep 13, 2022
    • sheaf's avatar
      Diagnostic codes: acccept test changes · 362cca13
      sheaf authored and Marge Bot's avatar Marge Bot committed
      The testsuite output now contains diagnostic codes, so many tests need
      to be updated at once.
      We decided it was best to keep the diagnostic codes in the testsuite
      output, so that contributors don't inadvertently make changes to the
      diagnostic codes.
      362cca13
  20. Aug 02, 2022
  21. Jun 06, 2022
  22. May 30, 2022
    • Simon Peyton Jones's avatar
      A bunch of changes related to eta reduction · 6656f016
      Simon Peyton Jones authored and Marge Bot's avatar Marge Bot committed
      This is a large collection of changes all relating to eta
      reduction, originally triggered by #18993, but there followed
      a long saga.
      
      Specifics:
      
      * Move state-hack stuff from GHC.Types.Id (where it never belonged)
        to GHC.Core.Opt.Arity (which seems much more appropriate).
      
      * Add a crucial mkCast in the Cast case of
        GHC.Core.Opt.Arity.eta_expand; helps with T18223
      
      * Add clarifying notes about eta-reducing to PAPs.
        See Note [Do not eta reduce PAPs]
      
      * I moved tryEtaReduce from GHC.Core.Utils to GHC.Core.Opt.Arity,
        where it properly belongs.  See Note [Eta reduce PAPs]
      
      * In GHC.Core.Opt.Simplify.Utils.tryEtaExpandRhs, pull out the code for
        when eta-expansion is wanted, to make wantEtaExpansion, and all that
        same function in GHC.Core.Opt.Simplify.simplStableUnfolding.  It was
        previously inconsistent, but it's doing the same thing.
      
      * I did a substantial refactor of ArityType; see Note [ArityType].
        This allowed me to do away with the somewhat mysterious takeOneShots;
        more generally it allows arityType to describe the function, leaving
        its clients to decide how to use that information.
      
        I made ArityType abstract, so that clients have to use functions
        to access it.
      
      * Make GHC.Core.Opt.Simplify.Utils.rebuildLam (was stupidly called
        mkLam before) aware of the floats that the simplifier builds up, so
        that it can still do eta-reduction even if there are some floats.
        (Previously that would not happen.)  That means passing the floats
        to rebuildLam, and an extra check when eta-reducting (etaFloatOk).
      
      * In GHC.Core.Opt.Simplify.Utils.tryEtaExpandRhs, make use of call-info
        in the idDemandInfo of the binder, as well as the CallArity info. The
        occurrence analyser did this but we were failing to take advantage here.
      
        In the end I moved the heavy lifting to GHC.Core.Opt.Arity.findRhsArity;
        see Note [Combining arityType with demand info], and functions
        idDemandOneShots and combineWithDemandOneShots.
      
        (These changes partly drove my refactoring of ArityType.)
      
      * In GHC.Core.Opt.Arity.findRhsArity
        * I'm now taking account of the demand on the binder to give
          extra one-shot info.  E.g. if the fn is always called with two
          args, we can give better one-shot info on the binders
          than if we just look at the RHS.
      
        * Don't do any fixpointing in the non-recursive
          case -- simple short cut.
      
        * Trim arity inside the loop. See Note [Trim arity inside the loop]
      
      * Make SimpleOpt respect the eta-reduction flag
        (Some associated refactoring here.)
      
      * I made the CallCtxt which the Simplifier uses distinguish between
        recursive and non-recursive right-hand sides.
           data CallCtxt = ... | RhsCtxt RecFlag | ...
        It affects only one thing:
           - We call an RHS context interesting only if it is non-recursive
             see Note [RHS of lets] in GHC.Core.Unfold
      
      * Remove eta-reduction in GHC.CoreToStg.Prep, a welcome simplification.
        See Note [No eta reduction needed in rhsToBody] in GHC.CoreToStg.Prep.
      
      Other incidental changes
      
      * Fix a fairly long-standing outright bug in the ApplyToVal case of
        GHC.Core.Opt.Simplify.mkDupableContWithDmds. I was failing to take the
        tail of 'dmds' in the recursive call, which meant the demands were All
        Wrong.  I have no idea why this has not caused problems before now.
      
      * Delete dead function GHC.Core.Opt.Simplify.Utils.contIsRhsOrArg
      
      Metrics: compile_time/bytes allocated
                                     Test    Metric       Baseline      New value Change
      ---------------------------------------------------------------------------------------
      MultiLayerModulesTH_OneShot(normal) ghc/alloc  2,743,297,692  2,619,762,992  -4.5% GOOD
                           T18223(normal) ghc/alloc  1,103,161,360    972,415,992 -11.9% GOOD
                            T3064(normal) ghc/alloc    201,222,500    184,085,360  -8.5% GOOD
                            T8095(normal) ghc/alloc  3,216,292,528  3,254,416,960  +1.2%
                            T9630(normal) ghc/alloc  1,514,131,032  1,557,719,312  +2.9%  BAD
                       parsing001(normal) ghc/alloc    530,409,812    525,077,696  -1.0%
      
      geo. mean                                 -0.1%
      
      Nofib:
             Program           Size    Allocs   Runtime   Elapsed  TotalMem
      --------------------------------------------------------------------------------
               banner          +0.0%     +0.4%     -8.9%     -8.7%      0.0%
          exact-reals          +0.0%     -7.4%    -36.3%    -37.4%      0.0%
       fannkuch-redux          +0.0%     -0.1%     -1.0%     -1.0%      0.0%
                 fft2          -0.1%     -0.2%    -17.8%    -19.2%      0.0%
                fluid          +0.0%     -1.3%     -2.1%     -2.1%      0.0%
                   gg          -0.0%     +2.2%     -0.2%     -0.1%      0.0%
        spectral-norm          +0.1%     -0.2%      0.0%      0.0%      0.0%
                  tak          +0.0%     -0.3%     -9.8%     -9.8%      0.0%
                 x2n1          +0.0%     -0.2%     -3.2%     -3.2%      0.0%
      --------------------------------------------------------------------------------
                  Min          -3.5%     -7.4%    -58.7%    -59.9%      0.0%
                  Max          +0.1%     +2.2%    +32.9%    +32.9%      0.0%
       Geometric Mean          -0.0%     -0.1%    -14.2%    -14.8%     -0.0%
      
      Metric Decrease:
          MultiLayerModulesTH_OneShot
          T18223
          T3064
          T15185
          T14766
      Metric Increase:
          T9630
      6656f016
  23. Apr 30, 2022
  24. Apr 06, 2022
  25. Apr 01, 2022
  26. Mar 16, 2022
    • Sebastian Graf's avatar
      Demand: Let `Boxed` win in `lubBoxity` (#21119) · 1575c4a5
      Sebastian Graf authored and Marge Bot's avatar Marge Bot committed
      Previously, we let `Unboxed` win in `lubBoxity`, which is unsoundly optimistic
      in terms ob Boxity analysis. "Unsoundly" in the sense that we sometimes unbox
      parameters that we better shouldn't unbox. Examples are #18907 and T19871.absent.
      
      Until now, we thought that this hack pulled its weight becuase it worked around
      some shortcomings of the phase separation between Boxity analysis and CPR
      analysis. But it is a gross hack which caused regressions itself that needed all
      kinds of fixes and workarounds. See for example #20767. It became impossible to
      work with in !7599, so I want to remove it.
      
      For example, at the moment, `lubDmd B dmd` will not unbox `dmd`,
      but `lubDmd A dmd` will. Given that `B` is supposed to be the bottom element of
      the lattice, it's hardly justifiable to get a better demand when `lub`bing with
      `A`.
      
      The consequence of letting `Boxed` win in `lubBoxity` is that we *would* regress
       #2387, #16040 and parts of #5075 and T19871.sumIO, until Boxity and CPR
      are able to communicate better. Fortunately, that is not the case since I could
      tweak the other source of optimism in Boxity analysis that is described in
      `Note [Unboxed demand on function bodies returning small products]` so that
      we *recursively* assume unboxed demands on function bodies returning small
      products. See the updated Note.
      
      `Note [Boxity for bottoming functions]` describes why we need bottoming
      functions to have signatures that say that they deeply unbox their arguments.
      In so doing, I had to tweak `finaliseArgBoxities` so that it will never unbox
      recursive data constructors. This is in line with our handling of them in CPR.
      I updated `Note [Which types are unboxed?]` to reflect that.
      
      In turn we fix #21119, #20767, #18907, T19871.absent and get a much simpler
      implementation (at least to think about). We can also drop the very ad-hoc
      definition of `deferAfterPreciseException` and its Note in favor of the
      simple, intuitive definition we used to have.
      
      Metric Decrease:
          T16875
          T18223
          T18698a
          T18698b
          hard_hole_fits
      Metric Increase:
          LargeRecord
          MultiComponentModulesRecomp
          T15703
          T8095
          T9872d
      
      Out of all the regresions, only the one in T9872d doesn't vanish in a perf
      build, where the compiler is bootstrapped with -O2 and thus SpecConstr.
      Reason for regressions:
      
        * T9872d is due to `ty_co_subst` taking its `LiftingContext` boxed.
          That is because the context is passed to a function argument, for
          example in `liftCoSubstTyVarBndrUsing`.
        * In T15703, LargeRecord and T8095, we get a bit more allocations in
          `expand_syn` and `piResultTys`, because a `TCvSubst` isn't unboxed.
          In both cases that guards against reboxing in some code paths.
        * The same is true for MultiComponentModulesRecomp, where we get less unboxing
          in `GHC.Unit.Finder.$wfindInstalledHomeModule`. In a perf build, allocations
          actually *improve* by over 4%!
      
      Results on NoFib:
      
      --------------------------------------------------------------------------------
              Program         Allocs    Instrs
      --------------------------------------------------------------------------------
               awards          -0.4%     +0.3%
            cacheprof          -0.3%     +2.4%
                  fft          -1.5%     -5.1%
             fibheaps          +1.2%     +0.8%
                fluid          -0.3%     -0.1%
                  ida          +0.4%     +0.9%
         k-nucleotide          +0.4%     -0.1%
           last-piece         +10.5%    +13.9%
                 lift          -4.4%     +3.5%
              mandel2         -99.7%    -99.8%
                 mate          -0.4%     +3.6%
               parser          -1.0%     +0.1%
               puzzle         -11.6%     +6.5%
      reverse-complem          -3.0%     +2.0%
                  scs          -0.5%     +0.1%
               sphere          -0.4%     -0.2%
            wave4main          -8.2%     -0.3%
      --------------------------------------------------------------------------------
      Summary excludes mandel2 because of excessive bias
                  Min         -11.6%     -5.1%
                  Max         +10.5%    +13.9%
       Geometric Mean          -0.2%     +0.3%
      --------------------------------------------------------------------------------
      
      Not bad for a bug fix.
      
      The regression in `last-piece` could become a win if SpecConstr would work on
      non-recursive functions. The regression in `fibheaps` is due to
      `Note [Reboxed crud for bottoming calls]`, e.g., #21128.
      1575c4a5
  27. Mar 02, 2022
    • sheaf's avatar
      Improve out-of-order inferred type variables · f596c91a
      sheaf authored and Marge Bot's avatar Marge Bot committed
        Don't instantiate type variables for :type in
        `GHC.Tc.Gen.App.tcInstFun`, to avoid inconsistently instantianting
        `r1` but not `r2` in the type
      
          forall {r1} (a :: TYPE r1) {r2} (b :: TYPE r2). ...
      
        This fixes #21088.
      
        This patch also changes the primop pretty-printer to ensure
        that we put all the inferred type variables first. For example,
        the type of reallyUnsafePtrEquality# is now
      
          forall {l :: Levity} {k :: Levity}
                 (a :: TYPE (BoxedRep l))
                 (b :: TYPE (BoxedRep k)).
            a -> b -> Int#
      
        This means we avoid running into issue #21088 entirely with
        the types of primops. Users can still write a type signature where
        the inferred type variables don't come first, however.
      
        This change to primops had a knock-on consequence, revealing that
        we were sometimes performing eta reduction on keepAlive#.
        This patch updates tryEtaReduce to avoid eta reducing functions
        with no binding, bringing it in line with tryEtaReducePrep,
        and thus fixing #21090.
      f596c91a
  28. Nov 06, 2021
  29. Oct 29, 2021
  30. Oct 24, 2021
    • Sebastian Graf's avatar
      DmdAnal: Implement Boxity Analysis (#19871) · 3bab222c
      Sebastian Graf authored and Marge Bot's avatar Marge Bot committed
      This patch fixes some abundant reboxing of `DynFlags` in
      `GHC.HsToCore.Match.Literal.warnAboutOverflowedLit` (which was the topic
      of #19407) by introducing a Boxity analysis to GHC, done as part of demand
      analysis. This allows to accurately capture ad-hoc unboxing decisions previously
      made in worker/wrapper in demand analysis now, where the boxity info can
      propagate through demand signatures.
      
      See the new `Note [Boxity analysis]`. The actual fix for #19407 is described in
      `Note [No lazy, Unboxed demand in demand signature]`, but
      `Note [Finalising boxity for demand signature]` is probably a better entry-point.
      
      To support the fix for #19407, I had to change (what was)
      `Note [Add demands for strict constructors]` a bit
      (now `Note [Unboxing evaluated arguments]`). In particular, we now take care of
      it in `finaliseBoxity` (which is only called from demand analaysis) instead of
      `wantToUnboxArg`.
      
      I also had to resurrect `Note [Product demands for function body]` and rename
      it to `Note [Unboxed demand on function bodies returning small products]` to
      avoid huge regressions in `join004` and `join007`, thereby fixing #4267 again.
      See the updated Note for details.
      
      A nice side-effect is that the worker/wrapper transformation no longer needs to
      look at strictness info and other bits such as `InsideInlineableFun` flags
      (needed for `Note [Do not unbox class dictionaries]`) at all. It simply collects
      boxity info from argument demands and interprets them with a severely simplified
      `wantToUnboxArg`. All the smartness is in `finaliseBoxity`, which could be moved
      to DmdAnal completely, if it wasn't for the call to `dubiousDataConInstArgTys`
      which would be awkward to export.
      
      I spent some time figuring out the reason for why `T16197` failed prior to my
      amendments to `Note [Unboxing evaluated arguments]`. After having it figured
      out, I minimised it a bit and added `T16197b`, which simply compares computed
      strictness signatures and thus should be far simpler to eyeball.
      
      The 12% ghc/alloc regression in T11545 is because of the additional `Boxity`
      field in `Poly` and `Prod` that results in more allocation during `lubSubDmd`
      and `plusSubDmd`. I made sure in the ticky profiles that the number of calls
      to those functions stayed the same. We can bear such an increase here, as we
      recently improved it by -68% (in b760c1f7).
      T18698* regress slightly because there is more unboxing of dictionaries
      happening and that causes Lint (mostly) to allocate more.
      
      Fixes #19871, #19407, #4267, #16859, #18907 and #13331.
      
      Metric Increase:
          T11545
          T18698a
          T18698b
      
      Metric Decrease:
          T12425
          T16577
          T18223
          T18282
          T4267
          T9961
      3bab222c
  31. Oct 22, 2021
  32. Oct 08, 2021
  33. Oct 05, 2021
  34. Oct 04, 2021
  35. Sep 30, 2021
  36. Sep 28, 2021
  37. Sep 23, 2021
Loading