<feed xmlns='http://www.w3.org/2005/Atom'>
<title>delta/haskell.git, branch wip/T20749</title>
<subtitle>gitlab.haskell.org: ghc/ghc.git
</subtitle>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/haskell.git/'/>
<entry>
<title>Make DataCon workers strict in strict fields (#20749)</title>
<updated>2023-03-10T17:43:00+00:00</updated>
<author>
<name>Sebastian Graf</name>
<email>sebastian.graf@kit.edu</email>
</author>
<published>2023-01-31T16:16:01+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/haskell.git/commit/?id=c870da6a6309282b829748c9ac8bed72f295f1af'/>
<id>c870da6a6309282b829748c9ac8bed72f295f1af</id>
<content type='text'>
This patch tweaks `exprIsConApp_maybe`, `exprIsHNF` and friends, and Demand
Analysis so that they exploit and maintain strictness of DataCon workers. See
`Note [Strict fields in Core]` for details.

Very little needed to change, and it puts field seq insertion done by Tag
Inference into a new perspective: That of *implementing* strict field semantics.
Before Tag Inference, DataCon workers are strict. Afterwards they are
effectively lazy and field seqs happen around use sites. History has shown
that there is no other way to guarantee taggedness and thus the STG Strict Field
Invariant.

Knock-on changes:

  * `exprIsHNF` previously used `exprOkForSpeculation` on unlifted arguments
    instead of recursing into `exprIsHNF`. That regressed the termination
    analysis in CPR analysis (which simply calls out to `exprIsHNF`), so I made
    it call `exprOkForSpeculation`, too.

  * There's a small regression in Demand Analysis, visible in the changed test
    output of T16859: Previously, a field seq on a variable would give that
    variable a "used exactly once" demand, now it's "used at least once",
    because `dmdTransformDataConSig` accounts for future uses of the field
    that actually all go through the case binder (and hence won't re-enter the
    potential thunk). The difference should hardly be observable.

  * The Simplifier's fast path for data constructors only applies to lazy
    data constructors now. I observed regressions involving Data.Binary.Put's
    `Pair` data type.

  * Unfortunately, T21392 does no longer reproduce after this patch, so I marked
    it as "not broken" in order to track whether we regress again in the future.

Fixes #20749, the satisfying conclusion of an annoying saga (cf. the ideas
in #21497 and #22475).
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This patch tweaks `exprIsConApp_maybe`, `exprIsHNF` and friends, and Demand
Analysis so that they exploit and maintain strictness of DataCon workers. See
`Note [Strict fields in Core]` for details.

Very little needed to change, and it puts field seq insertion done by Tag
Inference into a new perspective: That of *implementing* strict field semantics.
Before Tag Inference, DataCon workers are strict. Afterwards they are
effectively lazy and field seqs happen around use sites. History has shown
that there is no other way to guarantee taggedness and thus the STG Strict Field
Invariant.

Knock-on changes:

  * `exprIsHNF` previously used `exprOkForSpeculation` on unlifted arguments
    instead of recursing into `exprIsHNF`. That regressed the termination
    analysis in CPR analysis (which simply calls out to `exprIsHNF`), so I made
    it call `exprOkForSpeculation`, too.

  * There's a small regression in Demand Analysis, visible in the changed test
    output of T16859: Previously, a field seq on a variable would give that
    variable a "used exactly once" demand, now it's "used at least once",
    because `dmdTransformDataConSig` accounts for future uses of the field
    that actually all go through the case binder (and hence won't re-enter the
    potential thunk). The difference should hardly be observable.

  * The Simplifier's fast path for data constructors only applies to lazy
    data constructors now. I observed regressions involving Data.Binary.Put's
    `Pair` data type.

  * Unfortunately, T21392 does no longer reproduce after this patch, so I marked
    it as "not broken" in order to track whether we regress again in the future.

Fixes #20749, the satisfying conclusion of an annoying saga (cf. the ideas
in #21497 and #22475).
</pre>
</div>
</content>
</entry>
<entry>
<title>Simplifier: Eta expand arguments (#23083)</title>
<updated>2023-03-10T17:26:17+00:00</updated>
<author>
<name>Sebastian Graf</name>
<email>sebastian.graf@kit.edu</email>
</author>
<published>2023-03-07T12:23:19+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/haskell.git/commit/?id=8ca0c05b598353177cec46d4a508ea725d282f09'/>
<id>8ca0c05b598353177cec46d4a508ea725d282f09</id>
<content type='text'>
Previously, we'd only eta expand let bindings and lambdas,
now we'll also eta expand arguments such as in T23083:
```hs
g f h = f (h `seq` (h $))
```
Unless `-fpedantic-bottoms` is set, we'll now transform to
```hs
g f h = f (\eta -&gt; h eta)
```

Tweaking the Simplifier to eta-expand in args was a bit more painful than expected:

  * `tryEtaExpandRhs` and `findRhsArity` previously only worked on bindings.
    But eta expansion of non-recursive bindings is morally the same as eta
    expansion of arguments. And in fact the binder was never really looked at in
    the non-recursive case.
    I was able to make `findRhsArity` cater for both arguments and bindings, as
    well as have a new function `tryEtaExpandArg` that shares most of its code
    with that of `tryEtaExpandRhs`.

  * The Simplifier had a function `simplArg` that wasn't called in `rebuildCall`,
    which seems to be the main way to simplify args. Hence I consolidated the
    code path to call `simplArg`, too, renaming to `simplLazyArg`.

Fixes #23083.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Previously, we'd only eta expand let bindings and lambdas,
now we'll also eta expand arguments such as in T23083:
```hs
g f h = f (h `seq` (h $))
```
Unless `-fpedantic-bottoms` is set, we'll now transform to
```hs
g f h = f (\eta -&gt; h eta)
```

Tweaking the Simplifier to eta-expand in args was a bit more painful than expected:

  * `tryEtaExpandRhs` and `findRhsArity` previously only worked on bindings.
    But eta expansion of non-recursive bindings is morally the same as eta
    expansion of arguments. And in fact the binder was never really looked at in
    the non-recursive case.
    I was able to make `findRhsArity` cater for both arguments and bindings, as
    well as have a new function `tryEtaExpandArg` that shares most of its code
    with that of `tryEtaExpandRhs`.

  * The Simplifier had a function `simplArg` that wasn't called in `rebuildCall`,
    which seems to be the main way to simplify args. Hence I consolidated the
    code path to call `simplArg`, too, renaming to `simplLazyArg`.

Fixes #23083.
</pre>
</div>
</content>
</entry>
<entry>
<title>Simplifier: `countValArgs` should not count Type args (#23102)</title>
<updated>2023-03-10T17:26:17+00:00</updated>
<author>
<name>Sebastian Graf</name>
<email>sebastian.graf@kit.edu</email>
</author>
<published>2023-03-10T17:25:12+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/haskell.git/commit/?id=372ea02ec8dd9912bab799691905a30417e46de8'/>
<id>372ea02ec8dd9912bab799691905a30417e46de8</id>
<content type='text'>
I observed miscompilations while working on !10088 caused by this.

Fixes #23102.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
I observed miscompilations while working on !10088 caused by this.

Fixes #23102.
</pre>
</div>
</content>
</entry>
<entry>
<title>Fixes #19627.</title>
<updated>2023-03-09T14:52:45+00:00</updated>
<author>
<name>Apoorv Ingle</name>
<email>apoorv-ingle@uiowa.edu</email>
</author>
<published>2023-03-08T16:50:34+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/haskell.git/commit/?id=9ea719f2f1929bf2b789e4001f6c542a04185d61'/>
<id>9ea719f2f1929bf2b789e4001f6c542a04185d61</id>
<content type='text'>
Previously the solver failed with an unhelpful "solver reached too may iterations" error.
With the fix for #21909 in place we no longer have the possibility of generating such an error if we have `-fconstraint-solver-iteration` &gt; `-fgivens-fuel &gt; `-fwanteds-fuel`. This is true by default, and the said fix also gives programmers a knob to control how hard the solver should try before giving up.

This commit adds:
* Reference to ticket #19627 in the Note [Expanding Recursive Superclasses and ExpansionFuel]
* Test `typecheck/should_fail/T19627.hs` for regression purposes
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Previously the solver failed with an unhelpful "solver reached too may iterations" error.
With the fix for #21909 in place we no longer have the possibility of generating such an error if we have `-fconstraint-solver-iteration` &gt; `-fgivens-fuel &gt; `-fwanteds-fuel`. This is true by default, and the said fix also gives programmers a knob to control how hard the solver should try before giving up.

This commit adds:
* Reference to ticket #19627 in the Note [Expanding Recursive Superclasses and ExpansionFuel]
* Test `typecheck/should_fail/T19627.hs` for regression purposes
</pre>
</div>
</content>
</entry>
<entry>
<title>Delete created temporary subdirectories at end of session.</title>
<updated>2023-03-09T14:52:09+00:00</updated>
<author>
<name>Luite Stegeman</name>
<email>stegeman@gmail.com</email>
</author>
<published>2023-02-20T06:54:20+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/haskell.git/commit/?id=f97c7f6d96c58579d630bc883929afc3d45d5c2b'/>
<id>f97c7f6d96c58579d630bc883929afc3d45d5c2b</id>
<content type='text'>
This patch adds temporary subdirectories to the list of
paths do clean up at the end of the GHC session. This
fixes warnings about non-empty temporary directories.

Fixes #22952
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This patch adds temporary subdirectories to the list of
paths do clean up at the end of the GHC session. This
fixes warnings about non-empty temporary directories.

Fixes #22952
</pre>
</div>
</content>
</entry>
<entry>
<title>hadrian: Fix flavour compiler stage options off-by-one error</title>
<updated>2023-03-08T20:03:10+00:00</updated>
<author>
<name>Alexis King</name>
<email>lexi.lambda@gmail.com</email>
</author>
<published>2023-03-08T12:15:54+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/haskell.git/commit/?id=7c813d0688f03c782d3c3a93a8369a48b7e74c8d'/>
<id>7c813d0688f03c782d3c3a93a8369a48b7e74c8d</id>
<content type='text'>
!9193 pointed out that ghcDebugAssertions was supposed to be a predicate
on the stage of the built compiler, but in practice it was a predicate
on the stage of the compiler used to build. Unfortunately, while it
fixed that issue for ghcDebugAssertions, it documented every other
similar option as behaving the same way when in fact they all used the
old behavior.

The new behavior of ghcDebugAssertions seems more intuitive, so this
commit changes the interpretation of every other option to match. It
also improves the enableProfiledGhc and debugGhc flavour transformers by
making them more selective about which stages in which they build
additional library/RTS ways.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
!9193 pointed out that ghcDebugAssertions was supposed to be a predicate
on the stage of the built compiler, but in practice it was a predicate
on the stage of the compiler used to build. Unfortunately, while it
fixed that issue for ghcDebugAssertions, it documented every other
similar option as behaving the same way when in fact they all used the
old behavior.

The new behavior of ghcDebugAssertions seems more intuitive, so this
commit changes the interpretation of every other option to match. It
also improves the enableProfiledGhc and debugGhc flavour transformers by
making them more selective about which stages in which they build
additional library/RTS ways.
</pre>
</div>
</content>
</entry>
<entry>
<title>nonmoving: Non-concurrent collection</title>
<updated>2023-03-08T20:02:31+00:00</updated>
<author>
<name>Ben Gamari</name>
<email>ben@smart-cactus.org</email>
</author>
<published>2023-02-02T22:21:27+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/haskell.git/commit/?id=ba73a807edbb444c49e0cf21ab2ce89226a77f2e'/>
<id>ba73a807edbb444c49e0cf21ab2ce89226a77f2e</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>rts: Capture GC configuration in a struct</title>
<updated>2023-03-08T20:02:31+00:00</updated>
<author>
<name>Ben Gamari</name>
<email>ben@smart-cactus.org</email>
</author>
<published>2023-03-08T02:23:27+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/haskell.git/commit/?id=f6f12a36346e19de7eed330537350d0b7420764a'/>
<id>f6f12a36346e19de7eed330537350d0b7420764a</id>
<content type='text'>
The number of distinct arguments passed to GarbageCollect was getting a
bit out of hand.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The number of distinct arguments passed to GarbageCollect was getting a
bit out of hand.
</pre>
</div>
</content>
</entry>
<entry>
<title>testsuite: Skip T7160 in the nonmoving way</title>
<updated>2023-03-08T20:02:31+00:00</updated>
<author>
<name>Ben Gamari</name>
<email>ben@smart-cactus.org</email>
</author>
<published>2023-03-08T03:40:11+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/haskell.git/commit/?id=a57f12b3f06afe29cbbc6eb0a887bcbe319f17f6'/>
<id>a57f12b3f06afe29cbbc6eb0a887bcbe319f17f6</id>
<content type='text'>
Finalization order is different under the nonmoving collector.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Finalization order is different under the nonmoving collector.
</pre>
</div>
</content>
</entry>
<entry>
<title>testsuite: Mark ffi023 as broken due to #23089</title>
<updated>2023-03-08T20:02:31+00:00</updated>
<author>
<name>Ben Gamari</name>
<email>ben@smart-cactus.org</email>
</author>
<published>2023-03-08T03:33:46+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/haskell.git/commit/?id=f1fd3ffbdccf471c43f3c36d6ecb4bd5da33c097'/>
<id>f1fd3ffbdccf471c43f3c36d6ecb4bd5da33c097</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
</feed>
