[Git][ghc/ghc][ghc-9.6] 86 commits: rts: use performBlockingMajorGC in hs_perform_gc and fix ffi023

Zubin (@wz1000) gitlab at gitlab.haskell.org
Tue Sep 19 22:23:35 UTC 2023



Zubin pushed to branch ghc-9.6 at Glasgow Haskell Compiler / GHC


Commits:
1972f6b5 by Cheng Shao at 2023-09-05T18:01:27+05:30
rts: use performBlockingMajorGC in hs_perform_gc and fix ffi023

This patch does a few things:

- Add the missing RtsSymbols.c entry of performBlockingMajorGC
- Make hs_perform_gc call performBlockingMajorGC, which restores
  previous behavior
- Use hs_perform_gc in ffi023
- Remove rts_clearMemory() call in ffi023, it now works again in some
  test ways previously marked as broken. Fixes #23089

(cherry picked from commit b2d14d0b8ebb517139c08934a52791f21fe893f6)

- - - - -
fedc7d73 by sheaf at 2023-09-13T17:18:14+05:30
Propagate long-distance info in generated code

When desugaring generated pattern matches, we skip pattern match checks.
However, this ended up also discarding long-distance information, which
might be needed for user-written sub-expressions.

Example:

```haskell
okay (GADT di) cd =
  let sr_field :: ()
      sr_field = case getFooBar di of { Foo -> () }
  in case cd of { SomeRec _ -> SomeRec sr_field }
```

With sr_field a generated FunBind, we still want to propagate the outer
long-distance information from the GADT pattern match into the checks
for the user-written RHS of sr_field.

Fixes #23445

(cherry picked from commit fbc8e04e5d8fb05ff60568042802ab2fb34e1a70)

- - - - -
897b5689 by Richard Eisenberg at 2023-09-13T17:18:14+05:30
Don't suppress *all* Wanteds

Code in GHC.Tc.Errors.reportWanteds suppresses a Wanted if its
rewriters have unfilled coercion holes; see
Note [Wanteds rewrite Wanteds] in GHC.Tc.Types.Constraint.

But if we thereby suppress *all* errors that's really confusing,
and as #22707 shows, GHC goes on without even realising that the
program is broken. Disaster.

This MR arranges to un-suppress them all if they all get suppressed.

Close #22707

(cherry picked from commit 1ed573a53ee454db240b9fb1a17e28c97b6eb53a)

- - - - -
bd38bb14 by Luite Stegeman at 2023-09-13T17:18:14+05:30
Delete created temporary subdirectories at end of session.

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

(cherry picked from commit f97c7f6d96c58579d630bc883929afc3d45d5c2b)

- - - - -
0f4dfc0a by Matthew Pickering at 2023-09-13T17:18:14+05:30
Fix behaviour of -keep-tmp-files when used in OPTIONS_GHC pragma

This fixes the behaviour of -keep-tmp-files when used in an OPTIONS_GHC
pragma for files with module level scope.

Instead of simple not deleting the files, we also need to remove them
from the TmpFs so they are not deleted later on when all the other files
are deleted.

There are additional complications because you also need to remove the
directory where these files live from the TmpFs so we don't try to
delete those later either.

I added two tests.

1. Tests simply that -keep-tmp-files works at all with a single module
   and --make mode.
2. The other tests that temporary files are deleted for other modules
   which don't enable -keep-tmp-files.

Fixes #23339

(cherry picked from commit a24b83ddabac6b7eeb63db13884e4403f71375dd)

- - - - -
2423c854 by Matthew Pickering at 2023-09-13T17:18:14+05:30
withDeferredDiagnostics: When debugIsOn, write landmine into IORef to catch use-after-free.

Ticket #23305 reports an error where we were attempting to use the
logger which was created by withDeferredDiagnostics after its scope had
ended.

This problem would have been caught by this patch and a validate build:

```
+*** Exception: Use after free
+CallStack (from HasCallStack):
+  error, called at compiler/GHC/Driver/Make.hs:<line>:<column> in <package-id>:GHC.Driver.Make
```

This general issue is tracked by #20981

(cherry picked from commit dcf3288273d2418800e2dee97c937673a1d38a8f)

- - - - -
35e4c00c by Matthew Pickering at 2023-09-13T17:18:14+05:30
Don't return complete HscEnv from upsweep

By returning a complete HscEnv from upsweep the logger (as introduced by
withDeferredDiagnostics) was escaping the scope of
withDeferredDiagnostics and hence we were losing error messages.

This is reminiscent of #20981, which also talks about writing errors
into messages after their scope has ended.

See #23305 for details.

(cherry picked from commit 432c736c19446a011fca1f9485c67761c991bd42)

- - - - -
8ee3adf4 by Ryan Scott at 2023-09-13T17:18:14+05:30
Add regression test for #23143

!10541, the fix for #23323, also fixes #23143. Let's add a regression test to
ensure that it stays fixed.

Fixes #23143.

(cherry picked from commit 95b69cfb3d601eb3e6c5b1727c4cfef25ab87d68)

- - - - -
01cb005a by Simon Peyton Jones at 2023-09-13T17:18:14+05:30
Don't report redundant Givens from quantified constraints

This fixes #23323

See (RC4) in Note [Tracking redundant constraints]

(cherry picked from commit 2b0c9f5ef026df6dd2637aacce05a11d74146296)

- - - - -
bc04ca51 by Ben Gamari at 2023-09-13T17:18:14+05:30
nativeGen: Explicitly set flags of text sections on Windows

