[Git][ghc/ghc][ghc-9.6] 20 commits: NCG: Fix a bug where we errounously removed a required jump instruction.

Zubin (@wz1000) gitlab at gitlab.haskell.org
Mon Jul 1 07:00:38 UTC 2024



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


Commits:
9045ab5d by Andreas Klebinger at 2024-06-25T14:33:16+05:30
NCG: Fix a bug where we errounously removed a required jump instruction.

Add a new method to the Instruction class to check if we can eliminate a
jump in favour of fallthrough control flow.

Fixes #24507

(cherry picked from commit 0fe2b410ac0d8951f07ffcc9f3c6c97bc312df48)

- - - - -
1b0f0c1b by Zubin Duggal at 2024-06-25T16:50:35+05:30
driver: Make `checkHomeUnitsClosed` faster

The implementation of `checkHomeUnitsClosed` was traversing every single path
in the unit dependency graph - this grows exponentially and quickly grows to be
infeasible on larger unit dependency graphs.

Instead we replace this with a faster implementation which follows from the
specificiation of the closure property - there is a closure error if there are
units which are both are both (transitively) depended upon by home units and
(transitively) depend on home units, but are not themselves home units.

To compute the set of units required for closure, we first compute the closure
of the unit dependency graph, then the transpose of this closure, and find all
units that are reachable from the home units in the transpose of the closure.

(cherry picked from commit a933aff37992ea311a60be878379e7abf650e9fb)

- - - - -
bf9b110b by Matthew Pickering at 2024-06-25T16:58:37+05:30
Don't depend on registerPackage function in Cabal

More recent versions of Cabal modify the behaviour of libAbiHash which
breaks our usage of registerPackage.

It is simpler to inline the part of registerPackage that we need and
avoid any additional dependency and complication using the higher-level
function introduces.

(cherry picked from commit 3fff09779d5830549ae455a15907b7bb9fe7859a)

- - - - -
8ebc906a by Teo Camarasu at 2024-06-25T16:59:10+05:30
doc: Fix type error in hs_try_putmvar example

(cherry picked from commit 06f7db4001e4eee0f3076d949876f8f4af0eb6fb)

- - - - -
659a0b8b by Cheng Shao at 2024-06-25T17:00:44+05:30
driver: force merge objects when building dynamic objects

This patch forces the driver to always merge objects when building
dynamic objects even when ar -L is supported. It is an oversight of
!8887: original rationale of that patch is favoring the relatively
cheap ar -L operation over object merging when ar -L is supported,
which makes sense but only if we are building static objects! Omitting
check for whether we are building dynamic objects will result in
broken .so files with undefined reference errors at executable link
time when building GHC with llvm-ar. Fixes #22210.

(cherry picked from commit d2b17f3258b4d9db1de89c872f1b7cee0a3f9b74)

- - - - -
8ae9b4fb by Cheng Shao at 2024-06-25T17:00:53+05:30
driver: always merge objects when possible

This patch makes the driver always merge objects with `ld -r` when
possible, and only fall back to calling `ar -L` when merge objects
command is unavailable. This completely reverts !8887 and !12313,
given more fixes in Cabal seems to be needed to avoid breaking certain
configurations and the maintainence cost is exceeding the behefits in
this case :/

(cherry picked from commit 631cefec222e2db951c58db0b15a8d80ef5549cb)

- - - - -
0619129e by Torsten Schmits at 2024-06-25T17:02:54+05:30
refactor quadratic search in warnMissingHomeModules

(cherry picked from commit bc672166acd8f2815d58b6d214e69373abec4486)

