Skip to content
Snippets Groups Projects
  1. Jul 06, 2023
  2. Jul 05, 2023
    • Torsten Schmits's avatar
      Substitute free variables captured by breakpoints in SpecConstr · 40f4ef7c
      Torsten Schmits authored and Marge Bot's avatar Marge Bot committed
      Fixes #23267
      40f4ef7c
    • meooow's avatar
      Improve the situation with the stimes cycle · 9ce44336
      meooow authored and Marge Bot's avatar Marge Bot committed
      Currently the Semigroup stimes cycle is resolved in GHC.Base by
      importing stimes implementations from a hs-boot file. Resolve the cycle
      using hs-boot files for required classes (Num, Integral) instead. Now
      stimes can be defined directly in GHC.Base, making inlining and
      specialization possible.
      
      This leads to some new boot files for `GHC.Num` and `GHC.Real`, the
      methods for those are only used to implement `stimes` so it doesn't
      appear that these boot files will introduce any new performance traps.
      
      Metric Decrease:
          T13386
          T8095
      Metric Increase:
          T13253
          T13386
          T18698a
          T18698b
          T19695
          T8095
      9ce44336
    • Vladislav Zavialov's avatar
      testsuite: Do not require CUSKs · 679bbc97
      Vladislav Zavialov authored and Marge Bot's avatar Marge Bot committed
      Numerous tests make use of CUSKs (complete user-supplied kinds),
      a legacy feature scheduled for deprecation. In order to proceed
      with the said deprecation, the tests have been updated to use SAKS
      instead (standalone kind signatures).
      
      This also allows us to remove the Haskell2010 language pragmas that
      were added in 115cd3c8 to work around the lack of CUSKs in GHC2021.
      679bbc97
  3. Jun 29, 2023
  4. Jun 21, 2023
  5. Jun 14, 2023
  6. Jun 13, 2023
  7. May 23, 2023
    • Simon Peyton Jones's avatar
      Avoid an assertion failure in abstractFloats · 6abf3648
      Simon Peyton Jones authored and Marge Bot's avatar Marge Bot committed
      The function GHC.Core.Opt.Simplify.Utils.abstractFloats
      was carelessly calling lookupIdSubst_maybe on a CoVar;
      but a precondition of the latter is being given an Id.
      
      In fact it's harmless to call it on a CoVar, but still, the
      precondition on lookupIdSubst_maybe makes sense, so I added
      a test for CoVars.
      
      This avoids a crash in a DEBUG compiler, but otherwise has
      no effect. Fixes #23426.
      6abf3648
  8. 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
  9. May 13, 2023
  10. May 12, 2023
  11. May 06, 2023
  12. Apr 26, 2023
    • Sebastian Graf's avatar
      DmdAnal: Unleash demand signatures of free RULE and unfolding binders (#23208) · c30ac25f
      Sebastian Graf authored and Marge Bot's avatar Marge Bot committed
      In #23208 we observed that the demand signature of a binder occuring in a RULE
      wasn't unleashed, leading to a transitively used binder being discarded as
      absent. The solution was to use the same code path that we already use for
      handling exported bindings.
      
      See the changes to `Note [Absence analysis for stable unfoldings and RULES]`
      for more details.
      
      I took the chance to factor out the old notion of a `PlusDmdArg` (a pair of a
      `VarEnv Demand` and a `Divergence`) into `DmdEnv`, which fits nicely into our
      existing framework. As a result, I had to touch quite a few places in the code.
      
      This refactoring exposed a few small bugs around correct handling of bottoming
      demand environments. As a result, some strictness signatures now mention uniques
      that weren't there before which caused test output changes to T13143, T19969 and
      T22112. But these tests compared whole -ddump-simpl listings which is a very
      fragile thing to begin with. I changed what exactly they test for based on the
      symptoms in the corresponding issues.
      
      There is a single regression in T18894 because we are more conservative around
      stable unfoldings now. Unfortunately it is not easily fixed; let's wait until
      there is a concrete motivation before invest more time.
      
      Fixes #23208.
      c30ac25f
  13. Apr 25, 2023
    • Andrei Borzenkov's avatar
      Give more guarntees about ImplicitParams (#23289) · 74c55712
      Andrei Borzenkov authored and Marge Bot's avatar Marge Bot committed
      - Added new section in the GHC user's guide that legends behavior of
      nested implicit parameter bindings in these two cases:
      
        let ?f = 1 in let ?f = 2 in ?f
      
      and
      
        data T where MkT :: (?f :: Int) => T
      
        f :: T -> T -> Int
        f MkT MkT = ?f
      
      - Added new test case to examine this behavior.
      74c55712
  14. Apr 20, 2023
  15. Apr 04, 2023
  16. Apr 01, 2023
    • Matthew Pickering's avatar
      Add test for T23184 · 0077cb22
      Matthew Pickering authored and Marge Bot's avatar Marge Bot committed
      There was an outright bug, which Simon fixed in July 2021, as a little side-fix on a complicated patch:
      
      ```
      commit 6656f016
      Author: Simon Peyton Jones <simonpj@microsoft.com>
      Date:   Fri Jul 23 23:57:01 2021 +0100
      
          A bunch of changes related to eta reduction
      
          This is a large collection of changes all relating to eta
          reduction, originally triggered by #18993, but there followed
          a long saga.
      
          Specifics:
      
      ...lots of lines omitted...
      
          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.
      ```
      
      Note this "Fix a fairly longstanding outright bug".   This is the specific fix
      ```
      @@ -3552,8 +3556,8 @@ mkDupableContWithDmds env dmds
               --              let a = ...arg...
               --              in [...hole...] a
               -- NB: sc_dup /= OkToDup; that is caught earlier by contIsDupable
      -    do  { let (dmd:_) = dmds   -- Never fails
      -        ; (floats1, cont') <- mkDupableContWithDmds env dmds cont
      +    do  { let (dmd:cont_dmds) = dmds   -- Never fails
      +        ; (floats1, cont') <- mkDupableContWithDmds env cont_dmds cont
               ; let env' = env `setInScopeFromF` floats1
               ; (_, se', arg') <- simplArg env' dup se arg
               ; (let_floats2, arg'') <- makeTrivial env NotTopLevel dmd (fsLit "karg") arg'
      ```
      Ticket #23184 is a report of the bug that this diff fixes.
      0077cb22
  17. Mar 30, 2023
  18. Mar 21, 2023
  19. Mar 03, 2023
  20. Feb 28, 2023
    • Simon Peyton Jones's avatar
      Take more care with unlifted bindings in the specialiser · 7192ef91
      Simon Peyton Jones authored and Marge Bot's avatar Marge Bot committed
      As #22998 showed, we were floating an unlifted binding to top
      level, which breaks a Core invariant.
      
      The fix is easy, albeit a little bit conservative.  See
      Note [Care with unlifted bindings] in GHC.Core.Opt.Specialise
      7192ef91
    • Simon Peyton Jones's avatar
      Account for local rules in specImports · 0c200ab7
      Simon Peyton Jones authored and Marge Bot's avatar Marge Bot committed
      As #23024 showed, in GHC.Core.Opt.Specialise.specImports, we were
      generating specialisations (a locally-define function) for imported
      functions; and then generating specialisations for those
      locally-defined functions.  The RULE for the latter should be
      attached to the local Id, not put in the rules-for-imported-ids
      set.
      
      Fix is easy; similar to what happens in GHC.HsToCore.addExportFlagsAndRules
      0c200ab7
  21. Feb 27, 2023
    • Gergő Érdi's avatar
      Don't specialise incoherent instance applications · b56025f4
      Gergő Érdi authored
      Using incoherent instances, there can be situations where two
      occurrences of the same overloaded function at the same type use two
      different instances (see #22448). For incoherently resolved instances,
      we must mark them with `nospec` to avoid the specialiser rewriting one
      to the other. This marking is done during the desugaring of the
      `WpEvApp` wrapper.
      
      Fixes #22448
      
      Metric Increase:
          T15304
      b56025f4
  22. Feb 25, 2023
    • Simon Peyton Jones's avatar
      Fix shadowing bug in prepareAlts · ece092d0
      Simon Peyton Jones authored and Marge Bot's avatar Marge Bot committed
      As #23012 showed, GHC.Core.Opt.Simplify.Utils.prepareAlts was
      using an OutType to construct an InAlt.  When shadowing is in play,
      this is outright wrong.
      
      See Note [Shadowing in prepareAlts].
      ece092d0
  23. Feb 10, 2023
    • Simon Peyton Jones's avatar
      Refactor the simplifier a bit to fix #22761 · e45eb828
      Simon Peyton Jones authored and Marge Bot's avatar Marge Bot committed
      The core change in this commit, which fixes #22761, is that
      
      * In a Core rule, ru_rhs is always occ-analysed.
      
      This means adding a couple of calls to occurAnalyseExpr when
      building a Rule, in
      * GHC.Core.Rules.mkRule
      * GHC.Core.Opt.Simplify.Iteration.simplRules
      
      But diagosing the bug made me stare carefully at the code of the
      Simplifier, and I ended up doing some only-loosely-related refactoring.
      
      * I think that RULES could be lost because not every code path
        did addBndrRules
      
      * The code around lambdas was very convoluted
      
      It's mainly moving deck chairs around, but I like it more now.
      e45eb828
  24. Feb 09, 2023
  25. Feb 08, 2023
    • Matthew Pickering's avatar
      Revert "Don't keep exit join points so much" · 7eac2468
      Matthew Pickering authored and Marge Bot's avatar Marge Bot committed
      This reverts commit caced757.
      
      It seems the patch "Don't keep exit join points so much" is causing
      wide-spread regressions in the bytestring library benchmarks. If I
      revert it then the 9.6 numbers are better on average than 9.4.
      
      See ghc/ghc#22893 (comment 479525)
      
      -------------------------
      Metric Decrease:
          MultiComponentModules
          MultiComponentModulesRecomp
          MultiLayerModules
          MultiLayerModulesRecomp
          MultiLayerModulesTH_Make
          T12150
          T13386
          T13719
          T21839c
          T3294
          parsing001
      -------------------------
      7eac2468
  26. Feb 04, 2023
  27. 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
    • Jaro Reinders's avatar
      compiler: Implement higher order patterns in the rule matcher · 61ce5bf6
      Jaro Reinders authored and Marge Bot's avatar Marge Bot committed
      This implements proposal 555 and closes ticket #22465.
      See the proposal and ticket for motivation.
      
      The core changes of this patch are in the GHC.Core.Rules.match function
      and they are explained in the Note [Matching higher order patterns].
      61ce5bf6
  28. Feb 01, 2023
  29. Jan 31, 2023
    • Simon Peyton Jones's avatar
      Improve exprOkForSpeculation for classops · a83c810d
      Simon Peyton Jones authored and Marge Bot's avatar Marge Bot committed
      This patch fixes #22745 and #15205, which are about GHC's
      failure to discard unnecessary superclass selections that
      yield coercions.  See
        GHC.Core.Utils Note [exprOkForSpeculation and type classes]
      
      The main changes are:
      
      * Write new Note [NON-BOTTOM_DICTS invariant] in GHC.Core, and
        refer to it
      
      * Define new function isTerminatingType, to identify those
        guaranteed-terminating dictionary types.
      
      * exprOkForSpeculation has a new (very simple) case for ClassOpId
      
      * ClassOpId has a new field that says if the return type is
        an unlifted type, or a terminating type.
      
      This was surprisingly tricky to get right.  In particular note
      that unlifted types are not terminating types; you can write an
      expression of unlifted type, that diverges.  Not so for dictionaries
      (or, more precisely, for the dictionaries that GHC constructs).
      
      Metric Decrease:
          LargeRecord
      a83c810d
    • Simon Peyton Jones's avatar
      Take account of loop breakers in specLookupRule · d0f34f25
      Simon Peyton Jones authored and Marge Bot's avatar Marge Bot committed
      The key change is that in GHC.Core.Opt.Specialise.specLookupRule
      we were using realIdUnfolding, which ignores the loop-breaker
      flag.  When given a loop breaker, rule matching therefore
      looped infinitely -- #22802.
      
      In fixing this I refactored a bit.
      
      * Define GHC.Core.InScopeEnv as a data type, and use it.
        (Previously it was a pair: hard to grep for.)
      
      * Put several functions returning an IdUnfoldingFun into
        GHC.Types.Id, namely
           idUnfolding
           alwaysActiveUnfoldingFun,
           whenActiveUnfoldingFun,
           noUnfoldingFun
        and use them.  (The are all loop-breaker aware.)
      d0f34f25
  30. Jan 25, 2023
  31. Jan 17, 2023
  32. Jan 12, 2023
    • Sebastian Graf's avatar
      Fix contification with stable unfoldings (#22428) · 905d0b6e
      Sebastian Graf authored and Marge Bot's avatar Marge Bot committed
      Many functions now return a `TailUsageDetails` that adorns a `UsageDetails` with
      a `JoinArity` that reflects the number of join point binders around the body
      for which the `UsageDetails` was computed. `TailUsageDetails` is now returned by
      `occAnalLamTail` as well as `occAnalUnfolding` and `occAnalRules`.
      
      I adjusted `Note [Join points and unfoldings/rules]` and
      `Note [Adjusting right-hand sides]` to account for the new machinery.
      I also wrote a new `Note [Join arity prediction based on joinRhsArity]`
      and refer to it when we combine `TailUsageDetails` for a recursive RHS.
      
      I also renamed
      
        * `occAnalLam` to `occAnalLamTail`
        * `adjustRhsUsage` to `adjustTailUsage`
        * a few other less important functions
      
      and properly documented the that each call of `occAnalLamTail` must pair up with
      `adjustTailUsage`.
      
      I removed `Note [Unfoldings and join points]` because it was redundant with
      `Note [Occurrences in stable unfoldings]`.
      
      While in town, I refactored `mkLoopBreakerNodes` so that it returns a condensed
      `NodeDetails` called `SimpleNodeDetails`.
      
      Fixes #22428.
      
      The refactoring seems to have quite beneficial effect on ghc/alloc performance:
      
      ```
           CoOpt_Read(normal) ghc/alloc    784,778,420    768,091,176  -2.1% GOOD
               T12150(optasm) ghc/alloc     77,762,270     75,986,720  -2.3% GOOD
               T12425(optasm) ghc/alloc     85,740,186     84,641,712  -1.3% GOOD
               T13056(optasm) ghc/alloc    306,104,656    299,811,632  -2.1% GOOD
               T13253(normal) ghc/alloc    350,233,952    346,004,008  -1.2%
               T14683(normal) ghc/alloc  2,800,514,792  2,754,651,360  -1.6%
               T15304(normal) ghc/alloc  1,230,883,318  1,215,978,336  -1.2%
               T15630(normal) ghc/alloc    153,379,590    151,796,488  -1.0%
               T16577(normal) ghc/alloc  7,356,797,056  7,244,194,416  -1.5%
               T17516(normal) ghc/alloc  1,718,941,448  1,692,157,288  -1.6%
               T19695(normal) ghc/alloc  1,485,794,632  1,458,022,112  -1.9%
              T21839c(normal) ghc/alloc    437,562,314    431,295,896  -1.4% GOOD
              T21839r(normal) ghc/alloc    446,927,580    440,615,776  -1.4% GOOD
      
                    geo. mean                                          -0.6%
                    minimum                                            -2.4%
                    maximum                                            -0.0%
      ```
      
      Metric Decrease:
          CoOpt_Read
          T10421
          T12150
          T12425
          T13056
          T18698a
          T18698b
          T21839c
          T21839r
          T9961
      905d0b6e
    • Simon Peyton Jones's avatar
      Fix finaliseArgBoxities for OPAQUE function · b3be0d18
      Simon Peyton Jones authored and Marge Bot's avatar Marge Bot committed
      We never do worker wrapper for OPAQUE functions, so we must
      zap the unboxing info during strictness analysis.
      
      This patch fixes #22502
      b3be0d18
  33. Jan 11, 2023
    • Simon Peyton Jones's avatar
      Fix void-arg-adding mechanism for worker/wrapper · 964284fc
      Simon Peyton Jones authored and Marge Bot's avatar Marge Bot committed
      As #22725 shows, in worker/wrapper we must add the void argument
      /last/, not first.  See GHC.Core.Opt.WorkWrap.Utils
      Note [Worker/wrapper needs to add void arg last].
      
      That led me to to study GHC.Core.Opt.SpecConstr
      Note [SpecConstr needs to add void args first] which suggests the
      opposite!  And indeed I think it's the other way round for SpecConstr
      -- or more precisely the void arg must precede the "extra_bndrs".
      
      That led me to some refactoring of GHC.Core.Opt.SpecConstr.calcSpecInfo.
      964284fc
Loading