[Git][ghc/ghc][wip/tsan/codegen] 58 commits: rts: Check for program_invocation_short_name via autoconf
Ben Gamari (@bgamari)
gitlab at gitlab.haskell.org
Tue Nov 15 13:59:28 UTC 2022
Ben Gamari pushed to branch wip/tsan/codegen at Glasgow Haskell Compiler / GHC
Commits:
430eccef by Ben Gamari at 2022-11-11T13:16:45-05:00
rts: Check for program_invocation_short_name via autoconf
Instead of assuming support on all Linuxes.
- - - - -
6dab0046 by Matthew Pickering at 2022-11-11T13:17:22-05:00
driver: Fix -fdefer-diagnostics flag
The `withDeferredDiagnostics` wrapper wasn't doing anything because the
session it was modifying wasn't used in hsc_env. Therefore the fix is
simple, just push the `getSession` call into the scope of
`withDeferredDiagnostics`.
Fixes #22391
- - - - -
d0c691b6 by Simon Peyton Jones at 2022-11-11T13:18:07-05:00
Add a fast path for data constructor workers
See Note [Fast path for data constructors] in
GHC.Core.Opt.Simplify.Iteration
This bypasses lots of expensive logic, in the special case of
applications of data constructors. It is a surprisingly worthwhile
improvement, as you can see in the figures below.
Metrics: compile_time/bytes allocated
------------------------------------------------
CoOpt_Read(normal) -2.0%
CoOpt_Singletons(normal) -2.0%
ManyConstructors(normal) -1.3%
T10421(normal) -1.9% GOOD
T10421a(normal) -1.5%
T10858(normal) -1.6%
T11545(normal) -1.7%
T12234(optasm) -1.3%
T12425(optasm) -1.9% GOOD
T13035(normal) -1.0% GOOD
T13056(optasm) -1.8%
T13253(normal) -3.3% GOOD
T15164(normal) -1.7%
T15304(normal) -3.4%
T15630(normal) -2.8%
T16577(normal) -4.3% GOOD
T17096(normal) -1.1%
T17516(normal) -3.1%
T18282(normal) -1.9%
T18304(normal) -1.2%
T18698a(normal) -1.2% GOOD
T18698b(normal) -1.5% GOOD
T18923(normal) -1.3%
T1969(normal) -1.3% GOOD
T19695(normal) -4.4% GOOD
T21839c(normal) -2.7% GOOD
T21839r(normal) -2.7% GOOD
T4801(normal) -3.8% GOOD
T5642(normal) -3.1% GOOD
T6048(optasm) -2.5% GOOD
T9020(optasm) -2.7% GOOD
T9630(normal) -2.1% GOOD
T9961(normal) -11.7% GOOD
WWRec(normal) -1.0%
geo. mean -1.1%
minimum -11.7%
maximum +0.1%
Metric Decrease:
T10421
T12425
T13035
T13253
T16577
T18698a
T18698b
T1969
T19695
T21839c
T21839r
T4801
T5642
T6048
T9020
T9630
T9961
- - - - -
3c37d30b by Krzysztof Gogolewski at 2022-11-11T19:18:39+01:00
Use a more efficient printer for code generation (#21853)
The changes in `GHC.Utils.Outputable` are the bulk of the patch
and drive the rest.
The types `HLine` and `HDoc` in Outputable can be used instead of `SDoc`
and support printing directly to a handle with `bPutHDoc`.
See Note [SDoc versus HDoc] and Note [HLine versus HDoc].
The classes `IsLine` and `IsDoc` are used to make the existing code polymorphic
over `HLine`/`HDoc` and `SDoc`. This is done for X86, PPC, AArch64, DWARF
and dependencies (printing module names, labels etc.).
Co-authored-by: Alexis King <lexi.lambda at gmail.com>
Metric Decrease:
CoOpt_Read
ManyAlternatives
ManyConstructors
T10421
T12425
T12707
T13035
T13056
T13253
T13379
T18140
T18282
T18698a
T18698b
T1969
T20049
T21839c
T21839r
T3064
T3294
T4801
T5321FD
T5321Fun
T5631
T6048
T783
T9198
T9233
- - - - -
6b92b47f by Matthew Craven at 2022-11-11T18:32:14-05:00
Weaken wrinkle 1 of Note [Scrutinee Constant Folding]
Fixes #22375.
Co-authored-by: Simon Peyton Jones <simon.peytonjones at gmail.com>
- - - - -
154c70f6 by Simon Peyton Jones at 2022-11-11T23:40:10+00:00
Fix fragile RULE setup in GHC.Float
In testing my type-vs-constraint patch I found that the handling
of Natural literals was very fragile -- and I somehow tripped that
fragility in my work.
So this patch fixes the fragility.
See Note [realToFrac natural-to-float]
This made a big (9%) difference in one existing test in
perf/should_run/T1-359
Metric Decrease:
T10359
- - - - -
778c6adc by Simon Peyton Jones at 2022-11-11T23:40:10+00:00
Type vs Constraint: finally nailed
This big patch addresses the rats-nest of issues that have plagued
us for years, about the relationship between Type and Constraint.
See #11715/#21623.
The main payload of the patch is:
* To introduce CONSTRAINT :: RuntimeRep -> Type
* To make TYPE and CONSTRAINT distinct throughout the compiler
Two overview Notes in GHC.Builtin.Types.Prim
* Note [TYPE and CONSTRAINT]
* Note [Type and Constraint are not apart]
This is the main complication.
The specifics
* New primitive types (GHC.Builtin.Types.Prim)
- CONSTRAINT
- ctArrowTyCon (=>)
- tcArrowTyCon (-=>)
- ccArrowTyCon (==>)
- funTyCon FUN -- Not new
See Note [Function type constructors and FunTy]
and Note [TYPE and CONSTRAINT]
* GHC.Builtin.Types:
- New type Constraint = CONSTRAINT LiftedRep
- I also stopped nonEmptyTyCon being built-in; it only needs to be wired-in
* Exploit the fact that Type and Constraint are distinct throughout GHC
- Get rid of tcView in favour of coreView.
- Many tcXX functions become XX functions.
e.g. tcGetCastedTyVar --> getCastedTyVar
* Kill off Note [ForAllTy and typechecker equality], in (old)
GHC.Tc.Solver.Canonical. It said that typechecker-equality should ignore
the specified/inferred distinction when comparein two ForAllTys. But
that wsa only weakly supported and (worse) implies that we need a separate
typechecker equality, different from core equality. No no no.
* GHC.Core.TyCon: kill off FunTyCon in data TyCon. There was no need for it,
and anyway now we have four of them!
* GHC.Core.TyCo.Rep: add two FunTyFlags to FunCo
See Note [FunCo] in that module.
* GHC.Core.Type. Lots and lots of changes driven by adding CONSTRAINT.
The key new function is sORTKind_maybe; most other changes are built
on top of that.
See also `funTyConAppTy_maybe` and `tyConAppFun_maybe`.
* Fix a longstanding bug in GHC.Core.Type.typeKind, and Core Lint, in
kinding ForAllTys. See new tules (FORALL1) and (FORALL2) in GHC.Core.Type.
(The bug was that before (forall (cv::t1 ~# t2). blah), where
blah::TYPE IntRep, would get kind (TYPE IntRep), but it should be
(TYPE LiftedRep). See Note [Kinding rules for types] in GHC.Core.Type.
* GHC.Core.TyCo.Compare is a new module in which we do eqType and cmpType.
Of course, no tcEqType any more.
* GHC.Core.TyCo.FVs. I moved some free-var-like function into this module:
tyConsOfType, visVarsOfType, and occCheckExpand. Refactoring only.
* GHC.Builtin.Types. Compiletely re-engineer boxingDataCon_maybe to
have one for each /RuntimeRep/, rather than one for each /Type/.
This dramatically widens the range of types we can auto-box.
See Note [Boxing constructors] in GHC.Builtin.Types
The boxing types themselves are declared in library ghc-prim:GHC.Types.
GHC.Core.Make. Re-engineer the treatment of "big" tuples (mkBigCoreVarTup
etc) GHC.Core.Make, so that it auto-boxes unboxed values and (crucially)
types of kind Constraint. That allows the desugaring for arrows to work;
it gathers up free variables (including dictionaries) into tuples.
See Note [Big tuples] in GHC.Core.Make.
There is still work to do here: #22336. But things are better than
before.
* GHC.Core.Make. We need two absent-error Ids, aBSENT_ERROR_ID for types of
kind Type, and aBSENT_CONSTRAINT_ERROR_ID for vaues of kind Constraint.
Ditto noInlineId vs noInlieConstraintId in GHC.Types.Id.Make;
see Note [inlineId magic].
* GHC.Core.TyCo.Rep. Completely refactor the NthCo coercion. It is now called
SelCo, and its fields are much more descriptive than the single Int we used to
have. A great improvement. See Note [SelCo] in GHC.Core.TyCo.Rep.
* GHC.Core.RoughMap.roughMatchTyConName. Collapse TYPE and CONSTRAINT to
a single TyCon, so that the rough-map does not distinguish them.
* GHC.Core.DataCon
- Mainly just improve documentation
* Some significant renamings:
GHC.Core.Multiplicity: Many --> ManyTy (easier to grep for)
One --> OneTy
GHC.Core.TyCo.Rep TyCoBinder --> GHC.Core.Var.PiTyBinder
GHC.Core.Var TyCoVarBinder --> ForAllTyBinder
AnonArgFlag --> FunTyFlag
ArgFlag --> ForAllTyFlag
GHC.Core.TyCon TyConTyCoBinder --> TyConPiTyBinder
Many functions are renamed in consequence
e.g. isinvisibleArgFlag becomes isInvisibleForAllTyFlag, etc
* I refactored FunTyFlag (was AnonArgFlag) into a simple, flat data type
data FunTyFlag
= FTF_T_T -- (->) Type -> Type
| FTF_T_C -- (-=>) Type -> Constraint
| FTF_C_T -- (=>) Constraint -> Type
| FTF_C_C -- (==>) Constraint -> Constraint
* GHC.Tc.Errors.Ppr. Some significant refactoring in the TypeEqMisMatch case
of pprMismatchMsg.
* I made the tyConUnique field of TyCon strict, because I
saw code with lots of silly eval's. That revealed that
GHC.Settings.Constants.mAX_SUM_SIZE can only be 63, because
we pack the sum tag into a 6-bit field. (Lurking bug squashed.)
Fixes
* #21530
Updates haddock submodule slightly.
Performance changes
~~~~~~~~~~~~~~~~~~~
I was worried that compile times would get worse, but after
some careful profiling we are down to a geometric mean 0.1%
increase in allocation (in perf/compiler). That seems fine.
There is a big runtime improvement in T10359
Metric Decrease:
LargeRecord
MultiLayerModulesTH_OneShot
T13386
T13719
Metric Increase:
T8095
- - - - -
360f5fec by Simon Peyton Jones at 2022-11-11T23:40:11+00:00
Indent closing "#-}" to silence HLint
- - - - -
e160cf47 by Krzysztof Gogolewski at 2022-11-12T08:05:28-05:00
Fix merge conflict in T18355.stderr
Fixes #22446
- - - - -
294f9073 by Simon Peyton Jones at 2022-11-12T23:14:13+00:00
Fix a trivial typo in dataConNonlinearType
Fixes #22416
- - - - -
268a3ce9 by Ben Gamari at 2022-11-14T09:36:57-05:00
eventlog: Ensure that IPE output contains actual info table pointers
The refactoring in 866c736e introduced a rather subtle change in the
semantics of the IPE eventlog output, changing the eventlog field from
encoding info table pointers to "TNTC pointers" (which point to entry
code when tables-next-to-code is enabled). Fix this.
Fixes #22452.
- - - - -
d91db679 by Matthew Pickering at 2022-11-14T16:48:10-05:00
testsuite: Add tests for T22347
These are fixed in recent versions but might as well add regression
tests.
See #22347
- - - - -
8f6c576b by Matthew Pickering at 2022-11-14T16:48:45-05:00
testsuite: Improve output from tests which have failing pre_cmd
There are two changes:
* If a pre_cmd fails, then don't attempt to run the test.
* If a pre_cmd fails, then print the stdout and stderr from running that
command (which hopefully has a nice error message).
For example:
```
=====> 1 of 1 [0, 0, 0]
*** framework failure for test-defaulting-plugin(normal) pre_cmd failed: 2
** pre_cmd was "$MAKE -s --no-print-directory -C defaulting-plugin package.test-defaulting-plugin TOP={top}".
stdout:
stderr:
DefaultLifted.hs:19:13: error: [GHC-76037]
Not in scope: type constructor or class ‘Typ’
Suggested fix:
Perhaps use one of these:
‘Type’ (imported from GHC.Tc.Utils.TcType),
data constructor ‘Type’ (imported from GHC.Plugins)
|
19 | instance Eq Typ where
| ^^^
make: *** [Makefile:17: package.test-defaulting-plugin] Error 1
Performance Metrics (test environment: local):
```
Fixes #22329
- - - - -
91859dd9 by Ben Gamari at 2022-11-15T08:50:04-05:00
Introduce blockConcat
- - - - -
0476cf7a by Ben Gamari at 2022-11-15T08:50:54-05:00
cmm: Introduce MemoryOrderings
- - - - -
1b018976 by Ben Gamari at 2022-11-15T08:50:54-05:00
llvm: Respect memory specified orderings
- - - - -
f72f0880 by Ben Gamari at 2022-11-15T08:50:54-05:00
Codegen/x86: Eliminate barrier for relaxed accesses
- - - - -
f36b4362 by Ben Gamari at 2022-11-15T08:50:54-05:00
cmm/Parser: Reduce some repetition
- - - - -
86dd0a19 by Ben Gamari at 2022-11-15T08:50:54-05:00
cmm/Parser: Add syntax for ordered loads and stores
- - - - -
13c0cac6 by Ben Gamari at 2022-11-15T08:50:54-05:00
cmm/Parser: Atomic load syntax
- - - - -
5c35709f by Ben Gamari at 2022-11-15T08:50:54-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.
- - - - -
c014f114 by Ben Gamari at 2022-11-15T08:50:54-05:00
rts/Messages: Refactor
- - - - -
1f21f189 by Ben Gamari at 2022-11-15T08:57:22-05:00
rts/ThreadPaused: Ordering fixes
- - - - -
498eff4d by Ben Gamari at 2022-11-15T08:57:34-05:00
eventlog: Silence spurious data race
- - - - -
e3beb8a8 by Ben Gamari at 2022-11-15T08:57:34-05:00
Introduce SET_INFO_RELEASE for Cmm
- - - - -
056e23d3 by Ben Gamari at 2022-11-15T08:57:34-05:00
unlockClosure
- - - - -
954bf147 by Ben Gamari at 2022-11-15T08:57:34-05:00
Introduce and use GET_INFO_ACQUIRE
- - - - -
40821e0d by Ben Gamari at 2022-11-15T08:57:34-05:00
Fences
- - - - -
c925fd28 by Ben Gamari at 2022-11-15T08:57:34-05:00
LOAD_INFO
- - - - -
4d3f74dd by Ben Gamari at 2022-11-15T08:57:34-05:00
rts/stm: Fix memory ordering in readTVarIO#
See #22421.
- - - - -
025cb62e by Ben Gamari at 2022-11-15T08:57:34-05:00
Improve heap memory barrier Note
Also introduce MUT_FIELD marker in Closures.h to document mutable
fields.
- - - - -
036b9b45 by Ben Gamari at 2022-11-15T08:57:34-05:00
load_acquire_w
- - - - -
aaafd3e1 by Ben Gamari at 2022-11-15T08:57:34-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.
- - - - -
03d01785 by Ben Gamari at 2022-11-15T08:57:34-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.
- - - - -
25c882db by Ben Gamari at 2022-11-15T08:57:34-05:00
rts: Always use atomics for context_switch and interrupt
Since these are modified by the timer handler.
- - - - -
5aa58633 by Ben Gamari at 2022-11-15T08:57:34-05:00
GET_INFO_ACQUIRE
- - - - -
6e025e84 by Ben Gamari at 2022-11-15T08:57:34-05:00
fences
- - - - -
cc3df670 by Ben Gamari at 2022-11-15T08:57:34-05:00
fence
- - - - -
28136cb0 by Ben Gamari at 2022-11-15T08:57:34-05:00
nonmoving: Silence benign data race warning from TSAN
- - - - -
5a055d5d by Ben Gamari at 2022-11-15T08:57:34-05:00
nonmoving: Fix race in marking of blackholes
We must use an acquire-fence when marking to ensure that the indirectee
is visible.
- - - - -
b3c08c05 by Ben Gamari at 2022-11-15T08:57:34-05:00
fences
- - - - -
859ca5b8 by Ben Gamari at 2022-11-15T08:57:34-05:00
nonmoving: Fix segment list races
- - - - -
4bd329ba by Ben Gamari at 2022-11-15T08:57:34-05:00
nonmoving: Use atomic when looking at bd->gen
- - - - -
0b7ece26 by Ben Gamari at 2022-11-15T08:57:34-05:00
nonmoving: Eliminate race in bump_static_flag
- - - - -
66ec2cd9 by Ben Gamari at 2022-11-15T08:57:34-05:00
nonmoving: Ensure that mutable fields have acquire barrier
- - - - -
ea5da0d9 by Ben Gamari at 2022-11-15T08:57:34-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.
- - - - -
ad79e1a4 by Ben Gamari at 2022-11-15T08:57:34-05:00
rts: Encapsulate recent_activity access
- - - - -
69c50120 by Ben Gamari at 2022-11-15T08:57:34-05:00
Updates
- - - - -
0df05cdf by Ben Gamari at 2022-11-15T08:57:34-05:00
nonmoving: Collection running
- - - - -
69236490 by Ben Gamari at 2022-11-15T08:57:34-05:00
Mark epoch
- - - - -
b2ea2ef6 by Ben Gamari at 2022-11-15T08:57:34-05:00
Segment state
- - - - -
f3fefa73 by Ben Gamari at 2022-11-15T08:57:34-05:00
capabilities
- - - - -
1299da8b by Ben Gamari at 2022-11-15T08:57:34-05:00
rts: Encapsulate sched_state
- - - - -
61e374f5 by Ben Gamari at 2022-11-15T08:57:34-05:00
rts/Proftimer: Encapsulate
- - - - -
9feeb7ad by Ben Gamari at 2022-11-15T08:57:34-05:00
hadrian: Don't enable TSAN in stage0 build
- - - - -
542553de by Ben Gamari at 2022-11-15T08:57:34-05:00
PrimOps: Fix benign MutVar race
- - - - -
19e407ce by Ben Gamari at 2022-11-15T08:57:35-05:00
rts: Style fix
- - - - -
617a46d7 by Ben Gamari at 2022-11-15T08:57:35-05:00
nonmoving: Refactor update remembered set initialization
This avoids a lock inversion between the storage manager mutex and
the stable pointer table mutex.
- - - - -
26 changed files:
- compiler/GHC.hs
- compiler/GHC/Builtin/Names.hs
- compiler/GHC/Builtin/PrimOps.hs
- compiler/GHC/Builtin/Types.hs
- compiler/GHC/Builtin/Types.hs-boot
- compiler/GHC/Builtin/Types/Literals.hs
- compiler/GHC/Builtin/Types/Prim.hs
- − compiler/GHC/Builtin/Types/Prim.hs-boot
- compiler/GHC/Builtin/Uniques.hs
- compiler/GHC/ByteCode/Types.hs
- compiler/GHC/Cmm/CLabel.hs
- compiler/GHC/Cmm/CLabel.hs-boot
- compiler/GHC/Cmm/Config.hs
- compiler/GHC/Cmm/ContFlowOpt.hs
- compiler/GHC/Cmm/Dataflow/Block.hs
- compiler/GHC/Cmm/DebugBlock.hs
- compiler/GHC/Cmm/Lexer.x
- compiler/GHC/Cmm/MachOp.hs
- compiler/GHC/Cmm/Parser.y
- compiler/GHC/Cmm/Pipeline.hs
- compiler/GHC/Cmm/Reg.hs
- + compiler/GHC/Cmm/ThreadSanitizer.hs
- compiler/GHC/CmmToAsm.hs
- compiler/GHC/CmmToAsm/AArch64.hs
- compiler/GHC/CmmToAsm/AArch64/CodeGen.hs
- compiler/GHC/CmmToAsm/AArch64/Ppr.hs
The diff was not included because it is too large.
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/daf2511f2b25790a5b47e9c242c039885a61ed6f...617a46d7005861fe2919403d87995f3f955d3b27
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/daf2511f2b25790a5b47e9c242c039885a61ed6f...617a46d7005861fe2919403d87995f3f955d3b27
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/20221115/58bd6c36/attachment-0001.html>
More information about the ghc-commits
mailing list