[Git][ghc/ghc][wip/T20264] 95 commits: Remove TcRnDeprecatedInvisTyArgInConPat mechanism

Simon Peyton Jones (@simonpj) gitlab at gitlab.haskell.org
Sun Dec 15 17:06:17 UTC 2024



Simon Peyton Jones pushed to branch wip/T20264 at Glasgow Haskell Compiler / GHC


Commits:
5b4774f9 by sheaf at 2024-12-03T15:22:07+01:00
Remove TcRnDeprecatedInvisTyArgInConPat mechanism

The combination of ScopedTypeVariables + TypeApplications now no longer
enables the use of type applications in constructor patterns, as per
GHC proposal #448.

This completes the deprecation that begun with GHC 9.8.

We also remove the -Wdeprecated-type-abstractions flag, which was
introduced in GHC 9.10.

- - - - -
f813c8d7 by sheaf at 2024-12-03T17:10:15-05:00
Hadrian: use / when making filepaths absolute

In Hadrian, we are careful to use -/- rather than </>, in order to use
/ instead of \ in filepaths. However, this gets ruined by the use of
makeAbsolute from System.Directory, which, on Windows, changes back
forward slashes to backslashes.

- - - - -
292ed74e by Ben Gamari at 2024-12-03T17:10:52-05:00
rts/linker: Fix out-of-bounds mapping logic

Previously the structure of `mmapInRegion` concealed a subtle bug
concerning handling of `mmap` returning mappings below the beginning of
the desired region. Specifically, we would reset `p = result + bytes`
and then again reset `p = region->start` before looping around for
another iteration. This resulted in an infinite loop on FreeBSD.

Fixes #25492.

- - - - -
20912f5b by Ben Gamari at 2024-12-03T17:10:52-05:00
rts/linker: Clarify debug output

