[Git][ghc/ghc][wip/supersven/riscv64-ncg] 236 commits: hadrian: Bump index-state to allow building with ghc-9.6

Sven Tennie (@supersven) gitlab at gitlab.haskell.org
Wed Dec 13 10:37:43 UTC 2023



Sven Tennie pushed to branch wip/supersven/riscv64-ncg at Glasgow Haskell Compiler / GHC


Commits:
40293d4e by Matthew Pickering at 2023-05-10T16:07:19+01:00
hadrian: Bump index-state to allow building with ghc-9.6

- - - - -
65023412 by Ben Gamari at 2023-05-11T12:49:10-04:00
users guide: Note that base release notes are highlights of changelog

- - - - -
e0f3aec8 by Simon Peyton Jones at 2023-05-15T18:34:25-04:00
Refactor the simplifier a bit to fix #22761

The core change in this commit, which fixes #22761, is that

* In a Core rule, ru_rhs is always occ-analysed.

This means adding a couple of calls to occurAnalyseExpr when
building a Rule, in
* GHC.Core.Rules.mkRule
* GHC.Core.Opt.Simplify.Iteration.simplRules

But diagosing the bug made me stare carefully at the code of the
Simplifier, and I ended up doing some only-loosely-related refactoring.

* I think that RULES could be lost because not every code path
  did addBndrRules

* The code around lambdas was very convoluted

It's mainly moving deck chairs around, but I like it more now.

(cherry picked from commit e45eb82830d6de4d09abb548e190be980dd001b4)

- - - - -
595edd68 by Josh Meredith at 2023-05-15T18:34:25-04:00
JS: Fix implementation of MK_JSVAL

(cherry picked from commit bab232795865e9abb82b75c7e72329778e23a345)

- - - - -
dc291c00 by Josh Meredith at 2023-05-15T18:34:25-04:00
JS: fix implementation of forceBool to use JS backend syntax

(cherry picked from commit 047e9d4f10e4124899887449dc52b9e72a7d3ea6)

