Skip to content
Snippets Groups Projects
  1. Oct 08, 2021
    • abarbu's avatar
      Add defaulting plugins. · a76409c7
      abarbu authored
      Like the built-in type defaulting rules these plugins can propose candidates
      to resolve ambiguous type variables.
      
      Machine learning and other large APIs like those for game engines introduce
      new numeric types and other complex typed APIs. The built-in defaulting
      mechanism isn't powerful enough to resolve ambiguous types in these cases forcing
      users to specify minutia that they might not even know how to do. There is
      an example defaulting plugin linked in the documentation. Applications include
      defaulting the device a computation executes on, if a gradient should be
      computed for a tensor, or the size of a tensor.
      
      See https://github.com/ghc-proposals/ghc-proposals/pull/396 for details.
      a76409c7
    • CarrieMY's avatar
      Fix -E -fno-code undesirable interactions #20439 · 816d2561
      CarrieMY authored and Marge Bot's avatar Marge Bot committed
      816d2561
    • Matthew Pickering's avatar
      Normalise output of T20199 test · 1f160cd9
      Matthew Pickering authored and Marge Bot's avatar Marge Bot committed
      1f160cd9
    • Joachim Breitner's avatar
      New test case: Variant of T14052 with data type definitions · 75aea732
      Joachim Breitner authored and Marge Bot's avatar Marge Bot committed
      previous attempts at fixing #11547 and #20455 were reverted because they
      showed some quadratic behaviour, and the test case T15052 was added to
      catch that.
      
      I believe that similar quadratic behavor can be triggered with current
      master, by using type definitions rather than value definitions, so this
      adds a test case similar to T14052. I have hopes that my attempts at
      fixing #11547 will lead to code that avoid the quadratic increase here.
      Or not, we will see. In any case, having this in `master` and included
      in future comparisons will be useful.
      75aea732
    • Sylvain Henry's avatar
      Don't link plugins' units with target code (#20218) · 3d31f11e
      Sylvain Henry authored and Marge Bot's avatar Marge Bot committed
      Before this patch, plugin units were linked with the target code even
      when the unit was passed via `-plugin-package`. This is an issue to
      support plugins in cross-compilers (plugins are definitely not ABI
      compatible with target code).
      
      We now clearly separate unit dependencies for plugins and unit
      dependencies for target code and only link the latter ones.
      
      We've also added a test to ensure that plugin units passed via
      `-package` are linked with target code so that `thNameToGhcName` can
      still be used in plugins that need it (see T20218b).
      3d31f11e
    • Joachim Breitner's avatar
      Recover test case for T11547 · 01f5324f
      Joachim Breitner authored and Marge Bot's avatar Marge Bot committed
      commit 98c7749c has reverted commit 59d7ee53, including the test that
      that file added. That test case is still valuable, so I am re-adding it.
      I add it with it’s current (broken) behavior so that whoever fixes it
      intentionally or accidentially will notice and then commit the actual
      desired behavior (which is kinda unspecified, see
      #20455 (comment 382030))
      01f5324f
    • Sylvain Henry's avatar
      Bignum: allow naturalToWordClamp/Negate/Signum to inline (#20361) · 3a5a5c85
      Sylvain Henry authored and Marge Bot's avatar Marge Bot committed
      We don't need built-in rules now that bignum literals (e.g. 123 :: Natural)
      match with their constructors (e.g. NS 123##).
      3a5a5c85
  2. Oct 06, 2021
    • sheaf's avatar
      Improve overlap error for polykinded constraints · a466b024
      sheaf authored and Marge Bot's avatar Marge Bot committed
      There were two problems around `mkDictErr`:
      
        1. An outdated call to `flattenTys` meant that we missed out on some
           instances. As we no longer flatten type-family applications,
           the logic is obsolete and can be removed.
      
        2. We reported "out of scope" errors in a poly-kinded situation
           because `BoxedRep` and `Lifted` were considered out of scope.
           We fix this by using `pretendNameIsInScope`.
      
      fixes #20465
      a466b024
    • Matthew Pickering's avatar
      Disable -dynamic-too if -dynamic is also passed · 9af29e7f
      Matthew Pickering authored and Marge Bot's avatar Marge Bot committed
      Before if you passed both options then you would generate two identical
      hi/dyn_hi and o/dyn_o files, both in the dynamic way. It's better to
      warn this is happening rather than duplicating the work and causing
      potential confusion.
      
      -dynamic-too should only be used with -static.
      
      Fixes #20436
      9af29e7f
    • Sebastian Graf's avatar
      CprAnal: Two regression tests · 7fc986e1
      Sebastian Graf authored and Marge Bot's avatar Marge Bot committed
      For #16040 and #2387.
      7fc986e1
    • sheaf's avatar
      Add a regression test for #13233 · 4e91839a
      sheaf authored and Marge Bot's avatar Marge Bot committed
        This test fails on GHC 8.0.1, only when profiling is enabled,
        with the error:
      
          ghc: panic! (the 'impossible' happened)
            kindPrimRep.go a_12
      
        This was fixed by commit b460d6c9.
      4e91839a
    • Alan Zimmerman's avatar
      EPA: Remove duplicate AnnOpenP/AnnCloseP in DataDecl · 89e98bdf
      Alan Zimmerman authored and Marge Bot's avatar Marge Bot committed
      The parens EPAs were added in the tyvars where they belong, but also
      at the top level of the declaration.
      
      Closes #20452
      89e98bdf
  3. Oct 05, 2021
    • Sylvain Henry's avatar
      Constant folding for (.&.) maxBound (#20448) · 11240b74
      Sylvain Henry authored and Marge Bot's avatar Marge Bot committed
      11240b74
    • Simon Peyton Jones's avatar
      Ensure top-level binders in scope in SetLevels · 52400ebb
      Simon Peyton Jones authored and Marge Bot's avatar Marge Bot committed
      Ticket #20200 (the Agda failure) showed another case in which
      lookupIdSubst would fail to find a local Id in the InScopeSet.
      This time it was because SetLevels was given a program in which
      the top-level bindings were not in dependency order.
      
      The Simplifier (see Note [Glomming] in GHC.Core.Opt.Occuranal) and
      the specialiser (see Note [Top level scope] in GHC.Core.Opt.Specialise)
      may both produce top-level bindings where an early binding refers
      to a later one.
      
      One solution would be to run the occurrence analyser again to
      put them all in the right order. But a simpler one is to make
      SetLevels OK with this input by bringing all top-level binders into
      scope at the start. That's what this patch does.
      52400ebb
    • Alfredo Di Napoli's avatar
      Eradicate TcRnUnknownMessage from GHC.Tc.Deriv · ac275f42
      Alfredo Di Napoli authored and Marge Bot's avatar Marge Bot committed
      This (big) commit finishes porting the GHC.Tc.Deriv module to support
      the new diagnostic infrastructure (#18516) by getting rid of the legacy
      calls to `TcRnUnknownMessage`. This work ended up being quite pervasive
      and touched not only the Tc.Deriv module but also the Tc.Deriv.Utils and
      Tc.Deriv.Generics module, which needed to be adapted to use the new
      infrastructure. This also required generalising `Validity`.
      
      More specifically, this is a breakdown of the work done:
      
      * Add and use the TcRnUselessTypeable data constructor
      * Add and use TcRnDerivingDefaults data constructor
      * Add and use the TcRnNonUnaryTypeclassConstraint data constructor
      * Add and use TcRnPartialTypeSignatures
      * Add T13324_compile2 test to test another part of the
        TcRnPartialTypeSignatures diagnostic
      * Add and use TcRnCannotDeriveInstance data constructor, which introduces a
        new data constructor to TcRnMessage called TcRnCannotDeriveInstance, which
        is further sub-divided to carry a `DeriveInstanceErrReason` which explains
        the reason why we couldn't derive a typeclass instance.
      * Add DerivErrSafeHaskellGenericInst data constructor to DeriveInstanceErrReason
      * Add DerivErrDerivingViaWrongKind and DerivErrNoEtaReduce
      * Introduce the SuggestExtensionInOrderTo Hint, which adds (and use) a new
        constructor to the hint type `LanguageExtensionHint` called `SuggestExtensionInOrderTo`,
        which can be used to give a bit more "firm" recommendations when it's
        obvious what the required extension is, like in the case for the
        `DerivingStrategies`, which automatically follows from having enabled
        both `DeriveAnyClass` and `GeneralizedNewtypeDeriving`.
      * Wildcard-free pattern matching in mk_eqn_stock, which removes `_` in
        favour of pattern matching explicitly on `CanDeriveAnyClass` and
        `NonDerivableClass`, because that determine whether or not we can
        suggest to the user `DeriveAnyClass` or not.
      ac275f42
    • Sebastian Graf's avatar
      CprAnal: Activate Sum CPR for local bindings · cd1b016f
      Sebastian Graf authored and Marge Bot's avatar Marge Bot committed
      We've had Sum CPR (#5075) for top-level bindings for a couple of years now.
      That begs the question why we didn't also activate it for local bindings, and
      the reasons for that are described in `Note [CPR for sum types]`. Only that it
      didn't make sense! The Note said that Sum CPR would destroy let-no-escapes, but
      that should be a non-issue since we have syntactic join points in Core now and
      we don't WW for them (`Note [Don't w/w join points for CPR]`).
      
      So I simply activated CPR for all bindings of sum type, thus fixing #5075 and
      \#16570. NoFib approves:
      
      ```
      --------------------------------------------------------------------------------
              Program         Allocs    Instrs
      --------------------------------------------------------------------------------
        comp_lab_zift          -0.0%     +0.7%
                fluid          +1.7%     +0.7%
              reptile          +0.1%     +0.1%
      --------------------------------------------------------------------------------
                  Min          -0.0%     -0.2%
                  Max          +1.7%     +0.7%
       Geometric Mean          +0.0%     +0.0%
      ```
      
      There were quite a few metric decreases on the order of 1-4%, but T6048 seems to
      regress significantly, by 26.1%. WW'ing for a `Just` constructor and the nested
      data type meant additional Simplifier iterations and a 30% increase in term
      sizes as well as a 200-300% in type sizes due to unboxed 9-tuples. There's not
      much we can do about it, I'm afraid: We're just doing much more work there.
      
      Metric Decrease:
          T12425
          T18698a
          T18698b
          T20049
          T9020
          WWRec
      Metric Increase:
          T6048
      cd1b016f
    • Sebastian Graf's avatar
      WorkWrap: Nuke CPR signatures of join points (#18824) · 643b6f01
      Sebastian Graf authored and Marge Bot's avatar Marge Bot committed
      In #18824 we saw that the Simplifier didn't nuke a CPR signature of a join point
      when it pushed a continuation into it when it better should have.
      
      But join points are local, mostly non-exported bindings. We don't use their
      CPR signature anyway and would discard it at the end of the Core pipeline.
      Their main purpose is to propagate CPR info during CPR analysis and by the time
      worker/wrapper runs the signature will have served its purpose. So we zap it!
      
      Fixes #18824.
      643b6f01
    • Krzysztof Gogolewski's avatar
      Reject type family equation with wrong name (#20260) · 298df16d
      Krzysztof Gogolewski authored and Marge Bot's avatar Marge Bot committed
      We should reject "type family Foo where Bar = ()".
      This check was done in kcTyFamInstEqn but not in tcTyFamInstEqn.
      I factored out arity checking, which was duplicated.
      298df16d
    • Matthías Páll Gissurarson's avatar
      Speed up valid hole-fits by adding early abort and checks. · 5601b9e2
      Matthías Páll Gissurarson authored and Marge Bot's avatar Marge Bot committed
      By adding an early abort flag in `TcSEnv`, we can fail fast in the presence of
      insoluble constraints. This helps us avoid a lot of work in valid hole-fits, and
      we geta massive speed-up by avoiding a lot of useless work solving constraints that
      never come into play.
      
      Additionally, we add a simple check for degenerate hole types, such as
      when the type of the hole is an immutable type variable (as is the case
      when the hole is completely unconstrained). Then the only valid fits are
      the locals, so we can ignore the global candidates.
      
      This fixes #16875
      5601b9e2
    • sheaf's avatar
      Add a regression test for #17723 · 48b0f17a
      sheaf authored and Marge Bot's avatar Marge Bot committed
        The underlying bug was fixed by b8d98827, see MR !2477
      48b0f17a
    • sheaf's avatar
      Bump TcLevel of failing kind equality implication · a14d0e63
      sheaf authored and Marge Bot's avatar Marge Bot committed
        Not bumping the TcLevel meant that we could end up
        trying to add evidence terms for the implication constraint
        created to wrap failing kind equalities (to avoid their deferral).
      
      fixes #20043
      a14d0e63
    • Vladislav Zavialov's avatar
      Bespoke TokenLocation data type · a7629334
      Vladislav Zavialov authored and Marge Bot's avatar Marge Bot committed
      The EpaAnnCO we were using contained an Anchor instead of EpaLocation,
      making it harder to work with.
      
      At the same time, using EpaLocation by itself isn't possible either,
      as we may have tokens without location information.
      
      Hence the new data type:
      	data TokenLocation = NoTokenLoc
      	                   | TokenLoc !EpaLocation
      a7629334
  4. Oct 04, 2021
  5. Oct 02, 2021
  6. Sep 30, 2021
    • Matthew Pickering's avatar
      Recompilation: Handle -plugin-package correctly · 94f3ce7e
      Matthew Pickering authored and Marge Bot's avatar Marge Bot committed
      If a plugins was specified using the -plugin-package-(id) flag then the
      module it applied to was always recompiled.
      
      The recompilation checker was previously using `findImportedModule`,
      which looked for packages in the HPT and then in the package database
      but only for modules specified using `-package`.
      
      The correct lookup function for plugins is `findPluginModule`, therefore
      we check normal imports with `findImportedModule` and plugins with
      `findPluginModule`.
      
      Fixes #20417
      94f3ce7e
    • Sylvain Henry's avatar
      Rules for sized conversion primops (#19769) · 941d3792
      Sylvain Henry authored and Marge Bot's avatar Marge Bot committed
      Metric Decrease:
          T12545
      941d3792
    • Sebastian Graf's avatar
      Nested CPR light unleashed (#18174) · c261f220
      Sebastian Graf authored and Marge Bot's avatar Marge Bot committed
      This patch enables worker/wrapper for nested constructed products, as described
      in `Note [Nested CPR]`. The machinery for expressing Nested CPR was already
      there, since !5054. Worker/wrapper is equipped to exploit Nested CPR annotations
      since !5338. CPR analysis already handles applications in batches since !5753.
      This patch just needs to flip a few more switches:
      
      1. In `cprTransformDataConWork`, we need to look at the field expressions
         and their `CprType`s to see whether the evaluation of the expressions
         terminates quickly (= is in HNF) or if they are put in strict fields.
         If that is the case, then we retain their CPR info and may unbox nestedly
         later on. More details in `Note [Nested CPR]`.
      2. Enable nested `ConCPR` signatures in `GHC.Types.Cpr`.
      3. In the `asConCpr` call in `GHC.Core.Opt.WorkWrap.Utils`, pass CPR info of
         fields to the `Unbox`.
      4. Instead of giving CPR signatures to DataCon workers and wrappers, we now have
         `cprTransformDataConWork` for workers and treat wrappers by analysing their
         unfolding. As a result, the code from GHC.Types.Id.Make went away completely.
      5. I deactivated worker/wrappering for recursive DataCons and wrote a function
         `isRecDataCon` to detect them. We really don't want to give `repeat` or
         `replicate` the Nested CPR property.
         See Note [CPR for recursive data structures] for which kind of recursive
         DataCons we target.
      6. Fix a couple of tests and their outputs.
      
      I also documented that CPR can destroy sharing and lead to asymptotic increase
      in allocations (which is tracked by #13331/#19326) in
      `Note [CPR for data structures can destroy sharing]`.
      
      Nofib results:
      ```
      --------------------------------------------------------------------------------
              Program         Allocs    Instrs
      --------------------------------------------------------------------------------
         ben-raytrace          -3.1%     -0.4%
         binary-trees          +0.8%     -2.9%
         digits-of-e2          +5.8%     +1.2%
                event          +0.8%     -2.1%
       fannkuch-redux          +0.0%     -1.4%
                 fish           0.0%     -1.5%
               gamteb          -1.4%     -0.3%
              mkhprog          +1.4%     +0.8%
           multiplier          +0.0%     -1.9%
                  pic          -0.6%     -0.1%
              reptile         -20.9%    -17.8%
            wave4main          +4.8%     +0.4%
                 x2n1        -100.0%     -7.6%
      --------------------------------------------------------------------------------
                  Min         -95.0%    -17.8%
                  Max          +5.8%     +1.2%
       Geometric Mean          -2.9%     -0.4%
      ```
      The huge wins in x2n1 (loopy list) and reptile (see #19970) are due to
      refraining from unboxing (:). Other benchmarks like digits-of-e2 or wave4main
      regress because of that. Ultimately there are no great improvements due to
      Nested CPR alone, but at least it's a win.
      Binary sizes decrease by 0.6%.
      
      There are a significant number of metric decreases. The most notable ones (>1%):
      ```
             ManyAlternatives(normal) ghc/alloc   771656002.7   762187472.0  -1.2%
             ManyConstructors(normal) ghc/alloc  4191073418.7  4114369216.0  -1.8%
            MultiLayerModules(normal) ghc/alloc  3095678333.3  3128720704.0  +1.1%
                    PmSeriesG(normal) ghc/alloc    50096429.3    51495664.0  +2.8%
                    PmSeriesS(normal) ghc/alloc    63512989.3    64681600.0  +1.8%
                    PmSeriesV(normal) ghc/alloc    62575424.0    63767208.0  +1.9%
                       T10547(normal) ghc/alloc    29347469.3    29944240.0  +2.0%
                      T11303b(normal) ghc/alloc    46018752.0    47367576.0  +2.9%
                       T12150(optasm) ghc/alloc    81660890.7    82547696.0  +1.1%
                       T12234(optasm) ghc/alloc    59451253.3    60357952.0  +1.5%
                       T12545(normal) ghc/alloc  1705216250.7  1751278952.0  +2.7%
                       T12707(normal) ghc/alloc   981000472.0   968489800.0  -1.3% GOOD
                       T13056(optasm) ghc/alloc   389322664.0   372495160.0  -4.3% GOOD
                       T13253(normal) ghc/alloc   337174229.3   341954576.0  +1.4%
                       T13701(normal) ghc/alloc  2381455173.3  2439790328.0  +2.4%  BAD
                         T14052(ghci) ghc/alloc  2162530642.7  2139108784.0  -1.1%
                       T14683(normal) ghc/alloc  3049744728.0  2977535064.0  -2.4% GOOD
                       T14697(normal) ghc/alloc   362980213.3   369304512.0  +1.7%
                       T15164(normal) ghc/alloc  1323102752.0  1307480600.0  -1.2%
                       T15304(normal) ghc/alloc  1304607429.3  1291024568.0  -1.0%
                       T16190(normal) ghc/alloc   281450410.7   284878048.0  +1.2%
                       T16577(normal) ghc/alloc  7984960789.3  7811668768.0  -2.2% GOOD
                       T17516(normal) ghc/alloc  1171051192.0  1153649664.0  -1.5%
                       T17836(normal) ghc/alloc  1115569746.7  1098197592.0  -1.6%
                      T17836b(normal) ghc/alloc    54322597.3    55518216.0  +2.2%
                       T17977(normal) ghc/alloc    47071754.7    48403408.0  +2.8%
                      T17977b(normal) ghc/alloc    42579133.3    43977392.0  +3.3%
                       T18923(normal) ghc/alloc    71764237.3    72566240.0  +1.1%
                        T1969(normal) ghc/alloc   784821002.7   773971776.0  -1.4% GOOD
                        T3294(normal) ghc/alloc  1634913973.3  1614323584.0  -1.3% GOOD
                        T4801(normal) ghc/alloc   295619648.0   292776440.0  -1.0%
                      T5321FD(normal) ghc/alloc   278827858.7   276067280.0  -1.0%
                        T5631(normal) ghc/alloc   586618202.7   577579960.0  -1.5%
                        T5642(normal) ghc/alloc   494923048.0   487927208.0  -1.4%
                        T5837(normal) ghc/alloc    37758061.3    39261608.0  +4.0%
                        T9020(optasm) ghc/alloc   257362077.3   254672416.0  -1.0%
                        T9198(normal) ghc/alloc    49313365.3    50603936.0  +2.6%  BAD
                        T9233(normal) ghc/alloc   704944258.7   685692712.0  -2.7% GOOD
                        T9630(normal) ghc/alloc  1476621560.0  1455192784.0  -1.5%
                        T9675(optasm) ghc/alloc   443183173.3   433859696.0  -2.1% GOOD
                       T9872a(normal) ghc/alloc  1720926653.3  1693190072.0  -1.6% GOOD
                       T9872b(normal) ghc/alloc  2185618061.3  2162277568.0  -1.1% GOOD
                       T9872c(normal) ghc/alloc  1765842405.3  1733618088.0  -1.8% GOOD
         TcPlugin_RewritePerf(normal) ghc/alloc  2388882730.7  2365504696.0  -1.0%
                        WWRec(normal) ghc/alloc   607073186.7   597512216.0  -1.6%
      
                        T9203(normal) run/alloc   107284064.0   102881832.0  -4.1%
                haddock.Cabal(normal) run/alloc 24025329589.3 23768382560.0  -1.1%
                 haddock.base(normal) run/alloc 25660521653.3 25370321824.0  -1.1%
             haddock.compiler(normal) run/alloc 74064171706.7 73358712280.0  -1.0%
      ```
      The biggest exception to the rule is T13701 which seems to fluctuate as usual
      (not unlike T12545). T14697 has a similar quality, being a generated
      multi-module test. T5837 is small enough that it similarly doesn't measure
      anything significant besides module loading overhead.
      T13253 simply does one additional round of Simplification due to Nested CPR.
      
      There are also some apparent regressions in T9198, T12234 and PmSeriesG that we
      (@mpickering and I) were simply unable to reproduce locally. @mpickering tried
      to run the CI script in a local Docker container and actually found that T9198
      and PmSeriesG *improved*. In MRs that were rebased on top this one, like !4229,
      I did not experience such increases. Let's not get hung up on these regression
      tests, they were meant to test for asymptotic regressions.
      
      The build-cabal test improves by 1.2% in -O0.
      
      Metric Increase:
          T10421
          T12234
          T12545
          T13035
          T13056
          T13701
          T14697
          T18923
          T5837
          T9198
      Metric Decrease:
          ManyConstructors
          T12545
          T12707
          T13056
          T14683
          T16577
          T18223
          T1969
          T3294
          T9203
          T9233
          T9675
          T9872a
          T9872b
          T9872c
          T9961
          TcPlugin_RewritePerf
      c261f220
    • Matthew Pickering's avatar
      testsuite: Make cabal01 more robust to large environments · 594ee2f4
      Matthew Pickering authored and Marge Bot's avatar Marge Bot committed
      Sebastian unfortunately wrote a very long commit message in !5667 which
      caused `xargs` to fail on windows because the environment was too big.
      Fortunately `xargs` and `rm` don't need anything from the environment so
      just run those commands in an empty environment (which is what env -i
      achieves).
      594ee2f4
  7. Sep 29, 2021
  8. Sep 28, 2021
  9. Sep 23, 2021
Loading