- - - - -
f98b3ac0 by Simon Hengel at 2024-12-03T17:11:30-05:00
SysTools: Avoid race conditions when processing output (fixes #16450)

- - - - -
03851b64 by Rodrigo Mesquita at 2024-12-03T17:12:06-05:00
mg: Drop unnecessary HasCallStack

This HasCallStack was a debugging artifact from a previous commit.

- - - - -
01d213b5 by Rodrigo Mesquita at 2024-12-03T17:12:06-05:00
Improve haddock of graphReachabilityCyclic

- - - - -
f7cbffe2 by Rodrigo Mesquita at 2024-12-03T17:12:06-05:00
Refactor ModuleGraph interface

The 'ModuleGraph' abstraction represents the relationship and strucutre
of the modules being compiled. This structure is meant to be constructed
once at the start of compilation, and never changed again.

However, it's exposed interface was confusing and exposed too many
footguns which led to inneficient usages of the ModuleGraph. This commit
improves significantly the exported interface of ModuleGraph, taking
into consideration the recent improvements around reachability queries.

Since the ModuleGraph graphs and related structures (HPT, EPS) are
performance critical in the sense that somewhat simple mistakes can
cause bad leaks and non-linear memory usage, we want to have proper APIs
that guide efficient usage. This is a good step in that direction.

- - - - -
b69a7f3c by David Binder at 2024-12-04T18:37:42-05:00
Use consistent capitalization for "GHC Proposal" in user guide

- - - - -
18d9500d by David Binder at 2024-12-04T18:37:42-05:00
Fix reference to GHC proposal 193 in user guide

- - - - -
dd959406 by Ben Gamari at 2024-12-04T18:38:18-05:00
Revert "rts/Interpreter: Assert that TEST*_P discriminators are valid"

This assertion was based on the misconception that `GET_TAG` was
returning the pointer tag whereas it is actually returning the
constructor tag.

This reverts commit 9bf3663b9970851e7b5701d68147450272823197.

Fixes #25527.

- - - - -
cad6fede by Ben Gamari at 2024-12-04T18:38:54-05:00
rts/IOManager: Drop dead code

This assignment is dead code as it occurs after all branches have
returned. Moreover, it can't possibly be relevant since the "available"
branch already sets `flag`.

Potentially fixes #25542.

- - - - -
55d8304e by Ben Gamari at 2024-12-06T16:56:00-05:00
ghc-internal: Drop GHC.Internal.Data.Enum

This module consists only of reexports and consequently there is no
reason for it to exist.

- - - - -
56b9f484 by Ben Gamari at 2024-12-06T16:56:00-05:00
base: Introduce Data.Bounded

As proposed in [CLC#208] but unfortunately `Data.Enum` was already
incorrectly introduced in the `ghc-internal` refactor.

[CLC#208]: https://github.com/haskell/core-libraries-committee/issues/208

- - - - -
336d392e by Ben Gamari at 2024-12-06T16:56:00-05:00
base: Deprecate export of Bounded from Data.Enum

This begins the process of bringing us into compliance with
[CLC#208].

[CLC#208]: https://github.com/haskell/core-libraries-committee/issues/208

- - - - -
dd7ca939 by Ben Gamari at 2024-12-06T16:56:00-05:00
base: Mention incorrect Data.Enum addition in changelog

- - - - -
dfd1db48 by Ben Gamari at 2024-12-06T16:56:36-05:00
base: Reintroduce {Show,Enum} IoSubSystem

These instances were dropped in !9676 but not approved by the CLC.

Addresses #25549.

- - - - -
090fc7c1 by Peter Trommler at 2024-12-07T03:41:21-05:00
Fix requirements on T25240

T25240 doesn't need RTS linker, GHCi is sufficient and GHCi can also be
dynamically linked.

- - - - -
3fb5d399 by Peter Trommler at 2024-12-07T03:41:21-05:00
Fix requirements for T25155

Loading C objects requires RTS linker.

- - - - -
4c58bdf6 by Leary at 2024-12-07T03:42:07-05:00
TH: Add typed variants of dataToExpQ and liftData

This commit introduces to template-haskell (via ghc-internal) two
functions `dataToCodeQ` and `liftDataTyped`, typed variants of
`dataToExpQ` and `liftData` respectively.

Tested in: `dataToCodeQUnit`.

- - - - -
63027593 by Serge S. Gulin at 2024-12-08T13:52:05+03:00
JS: Basic cleanup for unused stuff to simplify things.

1. Make `staticInitStat`, `staticDeclStat`, `allocUnboxedConStatic`, `allocateStaticList`, `jsStaticArg` local to modules.
2. Remove unused `hdRawStr`, `hdStrStr` from Haskell and JavaScript (`h$pstr`, `h$rstr`, `h$str`).
3. Introduce a special type `StaticAppKind` enumeration and `StaticApp` to represent boxed scalar static applications. Originally, StaticThunk supported to pass Maybe when it became Nothing for initializied thunks in an alternatie way but it is not used anymore.

- - - - -
a9f8f1fb by Serge S. Gulin at 2024-12-08T14:10:45+03:00
JS: Add trivial optimizations for `unpackCString` and `unpackCStringUtf8`.

It became possible due of introduction strings unfloating at Sinker pass (#13185). Earns few more bytes at optimizations.

- - - - -
b519c06b by Serge S. Gulin at 2024-12-08T15:50:26+03:00
JS: Specialize unpackCString# CAFs (fixes #24744)

Code analysis shown that such optimization would be possible out of the box if `cachedIdentForId` allowed to do that for Haskell `Id`s which are represented by few JavaScript `Ident`s. It is a usual for strings which are represented at JavaScript as a pair of 2 values: the string content and the offset where to start reading actual string from the full content. Usually offset is 0 but technically we need to allow such complex structures to be treated as "global".

Enabling it there shown that `genToplevelRhs` and `globalOccs` had inaccuracies in their implementations:
1. `globalOccs` operated over JavaScript's `Ident`s but for complex structures it didn't pay attention to the fact that different Idents actually could be pointed to same Id. Now the algo is changed to calculate occurencies for Ids.
2. `genToplevelRhs` didn't assume that different Idents pointed to same Id can have mixed order of occurence. But actually the order is important. Strings are encoded into 2 variables where first is content and second is offset and their order are not interchangeable. It is fixed by regeneration Idents from collected Ids which is fine because all Idents generation is passed through the Cache and they are quasi-stable.

- - - - -
a8ceccf3 by Brandon Chinn at 2024-12-09T16:25:43-05:00
Fix panic in multiline string with unterminated gap (#25530)

- - - - -
9e464ad0 by Brandon Chinn at 2024-12-09T16:25:43-05:00
Add test case for unterminated multiline string

- - - - -
ed1ed5c6 by Rodrigo Mesquita at 2024-12-09T16:26:19-05:00
Revert mapMG renaming

We had previously renamed this function for consistency, but that caused unnecessary breakage

- - - - -
158261f7 by Sylvain Henry at 2024-12-09T16:27:01-05:00
RTS: make Cabal flags manual

Cabal shouldn't automatically try to set them. We set them explicitly.

- - - - -
a83b7ed6 by Matthew Stephenson at 2024-12-10T14:01:22-05:00
Add missing @since documentation for (!?) function
- - - - -
e745e3a3 by Ben Gamari at 2024-12-10T14:01:59-05:00
compiler: Don't attempt to TSAN-instrument SIMD operations

TSAN only provides instrumentation for 8, 16, 32, and 64-bit memory
loads/stores. Don't attempt to instrument wider operations.

Fixes #25563.

- - - - -
684c0018 by Ben Gamari at 2024-12-10T14:02:35-05:00
gitlab/ci: Don't clobber RUNTEST_ARGS

Previously the logic handling `IGNORE_PERF_FAILURES` clobbered the
user's `RUNTEST_ARGS`. Fix this.

- - - - -
41dae5b8 by Ben Gamari at 2024-12-10T14:03:11-05:00
hadrian: Mitigate mktexfmt race

At least some versions of Texlive's `mktexfmt` utility cannot be invoked
concurrently in their initial run since they fail to handle failure of
`mkdir` due to racing. Specifically, we see

```
| Run Xelatex: users_guide.tex => /tmp/extra-dir-9616886274866
| Run Xelatex: Haddock.tex => /tmp/extra-dir-9616886274869
This is XeTeX, Version 3.14159265-2.6-0.999992 (TeX Live 2020) (preloaded format=xelatex)
 restricted \write18 enabled.
kpathsea: Running mktexfmt xelatex.fmt
mktexfmt: mktexfmt is using the following fmtutil.cnf files (in precedence order):
mktexfmt:   /usr/share/texlive/texmf-dist/web2c/fmtutil.cnf
mktexfmt: mktexfmt is using the following fmtutil.cnf file for writing changes:
mktexfmt:   /builds/ghc/ghc/tmp-home/.texlive2020/texmf-config/web2c/fmtutil.cnf
/usr/bin/mktexfmt: mkdir(/builds/ghc/ghc/tmp-home/.texlive2020/texmf-var/web2c/) failed for tree /builds/ghc/ghc/tmp-home/.texlive2020/texmf-var/web2c: File exists at /usr/share/texlive/tlpkg/TeXLive/TLUtils.pm line 937.
I can't find the format file `xelatex.fmt'!
```

That is two `mktexfmt` invocations (for the user's guide and haddock
builds) attempted to create `$HOME/texlive2020/texmf-var/web2c` and
raced. One of the two `mkdir`'s consequently failed, bringing down the
entire build.

We avoid this by ensuring that the first `xelatex` invocation is always
performed serially.

Fixes #25564.

- - - - -
9efbc51f by Ben Gamari at 2024-12-10T14:03:48-05:00
rts/CheckUnload: Reset old_objects if unload is skipped

Previously `checkUnload` failed to reset `old_objects` when it decided
not to unload (e.g. due to heap profiling being enabled).

Fixes #24935.

- - - - -
5192a75f by Ben Gamari at 2024-12-11T04:28:11-05:00
rts: Annotate BCOs with their Name

This introduces a new bytecode instruction, `BCO_NAME`, to aid in debugging
bytecode execution. This instruction is injected by `mkProtoBCO` and
captures the Haskell name of the BCO. It is then printed by the
disassembler, allowing ready correlation with STG dumps.

- - - - -
99225996 by Ben Gamari at 2024-12-11T04:28:48-05:00
configure: Implement ld override whitelist

Bring `configure` into alignment with `ghc-toolchain`, ensuring that the
ld-override logic will only take effect on Linux and Windows.

Fixes #25501.

- - - - -
4a8fc928 by Ben Gamari at 2024-12-11T12:33:42+00:00
testsuite: Unmark T14028 as broken on FreeBSD

This now appears to pass on FreeBSD 14.

Closes #19723.

- - - - -
d7c0eb5a by Ben Gamari at 2024-12-11T12:33:42+00:00
gitlab-ci: Migrate FreeBSD runner tag to FreeBSD 14

- - - - -
7246dacc by Ben Gamari at 2024-12-11T12:33:42+00:00
gitlab-ci: Reintroduce FreeBSD 14 job

- - - - -
4af936da by Ben Gamari at 2024-12-11T12:33:42+00:00
gitlab-ci: Allow use of newer cabal-install bindists

Newer cabal-install bindists have internal directory structure.
Here we detect and account for the presence of such structure.

- - - - -
cbf38c1b by Ben Gamari at 2024-12-11T12:33:42+00:00
gitlab-ci: Enable documentation build on FreeBSD 14

- - - - -
d68107fb by Ben Gamari at 2024-12-11T12:33:42+00:00
gitlab-ci: Use system libffi on FreeBSD

- - - - -
fea3b590 by Ben Gamari at 2024-12-11T12:33:42+00:00
testsuite: Mark linker_unload as broken on FreeeBSD

Due to #25491.

- - - - -
ccf171ee by Ben Gamari at 2024-12-11T12:33:42+00:00
gitlab-ci: Prefer system toolchain on FreeBSD

It's not uncommon to find machines with gcc installed via ports. We
should be using the system's default clang-based toolchain instead.

- - - - -
cfb34738 by Ben Gamari at 2024-12-11T12:33:42+00:00
testsuite: Mark T21969 as broken on FreeBSD

Due to #25512.

- - - - -
0b64e37c by Ben Gamari at 2024-12-11T12:33:42+00:00
testsuite: Mark RestartEventLogging as broken on FreeBSD

I am seeing this fail quite reproducibly.

Due to #19724.

- - - - -
3b412019 by Ben Gamari at 2024-12-11T12:33:42+00:00
testsuite: Mark T16180 as "broken" on FreeBSD

Sadly we in fact need to skip it as it merely times out during
compilation.

See #14012.

- - - - -
57e3cab5 by Ben Gamari at 2024-12-11T12:33:42+00:00
testsuite: Skip T16992 unless in slow speed

This test has extraordinary memory requirements and tests a rather
niche aspect of the compact region mechanism. It has been suggested
multiple times that we shouldn't run it in the default testsuite
configuration. Finally implement this.

See #21890.
See #21892.

- - - - -
f08a72eb by Ben Gamari at 2024-12-11T19:30:54-05:00
rts(setNumCapabilities): Assert that n_caps < MAX_N_CAPS

It was noticed in #25560 that this would previously be allowed,
resulting in a segfault.

I will add a proper exception in `base` in a future commit.

- - - - -
e10d31ad by Ben Gamari at 2024-12-11T19:30:55-05:00
ghc-internal: Fix inconsistent FFI import types

The foreign imports of `enabled_capabilities` and
`getNumberOfProcessors` were declared as `CInt` whereas they are defined
as `uint32_t`.

- - - - -
06265655 by Ben Gamari at 2024-12-11T19:30:55-05:00
rts: Mention maximum capability count in users guide

Addresses #25560.

- - - - -
d488470b by Ben Gamari at 2024-12-11T19:30:55-05:00
rts/Capability: Move induction variable declaration into `for`s

Just a stylistic change.

- - - - -
71f050b7 by Ben Gamari at 2024-12-11T19:30:55-05:00
rts: Determine max_n_capabilities at RTS startup

Previously the maximum number of capabilities supported by the RTS was
statically capped at 256. However, this bound is uncomfortably low given
the size of today's machine.

While supporting unbounded, fully-dynamic adjustment would be nice, it
is complex and so instead we do something simpler: Probe the logical
core count at RTS startup and use this as the static bound for the rest
of our execution.

This should avoid users running into the capability limit on large
machines while avoiding wasting memory on a large capabilities array for
most users and keeping complexity at bay.

Addresses #25560.

- - - - -
1e84b411 by Ben Gamari at 2024-12-11T19:30:55-05:00
testsuite: Introduce req_c_rts

As suggested by @hsyl20, this is intended to mark tests that rely on the
behavior of the C RTS.

- - - - -
683115a4 by Ben Gamari at 2024-12-11T19:30:55-05:00
testsuite: Add test for #25560

- - - - -
ef2052a8 by Ben Gamari at 2024-12-12T04:42:32-05:00
testsuite: Only run T14497_compact in normal way

This test targets the compacting GC so it makes little sense to run it
across all ways. Moreover, it outright conflicts with the `nonmoving`
way.

- - - - -
34d3e8e6 by Ben Gamari at 2024-12-12T04:43:08-05:00
rts/CheckUnload: Don't prepare to unload if we can't unload

Previously `prepareUnloadCheck` would move the `objects` list to
`old_objects` even when profiling (where we cannot unload). This caused
us to vacate the `objects` list during major GCs, losing track of loaded
objects. Fix this by ensuring that `prepareUnloadCheck` and
`checkUnload` both use the same short-cutting logic.

- - - - -
9c53489d by Andrei Borzenkov at 2024-12-12T15:06:42-05:00
Update GHCi :info type declaration printing (#24459)

- Do not print result's kind in type families
  because we have full kind in SAKS and we display
  invisible arity using @-binders

- Do not suppress significant invisible binders

An invisible binder is considered significant when it meets at least
one of the following two criteria:
  - It visibly occurs in the declaration's body
  - It is followed by a significant binder,
    so it affects positioning
For non-generative type declarations (type synonyms and type families)
there is one additional criterion:
  - It is not followed by a visible binder, so it
    affects the arity of a type synonym

See Note [Print invisible binders in interface declarations]
for more information about what is "visibly occurs"

- - - - -
13fe48d4 by Matthew Pickering at 2024-12-12T15:07:19-05:00
typechecker: Perform type family consistency checks in topological order

Consider a module M importing modules A, B and C.

We can waste a lot of work depending on the order that the modules are
checked for family consistency.

Consider that C imports A and B. When compiling C we must have already
checked A and B for consistency, therefore if C is processed first then
A and B will not need to be checked for consistency again.

If A and B are compared first, then the consistency checks will be
performed against (wasted as we already performed them for C).

At the moment the order which modules are checked is non-deterministic.

Clearly we should engineer that C is checked before B and A, but by what
scheme?

A simple one is to observe that if a module M is in the transitive
closure of X then the size of the consistent family set of M is less
than or equal to size of the consistent family set of X.

Therefore by sorting the imports by the size of the consistent family
set and processing the largest first, you make sure to process modules
in topological order.

In practice we have observed that this strategy has reduced the amount
of consistency checks performed.

One solution to #25554

- - - - -
62a2b25f by Sylvain Henry at 2024-12-14T04:31:09-05:00
TNTC: set CmmProc entry_label properly (#25565)

Before this patch we were renaming the entry label of a CmmProc late in
the CmmToAsm pass. It led to inconsistencies and to some labels being
used in info tables but not being emitted (#25565).
Now we set the CmmProc entry label earlier in the StgToCmm monad and we
don't renamed it afterwards.

- - - - -
b339e7c3 by Simon Hengel at 2024-12-14T04:31:47-05:00
Make filter functionality for system tools line-based

This is more efficient as:

- All existing filter functions were line-based anyway.  They broke up
  the input into lines and then joined it back together.
- We already break up the output from system tools into lines when
  processing it.

Splitting up the output of system tools once and then filtering and
processing it reduces both code and runtime complexity.

- - - - -
39669077 by Simon Hengel at 2024-12-14T04:31:47-05:00
Refactoring: Don't use a `Chan` when parsing SysTools output

- - - - -
3e1e9438 by Simon Peyton Jones at 2024-12-14T23:00:05+00:00
Improve GHC build times

Two small changes

* In GHC.Data.Unboxed, never omit interface pragmas.  In "fast builds"
  one might omit them generally, but doing so gives very bad
  performance for code that imports this module.

* In GHC.Hs.Dump don't do type-class specialisation.  For some reason
  it goes mad and generates vast amounts of useless code.  See #25463.

- - - - -
b507e652 by Simon Peyton Jones at 2024-12-14T23:00:05+00:00
Refactor Lint

Refactor Lint for two reasons:

* To improve performance
* To prepare for type-lets

The big changes are all in GHC.Core.Lint:

* Change the main APIs:
  * `lintType` returns nothing rather than returning a `LintedType`;
  * `lintCoercion` return nothing rather than returning a `LintedCoercion`
  Reason: these functions did a lot of allocation to return a substituted
  type/coercion that was often discarded, or used only to extract its kind.

  Instead we now return nothing, and, when needed, extract the kind and
  substitute.

* Applications are treated as a whole, by `lintApp`.  By treating
  multiple arguments all at once we avoid performing multiple
  substitutions, each substituting a single type variable. This can
  make an absolutely huge difference.

Overall this led to a pretty massive rewrite of Lint, with many smaller
changes.

Smaller chnages elsewhere

* Rename `GHC.Core.TyCo.Subst.getSubstInScope` to `substInScopeSet` for consistency

* Define and use `GHC.Core.Type.liftedTypeOrConstraintKind`

Performance. This MR someimtes gives gives a very large improvement in
compile time, when Lint is on.  here is a selection of changes over 5%
in perf/compiler (with -dcore-lint)

      T25196                       -97.0%
      T14766                       -89.7%
      T14683                       -74.4%
      T5631                        -60.9%
      T20261                       -56.7%
      T18923                       -17.6%
      T13035                       -15.8%
      T6048                        -15.8%
      CoOpt_Read                   -14.4%
      T9630                        -10.9%
      T5642                         -7.3%

Eliminating the egregious offenders is a big win.

However, in some cases the compiler allocation /increases/. Here ae the
changes over 1%:

      T9961                          1.5%
      T8095                          2.8%
      T14052                         3.9%
      T12545                         4.5%
      T14052Type                     5.5%
      T5030                          8.0%
      T5321Fun                       8.3%
      T3064                         12.7%
      CoOpt_Singletons              15.6%
      T9198                         16.0%
      LargeRecord                   18.1%

I looked at the two biggest increases in compile-time bytes allocated.  Interestingly,
they both show substantial *decreases* in actual compile time, due to much smaller GC times.
I'm honestly not sure either why the allocation increases, or why the GC time decreases;
but I'm going to take the win!

    T9198
                 Baseline            With patch
    No Lint
      Alloc       44.6M              44.6M
      Mut time    0.23s              0.22s
      GC time     0.21s              0.21s

    With Lint
      Alloc       309M               360M
      Mut time    1.51s              0.85s
      GC time     2.97s              0.25s

    -------------------
    LargeRecord
                 Baseline            With patch
    No Lint
      Alloc       1.37G              1.37G
      Mut time    2.33s              2.33s
      GC time     2.40s              2.42s

    With Lint
      Alloc       3.4G               4.0G
      Mut time    6.02s              5.68s
      GC time     3.67s              3.03s

IMPORTANT NOTE: These changes don't show up in CI because in CI the
tests in perf/compiler are all run with -dcore-lint switched off.  I
gathered this data with some manual runs.

- - - - -
d82cd6a6 by Joseph Fourment at 2024-12-15T16:37:09+00:00
compiler: introduce type variable unfoldings

The plan for #20264 is to introduce let-bound types to have observable sharing in types.
To avoid the need to carry an environment when dealing with occurrences of these type variables,
we embed the types they're bound to (if any) in a `tv_unfolding :: Maybe Type` attribute.
This way, one can look through let-bound type variables using `coreView` and friends.
In particular, definitional equality looks through unfoldings.

- - - - -
296a6cc0 by Joseph Fourment at 2024-12-15T16:37:09+00:00
simple-opt: don't inline type-lets

- - - - -
952eddc5 by Joseph Fourment at 2024-12-15T16:37:09+00:00
specialise: fix type-lets in DFun unfoldings

During specialisation, a dictionary being specialised gets a new unfolding by turning
`DFun \ bndrs      -> MkD @<T1> ... @<Tm> <op1> ... <opn>` into
`DFun \ spec_bndrs -> MkD @((\ bndrs -> TYPE: <T1>) spec_args) ... ((\ bndrs -> <opn>) spec_args)`
which in turns gets beta-reduced into
`DFun \ spec_bndrs -> MkD (let { bndrs = spec_args } in TYPE: <T1>) ... (let { bndrs = spec_args } in <opn>)`.
Previously, such let binders would immediately be substituted into the type so it didn't cause any issue,
but now we want to avoid inlining.
Arguments of the form `let { bndrs = spec_args } in TYPE: <T1>` are not considered as type arguments since they're
not of the canonical form `TYPE: something`.
This commit restores the previous behavior of substituting the specialised type arguments.
Alternatively, we could attach some floated type bindings to `DFun`s.

- - - - -
f14dfa02 by Joseph Fourment at 2024-12-15T16:37:09+00:00
occur-anal: implement occurence analysis for type variables

In order to find out let-bound type variables that are used only once, in the hope of inlining them,
we need to track type variables as well in the occurrence analiser. Just like Id's, we attach an
`OccInfo` to each (immutable) type variable, and we walk into types and coercions to accurately gather
occurrences.

- - - - -
2013ad95 by Joseph Fourment at 2024-12-15T16:37:09+00:00
simplifier: don't inline type-lets

Keep propagating type-lets further down the pipeline, in the simplifier.
We also update CallArity, CprAnal, DmdAnal, WorkWrap, and Specialise to ignore type-lets.

- - - - -
953e3d95 by Joseph Fourment at 2024-12-15T16:37:09+00:00
prep: make type-lets pass through CorePrep

As a first attempt, ignore type-lets in CorePrep to avoid crashes.
However, this is not enough: CorePrep also does some let-floating.
If we don't float type-lets along with value-level let-bindings,
the latter can float out of the scope of a type variable in use.

- - - - -
2487bdaa by Joseph Fourment at 2024-12-15T16:37:09+00:00
simple-opt: fix simple_type_bind

Also:
- Inline small types using a new typeIsSmallEnoughToInline predicate
- Inline single-occurrence variables

- - - - -
14658926 by Joseph Fourment at 2024-12-15T16:37:09+00:00
simple-opt: make beta-reduction use simple_bind_type

- - - - -
f4bdf5a0 by Joseph Fourment at 2024-12-15T16:37:09+00:00
iface: add IfaceTypeLetBndr to represent non-top-level type-let binders

IfaceLetBndr isn't fit to represent type-let binders, as it includes a
bunch of vacuous flags for Ids only.
Instead of putting squares in circles, I added a new constructor for type binders.

The downside is that it breaks existing iface files, so since we can't bootstrap
yet so we have to bootstrap a cherry-picked branch and then checkout again to build
with --freeze1.

To avoid similar issues in the future, IfaceTyVarInfoItem serialises with a tag
despite there being only one constructor for now.

- - - - -
6fb97ab4 by Joseph Fourment at 2024-12-15T16:37:09+00:00
dmd-anal: prefix unused variable with _ to avoid warning

- - - - -
670bba04 by Joseph Fourment at 2024-12-15T16:37:09+00:00
type: inline unfoldView in sORTKind_maybe

- - - - -
696eb27f by Joseph Fourment at 2024-12-15T16:37:09+00:00
tidy: deal with type-lets

- - - - -
1b0329c9 by Joseph Fourment at 2024-12-15T16:37:09+00:00
notes: add Note [Type and coercion lets]

- - - - -
9c4937e5 by Joseph Fourment at 2024-12-15T16:37:10+00:00
notes: update Note [Comparing nullary type synonyms] to account for type variables

While updating backlinks, I noticed the optimisation for type variables
could be performed in more places.

- - - - -
89ab94e9 by Joseph Fourment at 2024-12-15T16:37:10+00:00
simplifier: inline single-occurring type-lets

- - - - -
09767789 by Joseph Fourment at 2024-12-15T16:37:10+00:00
cleanup: remove NOINLINE on tyVarOccInfo

- - - - -
f21d0aa3 by Simon Peyton Jones at 2024-12-15T16:37:10+00:00
Wibbles

- - - - -
53082465 by Simon Peyton Jones at 2024-12-15T16:37:10+00:00
Wibbles

- - - - -
fb5d0346 by Simon Peyton Jones at 2024-12-15T16:37:10+00:00
Progress

- - - - -
12b18e6a by Simon Peyton Jones at 2024-12-15T16:37:10+00:00
Progress

- - - - -
12e904c4 by Simon Peyton Jones at 2024-12-15T16:37:10+00:00
More progress

- - - - -
c862cec6 by Simon Peyton Jones at 2024-12-15T16:37:10+00:00
Progress

...doesn't compile though

- - - - -
d7944f3f by Simon Peyton Jones at 2024-12-15T16:37:10+00:00
Mostly working now

- - - - -
059771ad by Simon Peyton Jones at 2024-12-15T16:37:10+00:00
Aggressively create type-lets

- - - - -
01e210d5 by Simon Peyton Jones at 2024-12-15T16:37:10+00:00
more progress

- - - - -
054e3e28 by Simon Peyton Jones at 2024-12-15T16:37:10+00:00
More progress

- - - - -
31c066ea by Simon Peyton Jones at 2024-12-15T16:37:10+00:00
Temp debug printing

- - - - -
993f12c9 by Simon Peyton Jones at 2024-12-15T16:37:10+00:00
Remove bogus assert

- - - - -
886c462e by Simon Peyton Jones at 2024-12-15T16:37:10+00:00
Fix anoher couple of bugs

in SimpleOpt and exprIsTrivial

- - - - -
68bcd293 by Simon Peyton Jones at 2024-12-15T16:37:10+00:00
Improve zonking of foreign decls to avoid TcTyVars escaping

- - - - -
9676d828 by Simon Peyton Jones at 2024-12-15T16:37:11+00:00
Wibbles

- - - - -
dab8eb02 by Simon Peyton Jones at 2024-12-15T16:37:11+00:00
Some small wibbles

- - - - -
f0b157e3 by Simon Peyton Jones at 2024-12-15T16:37:11+00:00
Improvements

- - - - -


20 changed files:

- .gitlab/ci.sh
- .gitlab/generate-ci/gen_ci.hs
- .gitlab/jobs.yaml
- compiler/GHC/ByteCode/Asm.hs
- compiler/GHC/ByteCode/Instr.hs
- compiler/GHC/Cmm/ThreadSanitizer.hs
- compiler/GHC/CmmToAsm/X86/Ppr.hs
- compiler/GHC/Core.hs
- compiler/GHC/Core/Coercion.hs
- compiler/GHC/Core/Coercion/Axiom.hs
- compiler/GHC/Core/FVs.hs
- compiler/GHC/Core/Lint.hs
- compiler/GHC/Core/Make.hs
- compiler/GHC/Core/Opt/Arity.hs
- compiler/GHC/Core/Opt/CSE.hs
- compiler/GHC/Core/Opt/CallArity.hs
- compiler/GHC/Core/Opt/CprAnal.hs
- compiler/GHC/Core/Opt/DmdAnal.hs
- compiler/GHC/Core/Opt/FloatIn.hs
- compiler/GHC/Core/Opt/OccurAnal.hs


The diff was not included because it is too large.


View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1cf19e53374cf9bace9fcf4a0dacf08c959fbd6a...f0b157e369afdf77577bb00b9baf61c6ca4d8318

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1cf19e53374cf9bace9fcf4a0dacf08c959fbd6a...f0b157e369afdf77577bb00b9baf61c6ca4d8318
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/20241215/06c9a4ee/attachment-0001.html>


More information about the ghc-commits mailing list