[Git][ghc/ghc][wip/tsan/codegen] 44 commits: Implement UNPACK support for sum types.

Ben Gamari (@bgamari) gitlab at gitlab.haskell.org
Sun Nov 20 01:23:41 UTC 2022



Ben Gamari pushed to branch wip/tsan/codegen at Glasgow Haskell Compiler / GHC


Commits:
2b7d5ccc by Madeline Haraj at 2022-11-14T22:44:17+00:00
Implement UNPACK support for sum types.

This is based on osa's unpack_sums PR from ages past.

The meat of the patch is implemented in dataConArgUnpackSum
and described in Note [UNPACK for sum types].

- - - - -
78f7ecb0 by Andreas Klebinger at 2022-11-14T22:20:29-05:00
Expand on the need to clone local binders.

Fixes #22402.

- - - - -
65ce43cc by Krzysztof Gogolewski at 2022-11-14T22:21:05-05:00
Fix :i Constraint printing "type Constraint = Constraint"

Since Constraint became a synonym for CONSTRAINT 'LiftedRep,
we need the same code for handling printing as for the synonym
Type = TYPE 'LiftedRep.
This addresses the same bug as #18594, so I'm reusing the test.

- - - - -
94549f8f by ARATA Mizuki at 2022-11-15T21:36:03-05:00
configure: Don't check for an unsupported version of LLVM

The upper bound is not inclusive.

Fixes #22449

- - - - -
02d3511b by Bodigrim at 2022-11-15T21:36:41-05:00
Fix capitalization in haddock for TestEquality

- - - - -
08bf2881 by Cheng Shao at 2022-11-16T09:16:29+00:00
base: make Foreign.Marshal.Pool use RTS internal arena for allocation

`Foreign.Marshal.Pool` used to call `malloc` once for each allocation
request. Each `Pool` maintained a list of allocated pointers, and
traverses the list to `free` each one of those pointers. The extra O(n)
overhead is apparently bad for a `Pool` that serves a lot of small
allocation requests.

This patch uses the RTS internal arena to implement `Pool`, with these
benefits:

- Gets rid of the extra O(n) overhead.
- The RTS arena is simply a bump allocator backed by the block
  allocator, each allocation request is likely faster than a libc
  `malloc` call.

Closes #14762 #18338.

- - - - -
37cfe3c0 by Krzysztof Gogolewski at 2022-11-16T14:50:06-05:00
Misc cleanup

* Replace catMaybes . map f with mapMaybe f
* Use concatFS to concatenate multiple FastStrings
* Fix documentation of -exclude-module
* Cleanup getIgnoreCount in GHCi.UI