- - - - -
3db2b31b by Sebastian Graf at 2023-05-15T18:34:26-04:00
Simplifier: `countValArgs` should not count Type args (#23102)

I observed miscompilations while working on !10088 caused by this.

Fixes #23102.

Metric Decrease:
    T10421

(cherry picked from commit 559a480427a841b5189f2e6a84a38b02a7c2b8a1)

- - - - -
4532771a by Alexis King at 2023-05-15T18:34:26-04:00
bytecode: Fix bitmaps for BCOs used to tag tuples and prim call args

fixes #23068

(cherry picked from commit bed3a292df532935426987e1f0c5eaa4f605407e)

- - - - -
f70b9c49 by Matthew Pickering at 2023-05-16T07:56:09-04:00
docs: Generate docs/index.html with version number

* Generate docs/index.html to include the version of the ghc library

* This also fixes the packageVersions interpolations which were
  - Missing an interpolation for `LIBRARY_ghc_VERSION`
  - Double quoting the version so that "9.7" was being inserted.

Fixes #23121

(cherry picked from commit d7a768a415c3bd575a20b20ae9a3953aa5886ed7)

- - - - -
6cd0f807 by Simon Peyton Jones at 2023-05-16T07:56:09-04:00
Transfer DFunId_ness onto specialised bindings

Whether a binding is a DFunId or not has consequences for the `-fdicts-strict`
flag, essentially if we are doing demand analysis for a DFunId then `-fdicts-strict` does
not apply because the constraint solver can create recursive groups of dictionaries.

In #22549 this was fixed for the "normal" case, see
Note [Do not strictify the argument dictionaries of a dfun].
However the loop still existed if the DFunId was being specialised.

The problem was that the specialiser would specialise a DFunId and
turn it into a VanillaId and so the demand analyser didn't know to
apply special treatment to the binding anymore and the whole recursive
group was optimised to bottom.

The solution is to transfer over the DFunId-ness of the binding in the specialiser so
that the demand analyser knows not to apply the `-fstrict-dicts`.

Fixes #22549

(cherry picked from commit 3b0ea4809d92581a10e0e501a6fbd7339e8922bf)

- - - - -
5637364e by Ben Gamari at 2023-05-16T07:56:09-04:00
nonmoving: Disable slop-zeroing

As noted in #23170, the nonmoving GC can race with a mutator zeroing the
slop of an updated thunk (in much the same way that two mutators would
race). Consequently, we must disable slop-zeroing when the nonmoving GC
is in use.

Closes #23170

(cherry picked from commit d1bb16ed3e18a4f41fcfe31f0bf57dbaf589d6c5)

- - - - -
373ec872 by Krzysztof Gogolewski at 2023-05-16T07:56:09-04:00
Fix unification with oversaturated type families

unify_ty was incorrectly saying that F x y ~ T x are surely apart,
where F x y is an oversaturated type family and T x is a tyconapp.
As a result, the simplifier dropped a live case alternative (#23134).

(cherry picked from commit 7c16f3be6e1ac92f87d752f12ad6c6e7b7fd6207)

- - - - -
ab677901 by Ben Gamari at 2023-05-16T07:56:09-04:00
nativeGen/AArch64: Fix bitmask immediate predicate

Previously the predicate for determining whether a logical instruction
operand could be encoded as a bitmask immediate was far too
conservative. This meant that, e.g., pointer untagged required five
instructions whereas it should only require one.

Fixes #23030.

(cherry picked from commit b8d783d24b9a617ad1e3038abeb75d322703ef65)

- - - - -
7083db5a by Sylvain Henry at 2023-05-16T07:56:09-04:00
JS: fix thread-related primops

(cherry picked from commit d442ac053f9ac7dbcc32318802daf686f377fe3d)

- - - - -
35131c9d by Ben Gamari at 2023-05-16T07:56:09-04:00
rts: Initialize Array# header in listThreads#

Previously the implementation of listThreads# failed to initialize the
header of the created array, leading to various nastiness.

Fixes #23071

(cherry picked from commit 52d3e9b4189440d26bad9c5a15f9420b67b1ca5b)

- - - - -
ac639721 by Ben Gamari at 2023-05-16T07:56:09-04:00
testsuite: Add test for #23071

(cherry picked from commit 1db30fe1dd38dd8ffedfadf3845706fcde02933b)

- - - - -
1fdbbd8d by sheaf at 2023-05-16T07:56:09-04:00
Don't panic in ltPatersonSize

The function GHC.Tc.Utils.TcType.ltPatersonSize would panic when it
encountered a type family on the RHS, as usually these are not allowed
(type families are not allowed on the RHS of class instances or of
quantified constraints). However, it is possible to still encounter
type families on the RHS after doing a bit of constraint solving, as
seen in test case T23171. This could trigger the panic in the call to
ltPatersonSize in GHC.Tc.Solver.Canonical.mk_strict_superclasses, which
is involved in avoiding loopy superclass constraints.

This patch simply changes ltPatersonSize to return "I don't know, because
there's a type family involved" in these cases.

Fixes #23171

(cherry picked from commit df1a581188694479a583270548896245fc23b525)

- - - - -
5292bdf8 by Sylvain Henry at 2023-05-17T11:43:28-04:00
JS: fix getpid (fix #23399)

(cherry picked from commit 2972fd66f91cb51426a1df86b8166a067015e231)

- - - - -
6c5fcaba by Josh Meredith at 2023-05-17T11:43:34-04:00
JS: Implement h$clock_gettime in the JavaScript RTS (#23360)

(cherry picked from commit 5e3f9bb57680a40f6a9531e41dc2617c5f028e5c)

- - - - -
86a9404a by Sylvain Henry at 2023-05-17T11:44:06-04:00
Fix GHCJS OS platform (fix #23346)

(cherry picked from commit 2f571afe1c2aeb3f4dfca2012bc6b713144fd234)

- - - - -
48da24c9 by Simon Peyton Jones at 2023-05-18T16:00:10-04:00
Make GHC.Types.Id.Make.shouldUnpackTy a bit more clever

As #23307, GHC.Types.Id.Make.shouldUnpackTy was leaving money on the
table, failing to unpack arguments that are perfectly unpackable.

The fix is pretty easy; see Note [Recursive unboxing]

(cherry picked from commit 902f0730b4c50f39b7767a346be324c98bf7a8a6)

- - - - -
74b8e5bd by Alexis King at 2023-05-18T16:00:10-04:00
Use a uniform return convention in bytecode for unary results

fixes #22958

(cherry picked from commit d85ed900b271109185251cb0494d51048a4cf213)

- - - - -
4949111f by Alexis King at 2023-05-18T16:00:10-04:00
hadrian: Fix linker script flag for MergeObjects builder

This fixes what appears to have been a typo in !9530. The `-t` flag just
enables tracing on all versions of `ld` I’ve looked at, while `-T` is
used to specify a linker script. It seems that this worked anyway for
some reason on some `ld` implementations (perhaps because they
automatically detect linker scripts), but the missing `-T` argument
causes `gold` to complain.

(cherry picked from commit 59aa4676a49b4f9d09c1cd3cc3b47c3c54b6ed80)

- - - - -
27086298 by Krzysztof Gogolewski at 2023-05-18T16:00:10-04:00
Fix coercion optimisation for SelCo (#23362)

setNominalRole_maybe is supposed to output a nominal coercion.
In the SelCo case, it was not updating the stored role to Nominal,
causing #23362.

(cherry picked from commit d683b2e5b91a39a2bf16796f5800f605a0281004)

- - - - -
5bd85c7d by Ben Gamari at 2023-05-18T16:00:10-04:00
hadrian: Fix mention of non-existent removeFiles function

Previously Hadrian's bindist Makefile referred to a `removeFiles`
function that was previously defined by the `make` build system. Since
the `make` build system is no longer around, this function is now
undefined. Naturally, make being make, this appears to be silently
ignored instead of producing an error.

Fix this by rewriting it to `rm -f`.

Closes #23373.

(cherry picked from commit c6cf9433e3d41e239265eaeff0fd02e6b45d5427)

- - - - -
7607986e by sheaf at 2023-05-18T16:00:10-04:00
Don't panic in mkNewTyConRhs

This function could come across invalid newtype constructors, as we
only perform validity checking of newtypes once we are outside the
knot-tied typechecking loop.
This patch changes this function to fake up a stub type in the case of
an invalid newtype, instead of panicking.

This patch also changes "checkNewDataCon" so that it reports as many
errors as possible at once.

Fixes #23308

(cherry picked from commit c176ad1835ccfe55e2bde875b4a35e9d226ff657)

- - - - -
eaadcaa7 by Ryan Scott at 2023-05-18T16:00:10-04:00
Fix type variable substitution in gen_Newtype_fam_insts

Previously, `gen_Newtype_fam_insts` was substituting the type variable binders
of a type family instance using `substTyVars`, which failed to take type
variable dependencies into account. There is similar code in
`GHC.Tc.TyCl.Class.tcATDefault` that _does_ perform this substitution properly,
so this patch:

1. Factors out this code into a top-level `substATBndrs` function, and
2. Uses `substATBndrs` in `gen_Newtype_fam_insts`.

Fixes #23329.

(cherry picked from commit e8b72ff6e4aee1f889a9168df57bb1b00168fd21)

- - - - -
14414247 by Ben Gamari at 2023-05-18T16:00:10-04:00
nonmoving: Fix style

(cherry picked from commit abb6070f488120aef113b686e91b439fe6c3d272)

- - - - -
4200590a by Ben Gamari at 2023-05-18T16:00:10-04:00
nonmoving: Deduplicate assertion

(cherry picked from commit be2789014b208db5c471ab187e7dba2ebc59f8c8)

- - - - -
80208941 by Ben Gamari at 2023-05-18T16:00:10-04:00
rts: Fix type issues in Sparks.h

Adds explicit casts to satisfy a C++ compiler.

(cherry picked from commit b90346392f5455bc4a6f6d86700296babc429a98)

- - - - -
0a25b9df by Ben Gamari at 2023-05-18T16:00:10-04:00
rts: Use release ordering when storing thread labels

Since this makes the ByteArray# visible from other cores.

(cherry picked from commit da7b2b941d235a284d5685829c235a9e671a0336)

- - - - -
a70c277a by Ben Gamari at 2023-05-18T16:00:10-04:00
rts/BlockAlloc: Allow disabling of internal assertions

These can be quite expensive and it is sometimes useful to compile a
DEBUG RTS without them.

(cherry picked from commit 5b7f65767fbc2967e01a13ee580598e976f5d225)

- - - - -
b4e5489f by Ben Gamari at 2023-05-18T16:00:10-04:00
rts/Sanity: Mark pinned_object_blocks

(cherry picked from commit 6283144fb2e98f4c774950567e55575c1747d136)

- - - - -
2ab18a83 by Ben Gamari at 2023-05-18T16:00:11-04:00
rts/Sanity: Look at nonmoving saved_filled lists

(cherry picked from commit 9b52840412c920a1a1eed26df37262bc6c82c171)

- - - - -
556c2544 by Ben Gamari at 2023-05-18T16:00:11-04:00
Evac: Squash data race in eval_selector_chain

(cherry picked from commit 0edc543834d8172e54020c5272af1cf2d0b3437c)

- - - - -
4023f814 by Ben Gamari at 2023-05-18T16:00:11-04:00
nonmoving: Clarify implementation

This makes the intent of this implementation a bit clearer.

(cherry picked from commit 7eab831a7d17eda3108da4702a447656cd62334c)

- - - - -
88cc3f94 by Ben Gamari at 2023-05-18T16:00:11-04:00
nonmoving: Clarify comment

(cherry picked from commit 532262b95b2eaa685a22279a8e54cc2e379e21ef)

- - - - -
f5a48ce6 by Ben Gamari at 2023-05-18T16:00:11-04:00
nonmoving: Add missing no-op in busy-wait loop

(cherry picked from commit bd9cd84bbbb51f21c7b2b478e1f5971e2659b9fd)

- - - - -
5c4aa7e2 by Ben Gamari at 2023-05-18T16:00:11-04:00
nonmoving: Don't push empty arrays to update remembered set

Previously the write barrier of resizeSmallArray# incorrectly handled
resizing of zero-sized arrays, pushing an invalid pointer to the update
remembered set.

Fixes #22931.

(cherry picked from commit c4e6bfc801a79b73e94d363db1d3e65076e17981)

- - - - -
661da5ee by Ben Gamari at 2023-05-18T16:00:11-04:00
nonmoving: Fix handling of weak pointers

This fixes an interaction between aging and weak pointer handling which
prevented the finalization of some weak pointers. In particular, weak
pointers could have their keys incorrectly marked by the preparatory
collector, preventing their finalization by the subsequent concurrent
collection.

While in the area, we also significantly improve the assertions
regarding weak pointers.

Fixes #22327.

(cherry picked from commit 92227b6022b35d87f6366c75e09ed495b7c3603e)

- - - - -
568b2523 by Ben Gamari at 2023-05-18T16:00:11-04:00
nonmoving: Sanity check nonmoving large objects and compacts

(cherry picked from commit ba7e7972ae14848a9ac41d5c6200d0aa5727ed72)

- - - - -
ce560ce4 by Ben Gamari at 2023-05-18T16:00:11-04:00
nonmoving: Sanity check mutable list

Assert that entries in the nonmoving generation's generational
remembered set (a.k.a. mutable list) live in nonmoving generation.

(cherry picked from commit 71b038a1261754c38cf984f7c578621c3217c3bf)

- - - - -
a01dc8ab by Ben Gamari at 2023-05-18T16:00:11-04:00
nonmoving: Don't show occupancy if we didn't collect live words

(cherry picked from commit 99d144d56598965daba30aa73e6c598b3245bb0f)

- - - - -
762f6ae1 by Ben Gamari at 2023-05-18T16:00:11-04:00
nonmoving: Fix tracking of FILLED_SWEEPING segments

Previously we only updated the state of the segment at the head of each
allocator's filled list.

(cherry picked from commit 81d6cc551c7a843002495d3ffd2373ad00a52766)

- - - - -
395b8572 by Ben Gamari at 2023-05-18T16:00:11-04:00
nonmoving: Assert state of swept segments

(cherry picked from commit 58e53bc4d33dad76b3250997f1a8300d0041f387)

- - - - -
6208cbae by Ben Gamari at 2023-05-18T16:00:11-04:00
nonmoving: Handle new closures in nonmovingIsNowAlive

We must conservatively assume that new closures are reachable since we
are not guaranteed to mark such blocks.

(cherry picked from commit 2db92e015655e7fc22e559020572bf23233ffaae)

- - - - -
471b5fdc by Ben Gamari at 2023-05-18T16:00:11-04:00
nonmoving: Don't clobber update rem sets of old capabilities

Previously `storageAddCapabilities` (called by `setNumCapabilities`) would
clobber the update remembered sets of existing capabilities when
increasing the capability count. Fix this by only initializing the
update remembered sets of the newly-created capabilities.

Fixes #22927.

(cherry picked from commit e4c3249f00a406a406b6f1190ca8be628b643042)

- - - - -
229ae7e4 by Ben Gamari at 2023-05-18T16:00:11-04:00
nonmoving: Add missing write barriers in selector optimisation

This fixes the selector optimisation, adding a few write barriers which
are necessary for soundness. See the inline comments for details.

Fixes #22930.

(cherry picked from commit 1b06967176559d6b2b530dd16e127fa4479ae47f)

- - - - -
8f39f2b3 by Ben Gamari at 2023-05-18T16:00:11-04:00
nonmoving: Post-sweep sanity checking

(cherry picked from commit d4032690a8bf638f6d134cc6592d138eb018f102)

- - - - -
6a25c84f by Ben Gamari at 2023-05-18T16:00:11-04:00
nonmoving: Avoid n_caps race

(cherry picked from commit 0baa8752aaefe80ca428fbfa0cbd4e620d67e1a7)

- - - - -
7213e435 by Ben Gamari at 2023-05-18T16:00:11-04:00
nonmoving: Don't push if nonmoving collector isn't enabled

(cherry picked from commit 5d3232baa78dd6f00fc040f75d8e9a8075bfbc07)

- - - - -
251e2b4a by Ben Gamari at 2023-05-18T16:00:11-04:00
nonmoving: Be more paranoid in segment tracking

Previously we left various segment link pointers dangling. None of this
wrong per se, but it did make it harder than necessary to debug.

(cherry picked from commit 0a7eb0aa0bf7e7464e68ab9b6f4176771dcc3590)

- - - - -
81fb5149 by Ben Gamari at 2023-05-18T16:00:11-04:00
nonmoving: Sync-phase mark budgeting

Here we significantly improve the bound on sync phase pause times by
imposing a limit on the amount of work that we can perform during the
sync. If we find that we have exceeded our marking budget then we allow
the mutators to resume, return to concurrent marking, and try
synchronizing again later.

Fixes #22929.

(cherry picked from commit 7c817c0a4ab857e03d09526a481f63e313598c5b)

- - - - -
d8ad8043 by Ben Gamari at 2023-05-18T16:00:11-04:00
nonmoving: Allow pinned gen0 objects to be WEAK keys

(cherry picked from commit ce22a3e2f2e8168f80d77807d79214e1cfbccb44)

- - - - -
d6deed34 by Ben Gamari at 2023-05-18T16:00:11-04:00
rts: Reenable assertion

(cherry picked from commit 78746906d133765a9a4219eb34ed01e78f31344c)

- - - - -
d6826083 by Ben Gamari at 2023-05-18T16:00:11-04:00
nonmoving: Move current segment array into Capability

The current segments are conceptually owned by the mutator, not the
collector. Consequently, it was quite tricky to prove that the mutator
would not race with the collect due to this shared state. It turns out
that such races are possible: when resizing the current segment array
we may concurrently try to take a heap census. This will attempt to walk
the current segment array, causing a data race.

Fix this by moving the current segment array into `Capability`, where it
belongs.

Fixes #22926.

(cherry picked from commit b500867a9eae6381e5c686aaa71ae069398eacb9)

- - - - -
02289f9a by Ben Gamari at 2023-05-18T16:00:11-04:00
nonmoving: Fix Note references

Some references to Note [Deadlock detection under the non-moving
collector] were missing an article.

(cherry picked from commit 56e669c11208bba136c44ee7154b59e0d4d39c87)

- - - - -
4b75a239 by Ben Gamari at 2023-05-18T16:00:11-04:00
rts/Sanity: Fix block count assertion with non-moving collector

The nonmoving collector does not use `oldest_gen->blocks` to track its
block list. However, it nevertheless updates `oldest_gen->n_blocks` to
ensure that its size is accounted for by the storage manager.
Consequently, we must not attempt to assert consistency between the two.

(cherry picked from commit 4a7650d75752fcde2fc5bc23913e4116ae2ec582)

- - - - -
4275ccfb by Ben Gamari at 2023-05-18T16:00:11-04:00
nonmoving: Don't call prepareUnloadCheck

When the nonmoving GC is in use we do not call `checkUnload` (since we
don't unload code) and therefore should not call `prepareUnloadCheck`,
lest we run into assertions.

(cherry picked from commit 96a5aaede899f95fb06dcdb9d0439bbea0f93e14)

- - - - -
873df322 by Ben Gamari at 2023-05-18T16:00:11-04:00
rts: Encapsulate block allocator spinlock

This makes it a bit easier to add instrumentation on this spinlock
while debugging.

(cherry picked from commit 6c6674cafefbb72f1b9c5b8a005fc62f905c50ea)

- - - - -
8805864d by Ben Gamari at 2023-05-18T16:00:11-04:00
testsuite: Skip some tests when sanity checking is enabled

(cherry picked from commit e84f716798e0d3431aa7ec42b243dc0998cb6444)

- - - - -
f01df851 by Ben Gamari at 2023-05-18T16:00:12-04:00
nonmoving: Fix unregisterised build

(cherry picked from commit 3ae0f368542b24b2ee2cd102cf65db8db705c83c)

- - - - -
3bc83d81 by Ben Gamari at 2023-05-18T16:00:12-04:00
nonmoving: Ensure that sanity checker accounts for saved_filled segments

(cherry picked from commit 4eb9d06b00043e52be3cf828ccb92f0bb4c9e438)

- - - - -
7c5657fc by Ben Gamari at 2023-05-18T16:00:12-04:00
hadrian: Add +boot_nonmoving_gc flavour transformer

For using GHC bootstrapping to validate the non-moving GC.

(cherry picked from commit f0cf384db038ff3b83770dbf11a89ecd20178899)

- - - - -
04e8de8a by Ben Gamari at 2023-05-18T16:00:12-04:00
nonmoving: Move allocator into new source file

(cherry picked from commit 487a8b580581e8f9b40974cf0e0a4e93f95e8665)

- - - - -
a7716f0b by Ben Gamari at 2023-05-18T16:00:12-04:00
nonmoving: Split out nonmovingAllocateGC

(cherry picked from commit 8f374139f0b5f0a39861a7f9432070f78f9fbba0)

- - - - -
01f2fef1 by Ben Gamari at 2023-05-18T16:00:12-04:00
testsuite: Mark ffi023 as broken due to #23089

(cherry picked from commit f1fd3ffbdccf471c43f3c36d6ecb4bd5da33c097)

- - - - -
db8e4d61 by Ben Gamari at 2023-05-18T16:00:12-04:00
testsuite: Skip T7160 in the nonmoving way

Finalization order is different under the nonmoving collector.

(cherry picked from commit a57f12b3f06afe29cbbc6eb0a887bcbe319f17f6)

- - - - -
75fd54fe by Ben Gamari at 2023-05-18T16:00:12-04:00
rts: Capture GC configuration in a struct

The number of distinct arguments passed to GarbageCollect was getting a
bit out of hand.

(cherry picked from commit f6f12a36346e19de7eed330537350d0b7420764a)

- - - - -
19ad1ae5 by Ben Gamari at 2023-05-18T16:00:12-04:00
nonmoving: Non-concurrent collection

(cherry picked from commit ba73a807edbb444c49e0cf21ab2ce89226a77f2e)

- - - - -
15da0925 by Ben Gamari at 2023-05-18T16:00:12-04:00
gitlab-ci: Add job bootstrapping with nonmoving GC

(cherry picked from commit 581e58ac80f98a9f5292ad13a9a984c2f5a1de21)

- - - - -
7b39870b by Ben Gamari at 2023-05-21T14:30:51-04:00
nonmoving: Account for mutator allocations in bytes_allocated

Previously we failed to account direct mutator allocations into the
nonmoving heap against the mutator's allocation limit and
`cap->total_allocated`. This only manifests during CAF evaluation (since
we allocate the CAF's blackhole directly into the nonmoving heap).

Fixes #23312.

(cherry picked from commit b2cdb7dacc095142e29c0f28a956b7fa97cdb4b1)

- - - - -
3d0a7cd3 by Teo Camarasu at 2023-05-21T14:45:11-04:00
Add regression test for #17574

This test currently fails in the nonmoving way

(cherry picked from commit a56141a69842a78d56ec11be85a775eb703219bf)

- - - - -
f0f96536 by Teo Camarasu at 2023-05-21T14:45:20-04:00
fix: account for large and compact object stats with nonmoving gc

Make sure that we keep track of the size of large and compact objects that have been moved onto the nonmoving heap.
We keep track of their size and add it to the amount of live bytes in nonmoving segments to get the total size of the live nonmoving heap.

Resolves #17574

(cherry picked from commit 20c6669fc46c567e00d3cdf22aa84479b6d8dc17)

- - - - -
07243d1b by Ben Gamari at 2023-05-21T15:03:36-04:00
configure: Release 9.6.2

- - - - -
7e70df17 by Ben Gamari at 2023-05-22T20:18:09-04:00
docs: 9.6.2 release notes

- - - - -
9a1dcec1 by Ben Gamari at 2023-05-22T20:18:17-04:00
configure: RELEASE=NO

- - - - -
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 Andrew Lelechenko 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

- - - - -
96c483eb by Zubin Duggal at 2023-09-20T04:46:15+05:30
ci: Revert update to hadrian-bootstrap-sources from 2000339cbe66a2d9c7a106d6060a37fa11fc472d

These made the Gitlab runner fail in mysterious ways when run with
RELEASE_JOB=yes.

We will distribute older bootstrap sources for now, instead of bumping all
images to a newer docker revision that might break things

- - - - -
4d9abf1e by Zubin Duggal at 2023-09-20T13:36:44+05:30
Update haddock submodule to 2.29.1 to restore GHC 9.2 compatibility.

- - - - -
4031def4 by Ben Gamari at 2023-09-20T13:39:50+05:30
gitlab-ci: Only mark linker_unload_native as broken in static jobs

This test passes on dynamically-linked Alpine.

(cherry picked from commit f356a7e8ec8ec3d6b2b30fd175598b9b80065d87)

- - - - -
5279ff76 by Ben Gamari at 2023-09-20T13:41:34+05:30
gitlab-ci: Mark T22012 as broken on CentOS 7

Due to #23979.

(cherry picked from commit 4cec2feca335377f3b8e4aa448f8997760f5fb64)

- - - - -
5c623d3d by Zubin Duggal at 2023-09-20T20:43:09+05:30
configure: Set RELEASE=yes

- - - - -
6819b70a by Zubin Duggal at 2023-09-21T15:29:00+05:30
testsuite: Mark linker_unload_native as fragile

See #23993. This test is fragile on Alpine (dynamic) but we don't have a way
to mark it as fragile on only that platform, so marking it as fragile on all
platforms.

- - - - -
c8d8cc97 by Moritz Angermann at 2023-12-12T18:20:23+01:00
Bring back old aarch64 test-suite

- - - - -
2d99bca2 by Moritz Angermann at 2023-12-12T18:20:23+01:00
Add RV64 backend

- - - - -
2fa25a90 by Moritz Angermann at 2023-12-12T18:20:23+01:00
Add RV64 notes

- - - - -
55058315 by Moritz Angermann at 2023-12-12T18:20:24+01:00
Fixup Rebase mistake

- - - - -
4bf3eaed by Sven Tennie at 2023-12-12T18:20:24+01:00
Remove TAB character

The whitespace linter doesn't like it.

- - - - -
6f43b90d by Sven Tennie at 2023-12-12T18:20:24+01:00
Fix compiler warning about importing GHC.Utils.Panic.Plain in CodeGen.Platform.h

- - - - -
a914cd5f by Sven Tennie at 2023-12-12T18:20:24+01:00
Pretty-print registers by their alias names

The alias name is easier to memorize and simplifies reasoning
about what's going on.

- - - - -
6afdc32f by Sven Tennie at 2023-12-12T18:20:24+01:00
Fix getAmode: Only signed 12bit immediates

The symptom to find this was a too big immediate in a LW instruction in
test arr020:
    Error: illegal operands `lw t0,4016(t0)'

- - - - -
f0875bfa by Ben Gamari at 2023-12-12T18:20:24+01:00
hadrian: Pass CROSS_EMULATOR to runtests.py

- - - - -
ea621884 by Ben Gamari at 2023-12-12T18:20:24+01:00
testsuite/driver: Add basic support for testing cross-compilers

- - - - -
3cfc91d2 by Sven Tennie at 2023-12-12T18:20:24+01:00
Add OR and ORI instructions

ORR doesn't exist on RISCV. OR with register load is used when the
immediate is too big for ORI (i.e. >12bits.)

- - - - -
2eb5df1a by Sven Tennie at 2023-12-12T18:20:24+01:00
Refine TODO comment: Stack frame header size is 2 * 8 byte

The stack frame header should contain two registers: ra and previous fp

- - - - -
1b0b0491 by Sven Tennie at 2023-12-12T18:20:24+01:00
Fix MOV with immediate

There are three cases:
- Fits in a 12bit immediate slot -> ADDI
- Fits in 32bit -> %hi / %lo piecewise loading
- Else: Let the assembler solve this issue for now, LI

- - - - -
c8b7cf19 by Sven Tennie at 2023-12-12T18:20:24+01:00
Add DIV and REM

REM calculates the remainder and replaces the more complex logic copied
from AARCH64.

- - - - -
b7ce383b by Sven Tennie at 2023-12-12T18:20:24+01:00
Fix: LDRB -> LB, LDRH -> LH

A simple translation of these instructions from ARM to RISCV.

Add panic-ing pattern matches to fetch the outstanding STR and LDR
cases.

- - - - -
05b03431 by Sven Tennie at 2023-12-12T18:20:24+01:00
Implement MO_S_Shr and truncateReg

These store and load on the stack to move values in changed widths into
registers.

- - - - -
40498410 by Sven Tennie at 2023-12-12T18:20:24+01:00
CmmInt 0 should refer to zero register

A constant 0 can always be taken from the zero register.

- - - - -
2dbc849c by Sven Tennie at 2023-12-12T18:20:24+01:00
Fix signed shift right

This includes overhauling the sign extension and width truncation logic.

- - - - -
c74a9a31 by Sven Tennie at 2023-12-12T18:20:24+01:00
Replace SXTH & SXTB

Both do not exist on RISCV64. While touching the sign extension code,
also fix the integer calling convention in this sense and update the
sign extension note.

- - - - -
3ad1a720 by Sven Tennie at 2023-12-12T18:20:24+01:00
Allow truncation to from smaller to larger Width

This is used as inverse of sign extension to 64bit at many places.

- - - - -
3da8c87e by Sven Tennie at 2023-12-12T18:20:24+01:00
Implement MO_NOT: Replace MVN

MVN does not exist in RV64. Replace it by pseudo-instr not's effective
assembly.

- - - - -
049125d4 by Sven Tennie at 2023-12-12T18:20:24+01:00
Replace UXTB & UXTH, Fix UDIV

Replace UXTB and UXTB with truncateReg as these instructions do not
exist in RISCV64. UDIV is named DIVU in RISCV64.

- - - - -
40928235 by Sven Tennie at 2023-12-12T18:20:24+01:00
Implement XOR

Delete EOR which does not exist on RISCV64.

- - - - -
d32e58ef by Sven Tennie at 2023-12-12T18:20:24+01:00
Rename UDIV -> DIVU

That's how unsigned div is called on RISCV64. This should avoid confusion.

- - - - -
a7104960 by Sven Tennie at 2023-12-12T18:20:24+01:00
Delete unused EON

It does not exist on RISCV64.

- - - - -
e6c41bb7 by Sven Tennie at 2023-12-12T18:27:46+01:00
WIP: MO_S_MulMayOflo

- - - - -
91401476 by Moritz Angermann at 2023-12-12T18:30:03+01:00
float: first stab at supporting float ins

- - - - -
58f91052 by Sven Tennie at 2023-12-12T18:34:22+01:00
Fix & test MulMayOflo

- - - - -
79689c43 by Sven Tennie at 2023-12-12T18:34:25+01:00
Cleanup the MulMayOflo story

- - - - -
dd38ba33 by Sven Tennie at 2023-12-12T18:34:25+01:00
Implement MO_ReadBarrier and MO_WriteBarrier

The levels are taken from SMP.h write_barrier() and load_load_barrier().

- - - - -
202f3a04 by Sven Tennie at 2023-12-12T18:34:25+01:00
Implement MO_AtomicRead and MO_AtomicWrite

- - - - -
bfc92699 by Sven Tennie at 2023-12-12T18:34:25+01:00
Implement register -> stack spilling

- - - - -
0d12b3b7 by Sven Tennie at 2023-12-12T18:34:25+01:00
Add free reg counts for trivColorable

- - - - -
0553c3a3 by Sven Tennie at 2023-12-12T18:34:25+01:00
Fix immediate operand related guards

For most operations, the immediate's boundaries are those of a 12bit
integer.

- - - - -
1b115a61 by Sven Tennie at 2023-12-12T18:34:25+01:00
Assign x31 to be IP register

And, use it for register spilling.

- - - - -
e9c43006 by Sven Tennie at 2023-12-12T18:34:25+01:00
Implement MO_FS_Conv and MO_SF_Conv (integer <-> float conversion)

- - - - -
bae53d45 by Sven Tennie at 2023-12-12T18:34:25+01:00
Fix MO_U_Shr (UBFX does not exist in RISCV ISA)

- - - - -
f2693c99 by Sven Tennie at 2023-12-12T18:34:25+01:00
Fix (CmmLit (CmmInt w i)) where i doesn't fit in w

- - - - -
65ff4fb6 by Sven Tennie at 2023-12-12T18:34:25+01:00
Implement MOV for ImmInt immediates

These cases were likely just forgotten.

- - - - -
809f5a83 by Sven Tennie at 2023-12-12T18:34:25+01:00
Load integers in their positive representation and don't sign extend unsigned values in foreign C calls

Otherwise, the sign bits mess up everything!

- - - - -
4e6f1b67 by Sven Tennie at 2023-12-12T18:34:25+01:00
Just narrow all CmmLit . CmmInt to the expected width

There may appear immediates that don't fit the size. Just truncate them
with narrowU. Otherwise, some bit operations fail for the highest bit.

- - - - -
8f9471bc by Sven Tennie at 2023-12-12T18:34:25+01:00
Implement MO_UU_Conv

Expect zero extended (!) register. If the source Width is smaller or
equal to the target Width just move (copy) the value. Otherwise (target
Width is smaller), truncate it.

We don't need to care about sign-extension, as this mach op is unsigned.

- - - - -
adcf450d by Sven Tennie at 2023-12-12T18:34:25+01:00
CmmLoad: Load sub-words unsigned (no sign-extension)

The contract is that each operation should leave sub-words
zero-extended.

This fixes the test (test-primops):

//    Failed:
//    0::W64 - (~(zext[W32→W64](load[W32](0x8c::W64))))
//    ((0 :: bits64) - (~%zx64(bits32[buffer + (140 :: bits64)])))
//    0x8f8e8d8d /= 0xffffffff8f8e8d8d

test(bits64 buffer) {
    bits64 ret;
    ret = ((0 :: bits64) - (~%zx64(bits32[buffer + (140 :: bits64)])));
    return (ret);
}

- - - - -
eade684e by Sven Tennie at 2023-12-12T18:34:26+01:00
Annotate more instructions

- - - - -
8819dd7b by Sven Tennie at 2023-12-12T18:34:26+01:00
Truncate after left shift

Shifted values may exceed the target Width.

- - - - -
5c3c7be0 by Sven Tennie at 2023-12-12T18:34:26+01:00
MO_SS_Conv: Don't give up the highest bit for sign

According to this test, reducing the value for the sign is not correct.

narrow[W32→W8](sext[W16→W32](load[W16](0x223972::W64)))
test ( bits64 buffer ) {
    bits64 ret;
    (ret) = prim %popcnt8(%lobits8(%sx32(bits16[buffer + (2242930 :: bits64)])));
    return (ret);
}

4 /= 5

- - - - -
986bfcca by Sven Tennie at 2023-12-12T18:34:26+01:00
Unsigned remainder (modulo): REMU

- - - - -
a83fc290 by Sven Tennie at 2023-12-12T18:34:26+01:00
Fix loading 12bit < imm <= 32bit immediates

The prior version sign extended the immediate.

- - - - -
37e70daf by Sven Tennie at 2023-12-12T18:35:38+01:00
WIP: Check C calling convention

- - - - -
bc2320b8 by Sven Tennie at 2023-12-12T18:35:41+01:00
Fix & test C calling convention (parameters)

I think the gist is: Sub-word ints are sign-extended, sub-word words are
give as is, because they were truncated before.

- - - - -
da8858b3 by Sven Tennie at 2023-12-12T18:35:41+01:00
Truncate C return values to their expected width

Otherwise, values that may be too big are floating around.

- - - - -
1f913f51 by Sven Tennie at 2023-12-12T18:35:41+01:00
Single precision float comparisons

- - - - -
6714dc98 by Sven Tennie at 2023-12-12T18:35:41+01:00
Float conditional jumps

- - - - -
0508838f by Sven Tennie at 2023-12-12T18:35:41+01:00
Fix float absolute (fabs)

- - - - -
6680e07d by Sven Tennie at 2023-12-12T18:35:41+01:00
Fix float negation

- - - - -
cc4e6859 by Sven Tennie at 2023-12-12T18:35:41+01:00
Fix unsigned float loading

- - - - -
254161ee by Sven Tennie at 2023-12-12T18:35:41+01:00
Fix float comparisions

- - - - -
ad2163b5 by Sven Tennie at 2023-12-12T18:35:41+01:00
Fix float calling convention (a bit)

If fp regs are taken, use go regs instead.

- - - - -
a7b3893d by Sven Tennie at 2023-12-12T18:35:41+01:00
Add calling conv test for doubles

- - - - -
768576f3 by Sven Tennie at 2023-12-12T18:35:41+01:00
Fix float -> int conversion (width)

- - - - -
2f5354b2 by Sven Tennie at 2023-12-12T18:35:41+01:00
MO_FS_Conv: Truncate register after conversion

Otherwise, sign-extension bits may stay around.

- - - - -
8722ede9 by Sven Tennie at 2023-12-12T18:35:41+01:00
Fix float operation attributes

This is its own little hell...

- - - - -
296e5157 by Sven Tennie at 2023-12-12T18:35:41+01:00
Fix MO_FF_CONV

The instruction needs precision suffixes to be valid.

- - - - -
0d6dccdb by Sven Tennie at 2023-12-12T18:35:41+01:00
Fix wrong fcvt widths

- - - - -
81106e84 by Sven Tennie at 2023-12-12T18:35:41+01:00
Sign-extend branche conditionals W32 -> W64

Otherwise, negative ints are used as positive ints.

- - - - -
d8dd2e78 by Sven Tennie at 2023-12-12T18:35:41+01:00
Fix float NE: Needed width

- - - - -
7ec45201 by Sven Tennie at 2023-12-12T18:35:41+01:00
Fix TrivColorable register counts

- - - - -
0401a90b by Sven Tennie at 2023-12-13T11:37:09+01:00
Fix MulMayOflo test

- - - - -


16 changed files:

- .gitlab-ci.yml
- .gitlab/gen_ci.hs
- .gitlab/jobs.yaml
- .gitlab/rel_eng/fetch-gitlab-artifacts/fetch_gitlab.py
- compiler/CodeGen.Platform.h
- compiler/GHC/ByteCode/Asm.hs
- compiler/GHC/ByteCode/Instr.hs
- compiler/GHC/Cmm.hs
- compiler/GHC/Cmm/CLabel.hs
- compiler/GHC/Cmm/MachOp.hs
- compiler/GHC/CmmToAsm.hs
- compiler/GHC/CmmToAsm/AArch64/CodeGen.hs
- compiler/GHC/CmmToAsm/PIC.hs
- compiler/GHC/CmmToAsm/Ppr.hs
- + compiler/GHC/CmmToAsm/RV64-notes.md
- + compiler/GHC/CmmToAsm/RV64.hs


The diff was not included because it is too large.


View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ba3b2d609c1908876ca68d7dec6b83c4a71f7757...0401a90b7b75db4f1b5e5ac476ec5d4b759ccff5

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/ba3b2d609c1908876ca68d7dec6b83c4a71f7757...0401a90b7b75db4f1b5e5ac476ec5d4b759ccff5
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/20231213/45266d89/attachment-0001.html>


More information about the ghc-commits mailing list