[Git][ghc/ghc][wip/andreask/9.10-backports] 14 commits: Fix nasty bug in occurrence analyser

Andreas Klebinger (@AndreasK) gitlab at gitlab.haskell.org
Tue Jan 14 11:11:56 UTC 2025



Andreas Klebinger pushed to branch wip/andreask/9.10-backports at Glasgow Haskell Compiler / GHC


Commits:
081a9d84 by Simon Peyton Jones at 2025-01-14T11:52:50+01:00
Fix nasty bug in occurrence analyser

As #25096 showed, the occurrence analyser was getting one-shot info
flat out wrong.

This commit does two things:

* It fixes the bug and actually makes the code a bit tidier too.
  The work is done in the new function
     GHC.Core.Opt.OccurAnal.mkRhsOccEnv,
  especially the bit that prepares the `occ_one_shots` for the RHS.

  See Note [The OccEnv for a right hand side]

* When floating out a binding we must be conservative about one-shot
  info.  But we were zapping the entire demand info, whereas we only
  really need zap the /top level/ cardinality.

  See Note [Floatifying demand info when floating]
  in GHC.Core.Opt.SetLevels

For some reason there is a 2.2% improvement in compile-time allocation
for CoOpt_Read.  Otherwise nickels and dimes.

Metric Decrease:
    CoOpt_Read

(cherry picked from commit f6b4c1c9be71fc6fe4688337752ffa4ad84180d9)

- - - - -
576b792a by Arnaud Spiwack at 2025-01-14T11:52:52+01:00
Add tests for 25081

(cherry picked from commit e2f2a56e42d25bae178ae1692390bbbd6275176c)

- - - - -
e39886ac by Arnaud Spiwack at 2025-01-14T11:52:52+01:00
Scale multiplicity in list comprehension

Fixes #25081

(cherry picked from commit 23f50640e705c132f1a0689d4850866d0f0d76a6)

- - - - -
ddaa0928 by doyougnu at 2025-01-14T11:52:52+01:00
Rts linker: add case for pc-rel 64 relocation

part of the upstream haskell.nix patches

(cherry picked from commit bfe4b3d3bbb98b39169fad063c6c32f06d167756)

- - - - -
affa91f7 by Sylvain Henry at 2025-01-14T11:52:52+01:00
Only lookup ghcversion.h file in the RTS include-dirs by default.

The code was introduced in 3549c952b535803270872adaf87262f2df0295a4.
It used `getPackageIncludePath` which name doesn't convey that it looks
into all include paths of the preload units too. So this behavior is
probably unintentional and it should be ok to change it.

Fix #25106

(cherry picked from commit f954f42823f6ca3588425a0d543d93ace86d89e4)

- - - - -
e94a2403 by Andreas Klebinger at 2025-01-14T11:52:52+01:00
Add since annotation for -fkeep-auto-rules.

This partially addresses #25082.

- - - - -
b063ab38 by Andreas Klebinger at 2025-01-14T11:52:52+01:00
Mention `-fkeep-auto-rules` in release notes.

It was added earlier but hadn't appeared in any release notes yet.
Partially addresses #25082.

- - - - -
f2ed1384 by Sylvain Henry at 2025-01-14T11:52:52+01:00
Cmm: don't perform unsound optimizations on 32-bit compiler hosts

- beef61351b240967b49169d27a9a19565cf3c4af enabled the use of
  MO_Add/MO_Sub for 64-bit operations in the C and LLVM backends
- 6755d833af8c21bbad6585144b10e20ac4a0a1ab did the same for the x86 NCG
  backend