- - - - -
b0ac3813 by Lawton Nichols at 2022-11-19T03:22:14-05:00
Give better errors for code corrupted by Unicode smart quotes (#21843)

Previously, we emitted a generic and potentially confusing error during lexical
analysis on programs containing smart quotes (“/”/‘/’). This commit adds
smart quote-aware lexer errors.

- - - - -
cb8430f8 by Sebastian Graf at 2022-11-19T03:22:49-05:00
Make OpaqueNo* tests less noisy to unrelated changes

- - - - -
b1a8af69 by Sebastian Graf at 2022-11-19T03:22:49-05:00
Simplifier: Consider `seq` as a `BoringCtxt` (#22317)

See `Note [Seq is boring]` for the rationale.

Fixes #22317.

- - - - -
9fd11585 by Sebastian Graf at 2022-11-19T03:22:49-05:00
Make T21839c's ghc/max threshold more forgiving

- - - - -
4b6251ab by Simon Peyton Jones at 2022-11-19T03:23:24-05:00
Be more careful when reporting unbound RULE binders

See Note [Variables unbound on the LHS] in GHC.HsToCore.Binds.

Fixes #22471.

- - - - -
e8f2b80d by Peter Trommler at 2022-11-19T03:23:59-05:00
PPC NCG: Fix generating assembler code

Fixes #22479

- - - - -
9c5b92f8 by Ben Gamari at 2022-11-19T20:15:18-05:00
hadrian: Don't enable TSAN in stage0 build

- - - - -
2f6b2935 by Ben Gamari at 2022-11-19T20:15:18-05:00
cmm: Introduce blockConcat

- - - - -
7f032581 by Ben Gamari at 2022-11-19T20:15:18-05:00
cmm: Introduce MemoryOrderings

- - - - -
88686428 by Ben Gamari at 2022-11-19T20:15:18-05:00
llvm: Respect memory specified orderings

- - - - -
c4b08f84 by Ben Gamari at 2022-11-19T20:15:18-05:00
Codegen/x86: Eliminate barrier for relaxed accesses

- - - - -
af018502 by Ben Gamari at 2022-11-19T20:15:18-05:00
cmm/Parser: Reduce some repetition

- - - - -
cbe992fb by Ben Gamari at 2022-11-19T20:15:18-05:00
cmm/Parser: Add syntax for ordered loads and stores

- - - - -
4766ab03 by Ben Gamari at 2022-11-19T20:15:18-05:00
cmm/Parser: Atomic load syntax

Originally I had thought I would just use the `prim` call syntax instead
of introducing new syntax for atomic loads. However, it turns out that
`prim` call syntax tends to make things quite unreadable. This new
syntax seems quite natural.

- - - - -
69567ec0 by Ben Gamari at 2022-11-19T20:15:18-05:00
codeGen: Introduce ThreadSanitizer instrumentation

This introduces a new Cmm pass which instruments the program with
ThreadSanitizer annotations, allowing full tracking of mutator memory
accesses via TSAN.

- - - - -
63f8bdc9 by Ben Gamari at 2022-11-19T20:15:18-05:00
rts/Messages: Refactor

This doesn't change behavior but makes the code a bit easier to follow.

- - - - -
15a39d7b by Ben Gamari at 2022-11-19T20:15:18-05:00
rts/ThreadPaused: Ordering fixes

- - - - -
80b26557 by Ben Gamari at 2022-11-19T20:15:19-05:00
eventlog: Silence spurious data race

- - - - -
d59d6c19 by Ben Gamari at 2022-11-19T20:15:19-05:00
Introduce SET_INFO_RELEASE for Cmm

- - - - -
522a7f86 by Ben Gamari at 2022-11-19T20:15:19-05:00
rts: Use fences instead of explicit barriers

- - - - -
3bd090ce by Ben Gamari at 2022-11-19T20:15:19-05:00
rts/stm: Fix memory ordering in readTVarIO#

See #22421.

- - - - -
baa7e036 by Ben Gamari at 2022-11-19T20:15:19-05:00
Improve heap memory barrier Note

Also introduce MUT_FIELD marker in Closures.h to document mutable
fields.

- - - - -
90ba2853 by Ben Gamari at 2022-11-19T20:15:19-05:00
rts: Introduce getNumCapabilities

And ensure accesses to n_capabilities are atomic (although with relaxed
ordering). This is necessary as RTS API callers may concurrently call
into the RTS without holding a capability.

- - - - -
ba40302f by Ben Gamari at 2022-11-19T20:15:19-05:00
ghc: Fix data race in dump file handling

Previously the dump filename cache would use a non-atomic update which
could potentially result in lost dump contents. Note that this is still
a bit racy since the first writer may lag behind a later appending
writer.

- - - - -
4bc26b41 by Ben Gamari at 2022-11-19T20:15:19-05:00
rts: Always use atomics for context_switch and interrupt

Since these are modified by the timer handler.

- - - - -
4efe18f8 by Ben Gamari at 2022-11-19T20:15:19-05:00
rts/Timer: Always use atomic operations

As noted in #22447, the existence of the pthread-based ITimer
implementation means that we cannot assume that the program is
single-threaded.

- - - - -
0ed0929f by Ben Gamari at 2022-11-19T20:15:19-05:00
rts: Encapsulate recent_activity access

This makes it easier to ensure that it is accessed using the necessary
atomic operations.

- - - - -
e6c8486c by Ben Gamari at 2022-11-19T20:15:19-05:00
rts: Encapsulate access to capabilities array

- - - - -
2f3ee5e1 by Ben Gamari at 2022-11-19T20:15:19-05:00
rts: Encapsulate sched_state

- - - - -
11b63adb by Ben Gamari at 2022-11-19T20:15:19-05:00
PrimOps: Fix benign MutVar race

Relaxed ordering is fine here since the later CAS implies a release.

- - - - -
13d9a1fe by Ben Gamari at 2022-11-19T20:15:19-05:00
rts: Style fix

- - - - -
32519676 by Ben Gamari at 2022-11-19T20:15:19-05:00
compiler: Use release store in eager blackholing

- - - - -
bbb05912 by Ben Gamari at 2022-11-19T20:15:19-05:00
rts: Fix ordering of makeStableName

- - - - -
a7cf462e by Ben Gamari at 2022-11-19T20:15:19-05:00
rts: Use ordered accesses instead of explicit barriers

- - - - -
8461d88c by Ben Gamari at 2022-11-19T20:15:19-05:00
rts: Statically allocate capabilities

This is a rather simplistic way of solving #17289.

- - - - -
41c87b34 by Ben Gamari at 2022-11-19T20:15:19-05:00
rts: Ensure that all accesses to pending_sync are atomic

- - - - -
06c8fefb by Ben Gamari at 2022-11-19T20:15:19-05:00
rts: Note race with wakeBlockingQueue

- - - - -


30 changed files:

- compiler/GHC/Cmm/Config.hs
- compiler/GHC/Cmm/ContFlowOpt.hs
- compiler/GHC/Cmm/Dataflow/Block.hs
- compiler/GHC/Cmm/Lexer.x
- compiler/GHC/Cmm/MachOp.hs
- compiler/GHC/Cmm/Parser.y
- compiler/GHC/Cmm/Pipeline.hs
- + compiler/GHC/Cmm/ThreadSanitizer.hs
- compiler/GHC/CmmToAsm.hs
- compiler/GHC/CmmToAsm/AArch64/CodeGen.hs
- compiler/GHC/CmmToAsm/BlockLayout.hs
- compiler/GHC/CmmToAsm/PPC/CodeGen.hs
- compiler/GHC/CmmToAsm/PPC/Ppr.hs
- compiler/GHC/CmmToAsm/Reg/Graph/Spill.hs
- compiler/GHC/CmmToAsm/Reg/Graph/SpillClean.hs
- compiler/GHC/CmmToAsm/Reg/Graph/SpillCost.hs
- compiler/GHC/CmmToAsm/Reg/Linear/JoinToTargets.hs
- compiler/GHC/CmmToAsm/Wasm/FromCmm.hs
- compiler/GHC/CmmToAsm/X86/CodeGen.hs
- compiler/GHC/CmmToC.hs
- compiler/GHC/CmmToLlvm/CodeGen.hs
- compiler/GHC/Core/FVs.hs
- compiler/GHC/Core/Make.hs
- compiler/GHC/Core/Opt/ConstantFold.hs
- compiler/GHC/Core/Opt/Simplify/Utils.hs
- compiler/GHC/Core/Subst.hs
- compiler/GHC/Core/Unfold.hs
- compiler/GHC/CoreToStg/Prep.hs
- compiler/GHC/Data/Graph/Color.hs
- compiler/GHC/Data/Graph/Ops.hs


The diff was not included because it is too large.


View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/fc09360da6ba7c10661ece37eeffa2531295e77d...06c8fefbd9f9b18fc3586b4c63f1629d9c41b57e

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/fc09360da6ba7c10661ece37eeffa2531295e77d...06c8fefbd9f9b18fc3586b4c63f1629d9c41b57e
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/20221119/d0b9b0fb/attachment-0001.html>


More information about the ghc-commits mailing list