The binutils documentation (for COFF) claims,

> If no flags are specified, the default flags depend upon the section
> name. If the section name is not recognized, the default will be for the
> section to be loaded and writable.

We previously assumed that this would do the right thing for split
sections (e.g. a section named `.text$foo` would be correctly inferred
to be a text section). However, we have observed that this is not the
case (at least under the clang toolchain used on Windows): when
split-sections is enabled, text sections are treated by the assembler as
data (matching the "default" behavior specified by the documentation).

Avoid this by setting section flags explicitly. This should fix split
sections on Windows.

Fixes #22834.

(cherry picked from commit 3ece9856d157c85511d59f9f862ab351bbd9b38b)

- - - - -
3bc903b2 by Ben Gamari at 2023-09-13T17:18:14+05:30
nativeGen: Set explicit section types on all platforms

(cherry picked from commit db7f7240b53c01447e44d2790ee37eacaabfbcf3)

- - - - -
be64c6e6 by Ben Gamari at 2023-09-13T17:18:14+05:30
testsuite: Add tests for #23146

Both lifted and unlifted variants.

(cherry picked from commit 33cf4659f209ef8e97be188279216a2f4fe0cf51)

- - - - -
7f2f7ac1 by Ben Gamari at 2023-09-13T17:18:15+05:30
codeGen: Fix some Haddocks

(cherry picked from commit 76727617bccc88d1466ad6dc1442ab8ebb34f79a)

- - - - -
6eb8e32a by Ben Gamari at 2023-09-13T17:18:15+05:30
codeGen: Give proper LFInfo to datacon wrappers

As noted in `Note [Conveying CAF-info and LFInfo between modules]`,
when importing a binding from another module we must ensure that it gets
the appropriate `LambdaFormInfo` if it is in WHNF to ensure that
references to it are tagged correctly.

However, the implementation responsible for doing this,
`GHC.StgToCmm.Closure.mkLFImported`, only dealt with datacon workers and
not wrappers. This lead to the crash of this program in #23146:

    module B where

    type NP :: [UnliftedType] -> UnliftedType
    data NP xs where
      UNil :: NP '[]

    module A where
    import B

    fieldsSam :: NP xs -> NP xs -> Bool
    fieldsSam UNil UNil = True

    x = fieldsSam UNil UNil

Due to its GADT nature, `UNil` produces a trivial wrapper

    $WUNil :: NP '[]
    $WUNil = UNil @'[] @~(<co:1>)

which is referenced in the RHS of `A.x`. Due to the above-mentioned bug
in `mkLFImported`, the references to `$WUNil` passed to `fieldsSam` were
not tagged. This is problematic as `fieldsSam` expected its arguments to
be tagged as they are unlifted.

The fix is straightforward: extend the logic in `mkLFImported` to cover
(nullary) datacon wrappers as well as workers. This is safe because we
know that the wrapper of a nullary datacon will be in WHNF, even if it
includes equalities evidence (since such equalities are not runtime
relevant).

Thanks to @MangoIV for the great ticket and @alt-romes for his
minimization and help debugging.

Fixes #23146.

(cherry picked from commit 33a8c348cae5fd800c015fd8c2230b8066c7c0a4)

- - - - -
81f2cceb by Rodrigo Mesquita at 2023-09-13T17:18:15+05:30
codeGen: Fix LFInfo of imported datacon wrappers

As noted in #23231 and in the previous commit, we were failing to give a
an LFInfo of LFCon to a nullary datacon wrapper from another module,
failing to properly tag pointers which ultimately led to the
segmentation fault in #23146.

On top of the previous commit which now considers wrappers where we
previously only considered workers, we change the order of the guards so
that we check for the arity of the binding before we check whether it is
a constructor. This allows us to
(1) Correctly assign `LFReEntrant` to imported wrappers whose worker was
nullary, which we previously would fail to do
(2) Remove the `isNullaryRepDataCon` predicate:
    (a) which was previously wrong, since it considered wrappers whose
    workers had zero-width arguments to be non-nullary and would fail to
    give `LFCon` to them
    (b) is now unnecessary, since arity == 0 guarantees
        - that the worker takes no arguments at all
        - and the wrapper takes no arguments and its RHS must be an
          application of the worker to zero-width-args only.
        - we lint these two items with an assertion that the datacon
          `hasNoNonZeroWidthArgs`

We also update `isTagged` to use the new logic in determining the
LFInfos of imported Ids.

The creation of LFInfos for imported Ids and this detail are explained
in Note [The LFInfo of Imported Ids].

Note that before the patch to those issues we would already consider these
nullary wrappers to have `LFCon` lambda form info; but failed to re-construct
that information in `mkLFImported`

Closes #23231, #23146

(I've additionally batched some fixes to documentation I found while
investigating this issue)

(cherry picked from commit 2fc18e9e784ccc775db8b06a5d10986588cce74a)