- - - - -
942ddb2a by Sylvain Henry at 2024-06-28T15:34:28+05:30
Reverse arguments to stgCallocBytes (fix #24828)

(cherry picked from commit 6838a7c32ca29b5d44adc9d6280d3a960f31be7c)

- - - - -
05e4b390 by Ryan Scott at 2024-06-28T15:34:28+05:30
Add missing parenthesizePat in cvtp

We need to ensure that the output of `cvtp` is parenthesized (at precedence
`sigPrec`) so that any pattern signatures with a surrounding pattern signature
can parse correctly.

Fixes #24837.

(cherry picked from commit a3cd3a1d0d186f2aa4d0273c6b3e74a442de2ef0)

- - - - -
e0ff189b by Cheng Shao at 2024-06-28T15:34:28+05:30
compiler: emit NaturallyAligned when element type & index type are the same width

This commit fixes a subtle mistake in alignmentFromTypes that used to
generate Unaligned when element type & index type are the same width.
Fixes #24930.

(cherry picked from commit 0cff083abb24701530974872b21cf897c9955a9a)

- - - - -
52235ada by Cheng Shao at 2024-06-28T15:34:28+05:30
hadrian: fix no_dynamic_libs flavour transformer

This patch fixes the no_dynamic_libs flavour transformer and make
fully_static reuse it. Previously building with no_dynamic_libs fails
since ghc program is still dynamic and transitively brings in dyn ways
of rts which are produced by no rules.

(cherry picked from commit 1bb24432ff77e11a0340a7d8586e151e15bba2a1)

- - - - -
2b1fd267 by Cheng Shao at 2024-06-28T15:34:28+05:30
rts: ensure gc_thread/gen_workspace is allocated with proper alignment

gc_thread/gen_workspace are required to be aligned by 64 bytes.
However, this property has not been properly enforced before, and
numerous alignment violations at runtime has been caught by
UndefinedBehaviorSanitizer that look like:

```
rts/sm/GC.c:1167:8: runtime error: member access within misaligned address 0x0000027a3390 for type 'gc_thread' (aka 'struct gc_thread_'), which requires 64 byte alignment
0x0000027a3390: note: pointer points here
 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00
              ^
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior rts/sm/GC.c:1167:8

rts/sm/GC.c:1184:13: runtime error: member access within misaligned address 0x0000027a3450 for type 'gen_workspace' (aka 'struct gen_workspace_'), which requires 64 byte alignment
0x0000027a3450: note: pointer points here
 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00
              ^
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior rts/sm/GC.c:1184:13
```

This patch fixes the gc_thread/gen_workspace misalignment issue by
explicitly allocating them with alignment constraint.

(cherry picked from commit 7a660042395614e4b19534baf5b779f65059861e)

- - - - -
33584ad7 by Cheng Shao at 2024-06-28T15:34:28+05:30
rts: fix an unaligned load in nonmoving gc

This patch fixes an unaligned load in nonmoving gc by ensuring the
closure address is properly untagged first before attempting to
prefetch its header. The unaligned load is reported by
UndefinedBehaviorSanitizer:

```
rts/sm/NonMovingMark.c:921:9: runtime error: member access within misaligned address 0x0042005f3a71 for type 'StgClosure' (aka 'struct StgClosure_'), which requires 8 byte alignment
0x0042005f3a71: note: pointer points here
 00 00 00  98 43 13 8e 12 7f 00 00  50 3c 5f 00 42 00 00 00  58 17 b7 92 12 7f 00 00  89 cb 5e 00 42
              ^
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior rts/sm/NonMovingMark.c:921:9
```

This issue had previously gone unnoticed since it didn't really harm
runtime correctness, the invalid header address directly loaded from a
tagged pointer is only used as prefetch address and will not cause
segfaults. However, it still should be corrected because the prefetch
would be rendered useless by this issue, and untagging only involves a
single bitwise operation without memory access so it's cheap enough to
add.

(cherry picked from commit c77a48af6e1f38337b305fec794e8c999f1c7f3a)

- - - - -
deb5497a by Ian-Woo Kim at 2024-06-28T15:34:28+05:30
Add missing BCO handling in scavenge_one.

(cherry picked from commit 902ebcc2b95707319d37a19d6b23c342cc14b162)

- - - - -
5a203d10 by Peter Trommler at 2024-06-28T15:34:28+05:30
PPC NCG: Fix sign hints in C calls

Sign hints for parameters are in the second component of the pair.

Fixes #23034

(cherry picked from commit 7fe85b1354a13749f14d588e3cc742b8ae2d8da9)

- - - - -
7d6907c8 by Zubin Duggal at 2024-06-28T15:34:28+05:30
Bump directory submodule to 1.3.8.5

- - - - -
86afa784 by Sebastian Graf at 2024-06-28T15:34:28+05:30
exprIsTrivial: Factor out shared implementation

The duplication between `exprIsTrivial` and `getIdFromTrivialExpr_maybe` has
been bugging me for a long time.

This patch introduces an inlinable worker function `trivial_expr_fold` acting
as the single, shared decision procedure of triviality. It "returns" a
Church-encoded `Maybe (Maybe Id)`, so when it is inlined, it fuses to similar
code as before.
(Better code, even, in the case of `getIdFromTrivialExpr` which presently
allocates a `Just` constructor that cancels away after this patch.)

(cherry picked from commit 9cb7e73a632bb570dd5d9100ea45536a5f13e182)

- - - - -
d0438f66 by Sebastian Graf at 2024-06-28T15:34:28+05:30
Some cherry-picked bits of 59202c8 to fix #24718

As noted in f3225ed4b3f3c4, the test below is flaky on Darwin.

Metric Decrease:
    MultiLayerModulesTH_Make

(cherry picked from commit 78a253543d466ac511a1664a3e6aff032ca684d5)

- - - - -
51b77722 by Andreas Klebinger at 2024-07-01T04:00:07+05:30
GHCi interpreter: Tag constructor closures when possible.

When evaluating PUSH_G try to tag the reference we are pushing if it's a
constructor. This is potentially helpful for performance and required to
fix #24870.

(cherry picked from commit 1bfa91115b8320ed99a5e946147528e21ca4f3e1)

- - - - -
3a18c0fa by Zubin Duggal at 2024-07-01T04:00:07+05:30
Prepare release 9.6.6

- - - - -


30 changed files:

- compiler/GHC/ByteCode/Instr.hs
- compiler/GHC/CmmToAsm/AArch64.hs
- compiler/GHC/CmmToAsm/AArch64/Instr.hs
- compiler/GHC/CmmToAsm/BlockLayout.hs
- compiler/GHC/CmmToAsm/Instr.hs
- compiler/GHC/CmmToAsm/Monad.hs
- compiler/GHC/CmmToAsm/PPC.hs
- compiler/GHC/CmmToAsm/PPC/CodeGen.hs
- compiler/GHC/CmmToAsm/PPC/Instr.hs
- compiler/GHC/CmmToAsm/Reg/Liveness.hs
- compiler/GHC/CmmToAsm/X86.hs
- compiler/GHC/CmmToAsm/X86/Instr.hs
- compiler/GHC/Core/Utils.hs
- compiler/GHC/CoreToStg.hs
- compiler/GHC/Driver/Make.hs
- compiler/GHC/Driver/Pipeline/Execute.hs
- compiler/GHC/StgToCmm/Prim.hs
- compiler/GHC/ThToHs.hs
- configure.ac
- docs/users_guide/9.6.5-notes.rst
- + docs/users_guide/9.6.6-notes.rst
- docs/users_guide/exts/ffi.rst
- docs/users_guide/release-notes.rst
- hadrian/src/Flavour.hs
- hadrian/src/Hadrian/Haskell/Cabal/Parse.hs
- libraries/directory
- rts/Interpreter.c
- rts/linker/Elf.c
- rts/sm/GC.c
- rts/sm/NonMovingMark.c


The diff was not included because it is too large.


View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/650c34ab4e1cefb521209b143ecd75367ec03ee1...3a18c0fa2edcd61b0c3b470661791b09501c4c2b

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/650c34ab4e1cefb521209b143ecd75367ec03ee1...3a18c0fa2edcd61b0c3b470661791b09501c4c2b
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/20240701/c498f753/attachment-0001.html>


More information about the ghc-commits mailing list