However we store some literal values as `Int` in the compiler. As a
result, some Cmm optimizations transformed target 64-bit literals into
compiler `Int`. If the compiler is 32-bit, this leads to computing with
wrong literals (see #24893 and #24700).

This patch disables these Cmm optimizations for 32-bit compilers. This
is unsatisfying (optimizations shouldn't be compiler-word-size
dependent) but it fixes the bug and it makes the patch easy to backport.
A proper fix would be much more invasive but it shall be implemented in
the future.

Co-authored-by: amesgen <amesgen at amesgen.de>
(cherry picked from commit 7446a09a2d5b04b95cd43c03659b5647853124ce)

- - - - -
145db9c8 by Sylvain Henry at 2025-01-14T11:52:52+01:00
AARCH64 linker: skip NONE relocations

This patch is part of the patches upstreamed from haskell.nix.
See https://github.com/input-output-hk/haskell.nix/pull/1960 for the
original report/patch.

(cherry picked from commit c749bdfd3e21d712dc2b966482eb010165bdeebe)

- - - - -
a777e025 by sheaf at 2025-01-14T11:52:52+01:00
GHCi debugger: drop record name spaces for Ids

When binding new local variables at a breakpoint, we should create
Ids with variable namespace, and not record field namespace. Otherwise
the rest of the compiler falls over because the IdDetails are wrong.

Fixes #25109

(cherry picked from commit c29b2b5a77611b2bd6c3089765079bc43aec3e22)

- - - - -
e1ce9a5b by Sylvain Henry at 2025-01-14T11:52:52+01:00
JS: support rubbish static literals (#25177)

Support for rubbish dynamic literals was added in #24664. This patch
does the same for static literals.

Fix #25177

(cherry picked from commit 5092dbff750ee5b6fd082b7eed8574922a2b0bf4)

- - - - -
ff90f78f by Arsen Arsenović at 2025-01-14T11:52:52+01:00
ghc-toolchain: Don't leave stranded a.outs when testing for -g0

This happened because, when ghc-toolchain tests for -g0, it does so by
compiling an empty program.  This compilation creates an a.out.

Since we create a temporary directory, lets place the test program
compilation in it also, so that it gets cleaned up.

Fixes: 25b0b40467d0a12601497117c0ad14e1fcab0b74
Closes: https://gitlab.haskell.org/ghc/ghc/-/issues/25203
(cherry picked from commit b16605e7c135f8cfd357a60c7f358132faec6a84)

- - - - -
82b35198 by Cheng Shao at 2025-01-14T11:52:53+01:00
rts: fix checkClosure error message

This patch fixes an error message in checkClosure() when the closure
has already been evacuated. The previous logic was meant to print the
evacuated closure's type in the error message, but it was completely
wrong, given info was not really an info table, but a tagged pointer
that points to the closure's new address.

(cherry picked from commit 0d3bc2fa3a9a8c342ec34bb9d32e493655a4ec69)

- - - - -
c9479053 by Simon Peyton Jones at 2025-01-14T11:52:53+01:00
Add ZonkAny and document it

This MR fixed #24817 by adding ZonkAny, which takes a Nat
argument.

See Note [Any types] in GHC.Builtin.Types, especially
wrinkle (Any4).

(cherry picked from commit cfbff65a8bde902b4510cdaead847bf7a52b4018)

- - - - -


30 changed files:

- compiler/GHC/Builtin/Names.hs
- compiler/GHC/Builtin/Types.hs
- compiler/GHC/Cmm/Opt.hs
- compiler/GHC/Core/Opt/DmdAnal.hs
- compiler/GHC/Core/Opt/OccurAnal.hs
- compiler/GHC/Core/Opt/SetLevels.hs
- compiler/GHC/Core/Opt/Simplify/Iteration.hs
- compiler/GHC/Core/Opt/Specialise.hs
- compiler/GHC/Runtime/Eval.hs
- compiler/GHC/StgToJS/Literal.hs
- compiler/GHC/SysTools/Cpp.hs
- compiler/GHC/Tc/Gen/Match.hs
- compiler/GHC/Tc/Types.hs
- compiler/GHC/Tc/Utils/Monad.hs
- compiler/GHC/Tc/Zonk/Type.hs
- compiler/GHC/Types/Demand.hs
- compiler/GHC/Types/Id.hs
- compiler/GHC/Types/Id/Info.hs
- compiler/GHC/Utils/Outputable.hs
- docs/users_guide/9.10.2-notes.rst
- docs/users_guide/using-optimisation.rst
- rts/linker/PEi386.c
- rts/linker/elf_reloc_aarch64.c
- rts/sm/Sanity.c
- + testsuite/tests/codeGen/should_compile/T25177.hs
- + testsuite/tests/codeGen/should_compile/T25177.stderr
- testsuite/tests/codeGen/should_compile/all.T
- + testsuite/tests/codeGen/should_run/T24700.hs
- + testsuite/tests/codeGen/should_run/T24700.stdin
- + testsuite/tests/codeGen/should_run/T24700.stdout


The diff was not included because it is too large.


View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d55abf10ff541174a0119f9e142ec4acaf2f2661...c9479053b7218e89c790916fa4a14b84cb289e9b

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d55abf10ff541174a0119f9e142ec4acaf2f2661...c9479053b7218e89c790916fa4a14b84cb289e9b
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/20250114/9aca7d32/attachment-0001.html>


More information about the ghc-commits mailing list