[Git][ghc/ghc][wip/marge_bot_batch_merge_job] 7 commits: Fix binder-swap bug

Marge Bot (@marge-bot) gitlab at gitlab.haskell.org
Tue Oct 25 18:47:15 UTC 2022



Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC


Commits:
b2d27c70 by Simon Peyton Jones at 2022-10-25T14:46:38-04:00
Fix binder-swap bug

This patch fixes #21229 properly, by avoiding doing a
binder-swap on dictionary Ids.  This is pretty subtle, and explained
in Note [Care with binder-swap on dictionaries].

Test is already in simplCore/should_run/T21229

This allows us to restore a feature to the specialiser that we had
to revert: see Note [Specialising polymorphic dictionaries].
(This is done in a separate patch.)

I also modularised things, using a new function scrutBinderSwap_maybe
in all the places where we are (effectively) doing a binder-swap,
notably

* Simplify.Iteration.addAltUnfoldings
* SpecConstr.extendCaseBndrs

In Simplify.Iteration.addAltUnfoldings I also eliminated a guard
    Many <- idMult case_bndr
because we concluded, in #22123, that it was doing no good.

- - - - -
956df847 by Simon Peyton Jones at 2022-10-25T14:46:38-04:00
Make the specialiser handle polymorphic specialisation

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

- - - - -
322d264c by Sylvain Henry at 2022-10-25T14:46:44-04:00
Numeric exceptions: replace FFI calls with primops

ghc-bignum needs a way to raise numerical exceptions defined in base
package. At the time we used FFI calls into primops defined in the RTS.
These FFI calls had to be wrapped into hacky bottoming functions because
"foreign import prim" syntax doesn't support giving a bottoming demand
to the foreign call (cf #16929).

These hacky wrapper functions trip up the JavaScript backend (#21078)
because they are polymorphic in their return type. This commit
replaces them with primops very similar to raise# but raising predefined
exceptions.

- - - - -
2169f093 by Sylvain Henry at 2022-10-25T14:46:48-04:00
Enable popcount rewrite rule when cross-compiling

The comment applies only when host's word size < target's word size.
So we can relax the guard.

- - - - -
d3ecc1cc by Sylvain Henry at 2022-10-25T14:46:54-04:00
Add GHC.SysTools.Cpp module

Move doCpp out of the driver to be able to use it in the upcoming JS backend.

- - - - -
1e99b38c by Ben Gamari at 2022-10-25T14:46:55-04:00
llvm-targets: Add datalayouts for big-endian AArch64 targets

Fixes #22311.

Thanks to @zeldin for the patch.

- - - - -
5b3ba5be by Krzysztof Gogolewski at 2022-10-25T14:46:56-04:00
Cleanup String/FastString conversions

Remove unused mkPtrString and isUnderscoreFS.
We no longer use mkPtrString since 1d03d8bef96.

Remove unnecessary conversions between FastString and String and back.

- - - - -


30 changed files:

- compiler/GHC/Builtin/Names.hs
- compiler/GHC/Builtin/primops.txt.pp
- compiler/GHC/Core/Make.hs
- compiler/GHC/Core/Opt/ConstantFold.hs
- compiler/GHC/Core/Opt/OccurAnal.hs
- compiler/GHC/Core/Opt/SetLevels.hs
- compiler/GHC/Core/Opt/Simplify/Env.hs
- compiler/GHC/Core/Opt/Simplify/Iteration.hs
- compiler/GHC/Core/Opt/SpecConstr.hs
- compiler/GHC/Core/Opt/Specialise.hs
- compiler/GHC/Core/Opt/Stats.hs
- compiler/GHC/Core/Subst.hs
- compiler/GHC/Core/Type.hs
- compiler/GHC/Data/FastString.hs
- compiler/GHC/Driver/Pipeline.hs
- compiler/GHC/Driver/Pipeline/Execute.hs
- compiler/GHC/Hs/Dump.hs
- compiler/GHC/HsToCore/Foreign/C.hs
- compiler/GHC/HsToCore/Pmc/Solver/Types.hs
- compiler/GHC/HsToCore/Quote.hs
- compiler/GHC/Parser.y
- compiler/GHC/Parser/HaddockLex.x
- compiler/GHC/Parser/PostProcess.hs
- compiler/GHC/StgToCmm/Prim.hs
- + compiler/GHC/SysTools/Cpp.hs
- compiler/GHC/Tc/Errors/Ppr.hs
- compiler/GHC/Types/CostCentre.hs
- compiler/GHC/Types/FieldLabel.hs
- compiler/GHC/Types/Literal.hs
- compiler/GHC/Types/Name/Occurrence.hs


The diff was not included because it is too large.


View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1eda29fd4740352139183b55eb8ac3c08e89df51...5b3ba5be2a5be789a3f4d70583e451995384cfc1

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1eda29fd4740352139183b55eb8ac3c08e89df51...5b3ba5be2a5be789a3f4d70583e451995384cfc1
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20221025/88c043e5/attachment-0001.html>


More information about the ghc-commits mailing list