- - - - -
9c99cd76 by Sebastian Graf at 2023-09-13T17:18:15+05:30
DmdAnal: Unleash demand signatures of free RULE and unfolding binders (#23208)

In #23208 we observed that the demand signature of a binder occuring in a RULE
wasn't unleashed, leading to a transitively used binder being discarded as
absent. The solution was to use the same code path that we already use for
handling exported bindings.

See the changes to `Note [Absence analysis for stable unfoldings and RULES]`
for more details.

I took the chance to factor out the old notion of a `PlusDmdArg` (a pair of a
`VarEnv Demand` and a `Divergence`) into `DmdEnv`, which fits nicely into our
existing framework. As a result, I had to touch quite a few places in the code.

This refactoring exposed a few small bugs around correct handling of bottoming
demand environments. As a result, some strictness signatures now mention uniques
that weren't there before which caused test output changes to T13143, T19969 and
T22112. But these tests compared whole -ddump-simpl listings which is a very
fragile thing to begin with. I changed what exactly they test for based on the
symptoms in the corresponding issues.

There is a single regression in T18894 because we are more conservative around
stable unfoldings now. Unfortunately it is not easily fixed; let's wait until
there is a concrete motivation before invest more time.

Fixes #23208.

(cherry picked from commit c30ac25f7dfaded58bb2ff85d4bffe662e4af8b1)

- - - - -
0d642d43 by Matthew Craven at 2023-09-13T17:18:15+05:30
StgToCmm: Upgrade -fcheck-prim-bounds behavior

Fixes #21054. Additionally, we can now check for range overlap
when generating Cmm for primops that use memcpy internally.

(cherry picked from commit 65a442fccd081d9370ae4ee4e74f116139b5c2c8)

- - - - -
fbeb839d by Ben Gamari at 2023-09-13T17:18:15+05:30
hadrian: Always canonicalize topDirectory

Hadrian's `topDirectory` is intended to provide an absolute path to the
root of the GHC tree. However, if the tree is reached via a symlink this

One question here is whether the `canonicalizePath` call is expensive
enough to warrant caching. In a quick microbenchmark I observed that
`canonicalizePath "."` takes around 10us per call; this seems
sufficiently low not to worry.

Alternatively, another approach here would have been to rather move the
canonicalization into `m4/fp_find_root.m4`. This would have avoided
repeated canonicalization but sadly path canonicalization is a hard
problem in POSIX shell.

Addresses #22451.

(cherry picked from commit 5efa9ca545d8d33b9be4fc0ba91af1db38f19276)

- - - - -
7ed005ca by aadaa_fgtaa at 2023-09-13T17:18:15+05:30
Optimise ELF linker (#23464)

- cache last elements of `relTable`, `relaTable` and `symbolTables` in `ocInit_ELF`
- cache shndx table in ObjectCode
- run `checkProddableBlock` only with debug rts

(cherry picked from commit b3e1436f968c0c36a27ea0339ee2554970b329fe)

- - - - -
7f9a10c7 by Ben Gamari at 2023-09-13T17:18:15+05:30
rts: Ensure that pinned allocations respect block size

Previously, it was possible for pinned, aligned allocation requests to
allocate beyond the end of the pinned accumulator block. Specifically,
we failed to account for the padding needed to achieve the requested
alignment in the "large object" check. With large alignment requests,
this can result in the allocator using the capability's pinned object
accumulator block to service a request which is larger than
`PINNED_EMPTY_SIZE`.

To fix this we reorganize `allocatePinned` to consistently account for
the alignment padding in all large object checks. This is a bit subtle
as we must handle the case of a small allocation request filling the
accumulator block, as well as large requests.

Fixes #23400.

(cherry picked from commit fd8c57694a00f6359bd66365f1284388c869ac60)

- - - - -
1f788005 by Ben Gamari at 2023-09-13T17:18:15+05:30
testsuite: Add test for #23400

(cherry picked from commit 98185d5212fb0464dcbcca0ca2c33326a7a002e8)

- - - - -
1ad2e1cd by Ben Gamari at 2023-09-13T17:18:15+05:30
base: Fix incorrect CPP guard

This was guarded on `darwin_HOST_OS` instead of `defined(darwin_HOST_OS)`.

(cherry picked from commit d7ef1704aeba451bd3e0efbdaaab2638ee1f0bc8)

- - - - -
8dae53e2 by Ben Gamari at 2023-09-13T17:18:15+05:30
rts/Trace: Ensure that debugTrace arguments are used

As debugTrace is a macro we must take care to ensure that
the fact is clear to the compiler lest we see warnings.

(cherry picked from commit 7c7d1f66d35f73a2faa898a33aa80cd276159dc2)

- - - - -
622b09a8 by Ben Gamari at 2023-09-13T17:18:15+05:30
rts: Various warnings fixes

(cherry picked from commit cb92051e3d85575ff6abd753c9b135930cc50cf8)

- - - - -
9cdd8f41 by Ben Gamari at 2023-09-13T17:18:15+05:30
hadrian: Ignore warnings in unix and semaphore-compat

(cherry picked from commit dec81dd1fd0475dde4929baae625d155387300bb)

- - - - -
686a86b0 by Moisés Ackerman at 2023-09-13T17:35:18+05:30
Add failing test case for #23492

(cherry picked from commit 6074cc3cda9b9836c784942a1aa7f766fb142787)

- - - - -
469da90f by Moisés Ackerman at 2023-09-13T17:35:18+05:30
Use generated src span for catch-all case of record selector functions

This fixes #23492. The problem was that we used the real source span
of the field declaration for the generated catch-all case in the
selector function, in particular in the generated call to
`recSelError`, which meant it was included in the HIE output. Using
`generatedSrcSpan` instead means that it is not included.

(cherry picked from commit 356a269258a50bf67811fe0edb193fc9f82dfad1)

- - - - -
ae8571ff by Matthew Pickering at 2023-09-13T17:35:18+05:30
Add -fpolymorphic-specialisation flag (off by default at all optimisation levels)

Polymorphic specialisation has led to a number of hard to diagnose
incorrect runtime result bugs (see #23469, #23109, #21229, #23445) so
this commit introduces a flag `-fpolymorhphic-specialisation` which
allows users to turn on this experimental optimisation if they are
willing to buy into things going very wrong.

Ticket #23469

(cherry picked from commit 9f01d14b5bc1c73828b2b061206c45b84353620e)

- - - - -
e90957af by Bryan Richter at 2023-09-13T17:35:18+05:30
Add missing void prototypes to rts functions

See #23561.

(cherry picked from commit 82ac6bf113526f61913943b911089534705984fb)

- - - - -
c1f910d0 by Ben Gamari at 2023-09-13T17:35:18+05:30
Define FFI_GO_CLOSURES

The libffi shipped with Apple's XCode toolchain does not contain a
definition of the FFI_GO_CLOSURES macro, despite containing references
to said macro. Work around this by defining the macro, following the
model of a similar workaround in OpenJDK [1].

[1] https://github.com/openjdk/jdk17u-dev/pull/741/files

(cherry picked from commit 8b35e8caafeeccbf06b7faa70e807028a3f0ff43)

- - - - -
36dc5121 by Ben Gamari at 2023-09-13T17:35:18+05:30
hadrian: Ensure that way-flags are passed to CC

Previously the way-specific compilation flags (e.g. `-DDEBUG`,
`-DTHREADED_RTS`) would not be passed to the CC invocations. This meant
that C dependency files would not correctly reflect
dependencies predicated on the way, resulting in the rather
painful #23554.

Closes #23554.

(cherry picked from commit cca74dab6809f8cf7ffc2ec9df689e06aa425110)

- - - - -
b6bf7b43 by Krzysztof Gogolewski at 2023-09-13T17:35:18+05:30
Fix #23567, a specializer bug

Found by Simon in https://gitlab.haskell.org/ghc/ghc/-/issues/23567#note_507834

The testcase isn't ideal because it doesn't detect the bug in master,
unless doNotUnbox is removed as in
https://gitlab.haskell.org/ghc/ghc/-/issues/23567#note_507692.
But I have confirmed that with that modification, it fails before
and passes afterwards.

(cherry picked from commit bf9b9de0685e23c191722dfdb78d28b44f1cba05)

- - - - -
2086ffb5 by Dave Barton at 2023-09-13T17:35:18+05:30
Fix some broken links and typos

(cherry picked from commit 4457da2a7dba97ab2cd2f64bb338c904bb614244)

- - - - -
62d117c3 by Bodigrim at 2023-09-13T17:35:18+05:30
Add since annotations for Data.Foldable1

(cherry picked from commit 054261dd319b505392458da7745e768847015887)

- - - - -
1aef9974 by Ben Gamari at 2023-09-13T17:35:18+05:30
rts/RtsSymbols: Add AArch64 outline atomic operations

Fixes #22012 by adding the symbols described in
https://github.com/llvm/llvm-project/blob/main/llvm/docs/Atomics.rst#libcalls-atomic.

Ultimately this would be better addressed by #22011, but this is a first
step in the right direction and fixes the immediate symptom.

Note that we dropped the `__arch64_cas16` operations as these provided
by all platforms's compilers. Also, we don't link directly against the
libgcc/compiler-rt definitions but rather provide our own wrappers to
work around broken toolchains (e.g. https://bugs.gentoo.org/868018).

Generated via https://gitlab.haskell.org/ghc/ghc/-/snippets/5733.

(cherry picked from commit 1aa5733a4480420fdc146322d86dd143321a3da6)

- - - - -
d09e1901 by Matthew Pickering at 2023-09-13T17:35:18+05:30
driver: Fix -S with .cmm files

There was an oversight in the driver which assumed that you would always
produce a `.o` file when compiling a .cmm file.

Fixes #23610

(cherry picked from commit 76983a0dca64dfb7e94aea0c4f494921f8513b41)

- - - - -
380c8328 by sheaf at 2023-09-13T17:35:19+05:30
Valid hole fits: don't panic on a Given

The function GHC.Tc.Errors.validHoleFits would end up panicking when
encountering a Given constraint. To fix this, it suffices to filter out
the Givens before continuing.

Fixes #22684

(cherry picked from commit 630e302617a4a3e00d86d0650cb86fa9e6913e44)

- - - - -
e7406e9e by Matthew Pickering at 2023-09-13T17:35:19+05:30
simplifier: Correct InScopeSet in rule matching

The in-scope set passedto the `exprIsLambda_maybe` call lacked all the
in-scope binders. @simonpj suggests this fix where we augment the
in-scope set with the free variables of expression which fixes this
failure mode in quite a direct way.

Fixes #23630

(cherry picked from commit 4f5538a8e2a8b9bc490bcd098fa38f6f7e9f4d73)

- - - - -
db6198a0 by Ben Gamari at 2023-09-13T17:35:19+05:30
rts/win32: Ensure reliability of IO manager shutdown

When the Win32 threaded IO manager shuts down, `ioManagerDie` sends an
`IO_MANAGER_DIE` event to the IO manager thread using the
`io_manager_event` event object. Finally, it will closes the event object,
and invalidate `io_manager_event`.

Previously, `readIOManagerEvent` would see that `io_manager_event` is
invalid and return `0`, suggesting that everything is right with the
world. This meant that if `ioManagerDie` invalidated the handle before
the event manager was blocked on the event we would end up in a
situation where the event manager would never realize it was asked to
shut down.

Fix this by ensuring that `readIOManagerEvent` instead returns
`IO_MANAGER_DIE` when we detect that the event object has been
invalidated by `ioManagerDie`.

Fixes #23691.

(cherry picked from commit 01db1117e18f140987f608a78f3e929242d6f00c)

- - - - -
48917633 by Ben Gamari at 2023-09-13T17:35:19+05:30
codeGen: Ensure that TSAN is aware of writeArray# write barriers

By using a proper release store instead of a fence.

(cherry picked from commit aca20a5d4fde1c6429c887624bb95c9b54b7af73)

- - - - -
aa375afc by Ben Gamari at 2023-09-13T17:35:19+05:30
codeGen: Ensure that array reads have necessary barriers

This was the cause of #23541.

(cherry picked from commit 453c0531f2edf49b75c73bc45944600d8d7bf767)

- - - - -
c728db01 by Ben Gamari at 2023-09-13T17:35:19+05:30
linker/PEi386: Don't sign-extend symbol section number

Previously we incorrectly interpreted PE section numbers as signed
values. However, this isn't the case; rather, it's an unsigned 16-bit number
with a few special bit-patterns (0xffff and 0xfffe). This resulted in #22941
as the linker would conclude that the sections were invalid.

Fixing this required quite a bit of refactoring.

Closes #22941.

(cherry picked from commit 0eb54c050e46f447224167166dd6d2805ca8cdf5)

- - - - -
f939a7f7 by Simon Peyton Jones at 2023-09-13T17:53:09+05:30
Look both ways when looking for quantified equalities

When looking up (t1 ~# t2) in the quantified constraints,
check both orientations.  Forgetting this led to #23333.

(cherry picked from commit 40c7daed0c971e58e86a8189f82f72e9213af8b6)

- - - - -
938a6614 by Krzysztof Gogolewski at 2023-09-18T10:07:51+05:30
Show an error when we cannot default a concrete tyvar

Fixes #23153

(cherry picked from commit 0da18eb79540181ae9835e73d52ba47ec79fff6b)
(cherry picked from commit 39574e3402ac33eb346e508da2667b9f337a590f)

- - - - -
fbcf62e8 by sheaf at 2023-09-18T15:26:52+05:30
Handle ConcreteTvs in inferResultToType

This patch fixes two issues.

  1. inferResultToType was discarding the ir_frr information, which meant
     some metavariables ended up being MetaTvs instead of ConcreteTvs.

     This function now creates new ConcreteTvs as necessary, instead of
     always creating MetaTvs.

  2. startSolvingByUnification can make some type variables concrete.
     However, it didn't return an updated type, so callers of this
     function, if they don't zonk, might miss this and accidentally
     perform a double update of a metavariable.

     We now return the updated type from this function, which avoids
     this issue.

Fixes #23154

(cherry picked from commit 9ab9b30ec1affe22b188f9a6637ac3bdea75bdba)

- - - - -
a650cd0a by Krzysztof Gogolewski at 2023-09-18T15:26:52+05:30
Use tcInferFRR to prevent bad generalisation

Fixes #23176

(cherry picked from commit 4b89bb54a1d1d6a7b30a6bbfd21eed5d85506813)

- - - - -
9aedbee5 by Sven Tennie at 2023-09-19T11:40:57+05:30
x86 Codegen: Implement MO_S_MulMayOflo for W16

(cherry picked from commit 6c88c2ba89b33a22793a168ad781a086eb110769)

- - - - -
dc2487ba by Sven Tennie at 2023-09-19T11:40:57+05:30
x86 CodeGen: MO_S_MulMayOflo better error message for rep > W64

It's useful to see which value made the pattern match fail. (If it ever
occurs.)

(cherry picked from commit 5f1154e0e3339dd1cabf7a7129337d8aa191fca7)

- - - - -
d2db0289 by Sven Tennie at 2023-09-19T11:40:57+05:30
x86 CodeGen: Implement MO_S_MulMayOflo for W8

This case wasn't handled before. But, the test-primops test suite showed
that it actually might appear.

(cherry picked from commit e8c9a95febf7b18476fec816effc95cb3fcb93de)

- - - - -
94db871c by Sven Tennie at 2023-09-19T11:40:57+05:30
Add test for %mulmayoflo primop

The test expects a perfect implementation with no false positives.

(cherry picked from commit a36f9dc94823c75fb789710bc67b92e87a630440)

- - - - -
86e43bdb by Ben Gamari at 2023-09-19T11:40:57+05:30
testsuite: Mark MulMayOflo_full as broken rather than skipping

To ensure that we don't accidentally fix it.

See #23742.

(cherry picked from commit fd7ce39c70f8922e26b8be8a5fc4d6797987f66f)

- - - - -
65037411 by Ben Gamari at 2023-09-19T11:40:57+05:30
nativeGen/AArch64: Fix sign extension in MulMayOflo

Previously the 32-bit implementations of MulMayOflo would use the
a non-sensical sign-extension mode. Rewrite these to reflect what gcc 11
produces. Also similarly rework the 16- and 8-bit cases.

This now passes the MulMayOflo tests in ghc/test-primops> in all four
widths, including the precision tests.

Fixes #23721.

(cherry picked from commit 824092f28f52d32b6ea3cd26e1e576524ee24969)

- - - - -
a6846677 by Ben Gamari at 2023-09-19T11:40:57+05:30
compiler: Fingerprint more code generation flags

Previously our recompilation check was quite inconsistent in its
coverage of non-optimisation code generation flags. Specifically, we
failed to account for most flags that would affect the behavior of
generated code in ways that might affect the result of a program's
execution (e.g. `-feager-blackholing`, `-fstrict-dicts`)

Closes #23369.

(cherry picked from commit d1c92bf3b4b0b07a6a652f8fc31fd7b62465bf71)

- - - - -
c559cc62 by Andreas Klebinger at 2023-09-19T11:40:57+05:30
Arm: Fix lack of zero-extension for 8/16 bit add/sub with immediate.

For 32/64bit we can avoid explicit extension/zeroing as the instructions
set the full width of the registers.

When doing 16/8bit computation we have to put a bit more work in so we
can't use the fast path.

Fixes #23749 for 9.4.

(cherry picked from commit 0bb44f695bd008f03644e3d306566c50c5bd528c)

- - - - -
bc6429b7 by Ryan Scott at 2023-09-19T11:40:57+05:30
Restore mingwex dependency on Windows

This partially reverts some of the changes in !9475 to make `base` and
`ghc-prim` depend on the `mingwex` library on Windows. It also restores the
RTS's stubs for `mingwex`-specific symbols such as `_lock_file`.

This is done because the C runtime provides `libmingwex` nowadays, and
moreoever, not linking against `mingwex` requires downstream users to link
against it explicitly in difficult-to-predict circumstances. Better to always
link against `mingwex` and prevent users from having to do the guesswork
themselves.

See https://gitlab.haskell.org/ghc/ghc/-/merge_requests/10360#note_495873 for
the discussion that led to this.

(cherry picked from commit 2b1a4abe3f5935ca58c84c6073e6bdfa5160832f)

- - - - -
dbcb04bd by Ryan Scott at 2023-09-19T11:40:57+05:30
RtsSymbols.c: Remove mingwex symbol stubs

As of !9475, the RTS now links against `ucrt` instead of `msvcrt` on Windows,
which means that the RTS no longer needs to declare stubs for the `__mingw_*`
family of symbols. Let's remove these stubs to avoid confusion.

Fixes #23309.

(cherry picked from commit 289547580b6f2808ee123f106c3118b716486d5b)

- - - - -
a5af5c1a by Jaro Reinders at 2023-09-19T11:40:58+05:30
Make STG rewriter produce updatable closures

(cherry picked from commit 3930d793901d72f42b1535c85b746f32d5f3b677)

- - - - -
c0bec55a by Ben Gamari at 2023-09-19T11:40:58+05:30
users-guide: Support both distutils and packaging

As noted in #23818, some old distributions (e.g. Debian 9) only include
`distutils` while newer distributions only include `packaging`.

Fixes #23818.

(cherry picked from commit d814bda97994df01139c2a9bcde915dc86ef2927)

- - - - -
77386227 by Ben Gamari at 2023-09-19T11:40:58+05:30
users-guide: Ensure extlinks is compatible with Sphinx <4

The semantics of the `extlinks` attribute annoyingly changed in Sphinx
4. Reflect this in our configuration. See #22690.

Fixes #23807.

(cherry picked from commit 1726db3f39f1c41b92b1bdf45e9dc054b401e782)

- - - - -
9c046c69 by Krzysztof Gogolewski at 2023-09-19T11:40:58+05:30
Fix MultiWayIf linearity checking (#23814)

Co-authored-by: Thomas BAGREL <thomas.bagrel at tweag.io>
(cherry picked from commit edd8bc43566b3f002758e5d08c399b6f4c3d7443)

- - - - -
53c0184a by Gergő Érdi at 2023-09-19T11:40:58+05:30
If we have multiple defaulting plugins, then we should zonk in between them

after any defaulting has taken place, to avoid a defaulting plugin seeing
a metavariable that has already been filled.

Fixes #23821.

(cherry picked from commit 1d92f2dff6d1a170a44488d73cef81292591d120)

- - - - -
776647bf by Gergő Érdi at 2023-09-19T11:40:58+05:30
Improvements to the documentation of defaulting plugins

Based on @simonpj's draft and comments in !11117

(cherry picked from commit eaee4d296a0782c1acfde610ed3f0a7c7668c06c)

- - - - -
bdf011e2 by Matthew Pickering at 2023-09-19T11:40:58+05:30
driver: Check transitive closure of haskell package dependencies when deciding whether to relink

We were previously just checking whether direct package dependencies had
been modified. This caused issues when compiling without optimisations
as we wouldn't relink the direct dependency if one of its dependenices
changed.

Fixes #23724

(cherry picked from commit 291d81aef8083290da0d2ce430fbc5e5a33bdb6e)

- - - - -
692b26d1 by Ben Gamari at 2023-09-19T11:40:58+05:30
rts: Fix invalid symbol type

I suspect this code is dead since we haven't observed this failing
despite the obviously incorrect macro name.

(cherry picked from commit 9861f787a8323d03311e30851b10fdf100717afb)

- - - - -
9ab41a89 by Ben Gamari at 2023-09-19T11:40:58+05:30
testsuite: Add simple test exercising C11 atomics in GHCi

See #22012.

(cherry picked from commit 03ed6a9a634fd6c3ef35e9c5428b4a911e3f0add)

- - - - -
b2331e11 by Ben Gamari at 2023-09-19T11:40:58+05:30
rts/RtsSymbols: Add AArch64 outline atomic operations

Fixes #22012 by adding the symbols described in
https://github.com/llvm/llvm-project/blob/main/llvm/docs/Atomics.rst#libcalls-atomic.

Ultimately this would be better addressed by #22011, but this is a first
step in the right direction and fixes the immediate symptom.

Note that we dropped the `__arch64_cas16` operations as these provided
by all platforms's compilers. Also, we don't link directly against the
libgcc/compiler-rt definitions but rather provide our own wrappers to
work around broken toolchains (e.g. https://bugs.gentoo.org/868018).

Generated via https://gitlab.haskell.org/ghc/ghc/-/snippets/5733.

(cherry picked from commit 1aa5733a4480420fdc146322d86dd143321a3da6)

- - - - -
661b4908 by Matthew Craven at 2023-09-19T11:40:58+05:30
Unarise: Split Rubbish literals in function args

Fixes #23914.  Also adds a check to STG lint that
these args are properly unary or nullary after unarisation

(cherry picked from commit da30f0beb9e1820500382da02ffce96da959fa84)

- - - - -
582fc7d5 by Simon Peyton Jones at 2023-09-19T11:40:58+05:30
Tiny refactor

canEtaReduceToArity was only called internally, and always with
two arguments equal to zero.  This patch just specialises the
function, and renames it to cantEtaReduceFun.

No change in behaviour.

(cherry picked from commit 236a134eab4c0a3aae30752a3d580c083f4e6b57)

- - - - -
e32a4856 by Simon Peyton Jones at 2023-09-19T11:40:58+05:30
Fix eta reduction

Issue #23922 showed that GHC was bogusly eta-reducing a join point.
We should never eta-reduce (\x -> j x) to j, if j is a join point.

It is extremly difficult to trigger this bug.  It took me 45 mins of
trying to make a small tests case, here immortalised as T23922a.

(cherry picked from commit 6840012e5bb8f5c13e4bf7a4e4cbba0b06420aaa)

- - - - -
428438cd by Andreas Klebinger at 2023-09-19T11:40:58+05:30
Profiling: Properly escape characters when using `-pj`.

There are some ways in which unusual characters like quotes or others
can make it into cost centre names. So properly escape these.

Fixes #23924

(cherry picked from commit e5c00092a13f1a8cf53df2469e027012743cf59a)

- - - - -
ef74f5fb by Krzysztof Gogolewski at 2023-09-19T11:40:58+05:30
Fix wrong role in mkSelCo_maybe

In the Lint failure in #23938, we start with a coercion Refl :: T a ~R T a,
and call mkSelCo (SelTyCon 1 nominal) Refl.
The function incorrectly returned Refl :: a ~R a. The returned role
should be nominal, according to the SelCo rule:

      co : (T s1..sn) ~r0 (T t1..tn)
      r = tyConRole tc r0 i
      ----------------------------------
      SelCo (SelTyCon i r) : si ~r ti

In this test case, r is nominal while r0 is representational.

(cherry picked from commit e0aa8c6e3a8b6004eca9349e5b705b8a767050aa)

- - - - -
ceb1e37a by Finley McIlwaine at 2023-09-19T11:40:58+05:30
Add -dipe-stats flag

This is useful for seeing which info tables have information.

(cherry picked from commit cc52c358316ac8210f80da80db6b0c620dd5bdc3)

- - - - -
2e9adfc4 by Finley McIlwaine at 2023-09-19T11:40:58+05:30
Add -finfo-table-map-with-fallback -finfo-table-map-with-stack

The -fno-info-table-map-with-stack flag omits STACK info tables from the info
table map, and the -fno-info-table-map-with-fallback flag omits info tables
with defaulted source locations from the map. In a test on the Agda codebase
the build results were about 7% smaller when both of those types of tables
were omitted.

Adds a test that verifies that passing each combination of these flags
results in the correct output for -dipe-stats, which is disabled for the js
backend since profiling is not implemented.

This commit also refactors a lot of the logic around extracting info tables
from the Cmm results and building the info table map.

This commit also fixes some issues in the users guide rst source to fix
warnings that were noticed while debugging the documentation for these flags.

Fixes #23702

(cherry picked from commit 261c4acbfdaf5babfc57ab0cef211edb66153fb1)

- - - - -
3bb59347 by Finley McIlwaine at 2023-09-19T22:26:43+05:30
Refactor estimation of stack info table provenance

This commit greatly refactors the way we compute estimated provenance for stack
info tables. Previously, this process was done using an entirely separate traversal
of the whole Cmm code stream to build the map from info tables to source locations.
The separate traversal is now fused with the Cmm code generation pipeline in
GHC.Driver.Main.

This results in very significant code generation speed ups when -finfo-table-map is
enabled. In testing, this patch reduces code generation times by almost 30% with
-finfo-table-map and -O0, and 60% with -finfo-table-map and -O1 or -O2 .

Fixes #23103

(cherry picked from commit d99c816f7b5727a3f344960e02a1932187ea093f)

- - - - -
448c885d by Finley McIlwaine at 2023-09-19T22:26:43+05:30
Add a test checking overhead of -finfo-table-map

We want to make sure we don't end up with poor codegen performance resulting from
-finfo-table-map again as in #23103. This test adds a performance test tracking
total allocations while compiling ExactPrint with -finfo-table-map.

(cherry picked from commit d3e0124c1157a4a423d86a1dc1d7e82c6d32ef06)

- - - - -
ec164fcb by Ben Gamari at 2023-09-19T22:26:43+05:30
base: Advertise linear time of readFloat

As noted in #23538, `readFloat` has runtime that scales nonlinearly in
the size of its input. Consequently, its use on untrusted input can
be exploited as a denial-of-service vector. Point this out and suggest
use of `read` instead.

See #23538.

(cherry picked from commit b33113c86ce5888ff5edfd6d3dd95772d3c8abce)

- - - - -
b6bd8c09 by Sylvain Henry at 2023-09-19T22:26:43+05:30
Add missing int64/word64-to-double/float rules (#23907)

CLC proposal: https://github.com/haskell/core-libraries-committee/issues/203

(cherry picked from commit 5126a2fef0385e206643b6af0543d10ff0c219d8)

- - - - -
9bc1ab68 by Matthew Pickering at 2023-09-19T22:26:43+05:30
Build vanilla alpine bindists

We currently attempt to build and distribute fully static alpine
bindists (ones which could be used on any linux platform) but most
people who use the alpine bindists want to use alpine to build their own
static applications (for which a fully static bindist is not necessary).
We should build and distribute these bindists for these users whilst the
fully-static bindist is still unusable.

Fixes #23349

(cherry picked from commit 29be39ba3f187279b19cf451f2d8f58822edab4f)

- - - - -
1bd57554 by Matthew Craven at 2023-09-19T22:26:43+05:30
Bump bytestring submodule to 0.11.5.1

(cherry picked from commit 43578d60bfc478e7277dcd892463cec305400025)

- - - - -
374f6f0d by Zubin Duggal at 2023-09-19T22:26:43+05:30
Bump bytestring submodule to 0.11.5.2 (#23789)

(cherry picked from commit a98ae4ec6f4325c32c86cc0726947b6ecf4d047a)

- - - - -
8ca3c034 by Zubin Duggal at 2023-09-19T22:26:43+05:30
Bump filepath submodule to 1.4.100.4
Bump bytestring submodule to 0.11.5.2

- - - - -
f29969ca by Zubin Duggal at 2023-09-19T22:26:43+05:30
Update haddock submodule

- - - - -
2000339c by Zubin Duggal at 2023-09-19T22:29:31+05:30
ci: Update bootstrap matrix for ghc 9.2.8, 9.4.7 and 9.6.2

Also add bootstrap plans for 9.2.{6..8}, 9.4.{4..6}, 9.6.{1,2}

- - - - -
21e34882 by Zubin Duggal at 2023-09-19T22:29:31+05:30
user-guide: Add note that #23520 and -Wincomplete-record-updates is broken

- - - - -
835be43c by Zubin Duggal at 2023-09-19T22:29:31+05:30
users-guide: Remove package list from older release notes (#18904)

- - - - -
ea651dae by Zubin Duggal at 2023-09-20T00:49:41+05:30
Prepare release 9.6.3

Metric Decrease:
    MultiComponentModules
    MultiComponentModulesRecomp
    MultiLayerModules
    MultiLayerModulesRecomp
    T10421
    T12150
    T12234
    T12425
    T13035
    T13701
    T13719
    T15164
    T16875
    T18140
    T18304
    T18698a
    T18698b
    T18923
    T20049
    T9198
    T9961
    hard_hole_fits
Metric Decrease 'compile_time/bytes allocated':
    T21839r
Metric Increase 'runtime/max_bytes_used':
    T21839r
Metric Increase 'runtime/peak_megabytes_allocated':
    T21839r

- - - - -


30 changed files:

- .gitlab-ci.yml
- .gitlab/gen_ci.hs
- .gitlab/jobs.yaml
- .gitlab/rel_eng/fetch-gitlab-artifacts/fetch_gitlab.py
- compiler/GHC/Cmm.hs
- compiler/GHC/Cmm/CLabel.hs
- compiler/GHC/Cmm/MachOp.hs
- compiler/GHC/CmmToAsm/AArch64/CodeGen.hs
- compiler/GHC/CmmToAsm/Ppr.hs
- compiler/GHC/CmmToAsm/X86/CodeGen.hs
- compiler/GHC/Core/Coercion.hs
- compiler/GHC/Core/DataCon.hs
- compiler/GHC/Core/Opt/Arity.hs
- compiler/GHC/Core/Opt/DmdAnal.hs
- compiler/GHC/Core/Opt/SpecConstr.hs
- compiler/GHC/Core/Opt/Specialise.hs
- compiler/GHC/Core/Rules.hs
- compiler/GHC/Core/Tidy.hs
- compiler/GHC/CoreToStg/Prep.hs
- compiler/GHC/Driver/CodeOutput.hs
- compiler/GHC/Driver/Config/StgToCmm.hs
- compiler/GHC/Driver/Flags.hs
- compiler/GHC/Driver/GenerateCgIPEStub.hs
- compiler/GHC/Driver/Main.hs
- compiler/GHC/Driver/Make.hs
- compiler/GHC/Driver/Pipeline.hs
- compiler/GHC/Driver/Session.hs
- compiler/GHC/Hs/Utils.hs
- compiler/GHC/HsToCore/Match.hs
- compiler/GHC/HsToCore/Pmc.hs


The diff was not included because it is too large.


View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9a1dcec1be8421d415c4592231e6c24af7e7e013...ea651daef0d6e0977627696cb14f569f2a305069

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9a1dcec1be8421d415c4592231e6c24af7e7e013...ea651daef0d6e0977627696cb14f569f2a305069
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/20230919/43368b08/attachment-0001.html>


More information about the ghc-commits mailing list