[Git][ghc/ghc][wip/simplifier-tweaks] 93 commits: JS: implement getMonotonicTime (fix #23687)
Simon Peyton Jones (@simonpj)
gitlab at gitlab.haskell.org
Wed Aug 9 22:31:15 UTC 2023
Simon Peyton Jones pushed to branch wip/simplifier-tweaks at Glasgow Haskell Compiler / GHC
Commits:
33598ecb by Sylvain Henry at 2023-08-01T14:45:54-04:00
JS: implement getMonotonicTime (fix #23687)
- - - - -
d2bedffd by Bartłomiej Cieślar at 2023-08-01T14:46:40-04:00
Implementation of the Deprecated Instances proposal #575
This commit implements the ability to deprecate certain instances,
which causes the compiler to emit the desired deprecation message
whenever they are instantiated. For example:
module A where
class C t where
instance {-# DEPRECATED "dont use" #-} C Int where
module B where
import A
f :: C t => t
f = undefined
g :: Int
g = f -- "dont use" emitted here
The implementation is as follows:
- In the parser, we parse deprecations/warnings attached to instances:
instance {-# DEPRECATED "msg" #-} Show X
deriving instance {-# WARNING "msg2" #-} Eq Y
(Note that non-standalone deriving instance declarations do not support
this mechanism.)
- We store the resulting warning message in `ClsInstDecl` (respectively, `DerivDecl`).
In `GHC.Tc.TyCl.Instance.tcClsInstDecl` (respectively, `GHC.Tc.Deriv.Utils.newDerivClsInst`),
we pass on that information to `ClsInst` (and eventually store it in `IfaceClsInst` too).
- Finally, when we solve a constraint using such an instance, in
`GHC.Tc.Instance.Class.matchInstEnv`, we emit the appropriate warning
that was stored in `ClsInst`.
Note that we only emit a warning when the instance is used in a different module
than it is defined, which keeps the behaviour in line with the deprecation of
top-level identifiers.
Signed-off-by: Bartłomiej Cieślar <bcieslar2001 at gmail.com>
- - - - -
d5a65af6 by Ben Gamari at 2023-08-01T14:47:18-04:00
compiler: Style fixes
- - - - -
7218c80a by Ben Gamari at 2023-08-01T14:47:19-04:00
rts: Fix implicit cast
This ensures that Task.h can be built with a C++ compiler.
- - - - -
d6d5aafc by Ben Gamari at 2023-08-01T14:47:19-04:00
testsuite: Fix warning in hs_try_putmvar001
- - - - -
d9eddf7a by Ben Gamari at 2023-08-01T14:47:19-04:00
testsuite: Add AtomicModifyIORef test
- - - - -
f9eea4ba by Ben Gamari at 2023-08-01T14:47:19-04:00
rts: Introduce NO_WARN macro
This allows fine-grained ignoring of warnings.
- - - - -
497b24ec by Ben Gamari at 2023-08-01T14:47:19-04:00
rts: Simplify atomicModifyMutVar2# implementation
Previously we would perform a redundant load in the non-threaded RTS in
atomicModifyMutVar2# implementation for the benefit of the non-moving
GC's write barrier. Eliminate this.
- - - - -
52ee082b by Ben Gamari at 2023-08-01T14:47:19-04:00
rts: Introduce more principled fence operations
- - - - -
cd3c0377 by Ben Gamari at 2023-08-01T14:47:19-04:00
rts: Introduce SET_INFO_RELAXED
- - - - -
6df2352a by Ben Gamari at 2023-08-01T14:47:19-04:00
rts: Style fixes
- - - - -
4ef6f319 by Ben Gamari at 2023-08-01T14:47:19-04:00
codeGen/tsan: Rework handling of spilling
- - - - -
f9ca7e27 by Ben Gamari at 2023-08-01T14:47:19-04:00
hadrian: More debug information
- - - - -
df4153ac by Ben Gamari at 2023-08-01T14:47:19-04:00
Improve TSAN documentation
- - - - -
fecae988 by Ben Gamari at 2023-08-01T14:47:19-04:00
hadrian: More selective TSAN instrumentation
- - - - -
465a9a0b by Alan Zimmerman at 2023-08-01T14:47:56-04:00
EPA: Provide correct annotation span for ImportDecl
Use the whole declaration, rather than just the span of the 'import'
keyword.
Metric Decrease:
T9961
T5205
Metric Increase:
T13035
- - - - -
ae63d0fa by Bartłomiej Cieślar at 2023-08-01T14:48:40-04:00
Add cases to T23279: HasField for deprecated record fields
This commit adds additional tests from ticket #23279 to ensure that we don't
regress on reporting deprecated record fields in conjunction with HasField,
either when using overloaded record dot syntax or directly through `getField`.
Fixes #23279
- - - - -
00fb6e6b by Andreas Klebinger at 2023-08-01T14:49:17-04:00
AArch NCG: Pure refactor
Combine some alternatives. Add some line breaks for overly long lines
- - - - -
8f3b3b78 by Andreas Klebinger at 2023-08-01T14:49:54-04:00
Aarch ncg: Optimize immediate use for address calculations
When the offset doesn't fit into the immediate we now just reuse the
general getRegister' code path which is well optimized to compute the
offset into a register instead of a special case for CmmRegOff.
This means we generate a lot less code under certain conditions which is
why performance metrics for these improve.
-------------------------
Metric Decrease:
T4801
T5321FD
T5321Fun
-------------------------
- - - - -
74a882dc by MorrowM at 2023-08-02T06:00:03-04:00
Add a RULE to make lookup fuse
See https://github.com/haskell/core-libraries-committee/issues/175
Metric Increase:
T18282
- - - - -
cca74dab by Ben Gamari at 2023-08-02T06:00:39-04:00
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.
- - - - -
622b483c by Jaro Reinders at 2023-08-02T06:01:20-04:00
Native 32-bit Enum Int64/Word64 instances
This commits adds more performant Enum Int64 and Enum Word64 instances
for 32-bit platforms, replacing the Integer-based implementation.
These instances are a copy of the Enum Int and Enum Word instances with
minimal changes to manipulate Int64 and Word64 instead.
On i386 this yields a 1.5x performance increase and for the JavaScript
back end it even yields a 5.6x speedup.
Metric Decrease:
T18964
- - - - -
c8bd7fa4 by Sylvain Henry at 2023-08-02T06:02:03-04:00
JS: fix typos in constants (#23650)
- - - - -
b9d5bfe9 by Josh Meredith at 2023-08-02T06:02:40-04:00
JavaScript: update MK_TUP macros to use current tuple constructors (#23659)
- - - - -
28211215 by Matthew Pickering at 2023-08-02T06:03:19-04:00
ci: Pass -Werror when building hadrian in hadrian-ghc-in-ghci job
Warnings when building Hadrian can end up cluttering the output of HLS,
and we've had bug reports in the past about these warnings when building
Hadrian. It would be nice to turn on -Werror on at least one build of
Hadrian in CI to avoid a patch introducing warnings when building
Hadrian.
Fixes #23638
- - - - -
aca20a5d by Ben Gamari at 2023-08-02T06:03:55-04:00
codeGen: Ensure that TSAN is aware of writeArray# write barriers
By using a proper release store instead of a fence.
- - - - -
453c0531 by Ben Gamari at 2023-08-02T06:03:55-04:00
codeGen: Ensure that array reads have necessary barriers
This was the cause of #23541.
- - - - -
93a0d089 by Arnaud Spiwack at 2023-08-02T06:04:37-04:00
Add test for #23550
- - - - -
6a2f4a20 by Arnaud Spiwack at 2023-08-02T06:04:37-04:00
Desugar non-recursive lets to non-recursive lets (take 2)
This reverts commit 522bd584f71ddeda21efdf0917606ce3d81ec6cc. And
takes care of the case that I missed in my previous attempt. Namely
the case of an AbsBinds with no type variables and no dictionary
variable.
Ironically, the comment explaining why non-recursive lets were
desugared to recursive lets were pointing specifically at this case
as the reason. I just failed to understand that it was until Simon PJ
pointed it out to me.
See #23550 for more discussion.
- - - - -
ff81d53f by jade at 2023-08-02T06:05:20-04:00
Expand documentation of List & Data.List
This commit aims to improve the documentation and examples
of symbols exported from Data.List
- - - - -
fa4e5913 by Jade at 2023-08-02T06:06:03-04:00
Improve documentation of Semigroup & Monoid
This commit aims to improve the documentation of various symbols
exported from Data.Semigroup and Data.Monoid
- - - - -
e2c91bff by Gergő Érdi at 2023-08-03T02:55:46+01:00
Desugar bindings in the context of their evidence
Closes #23172
- - - - -
481f4a46 by Gergő Érdi at 2023-08-03T07:48:43+01:00
Add flag to `-f{no-}specialise-incoherents` to enable/disable specialisation of
incoherent instances
Fixes #23287
- - - - -
d751c583 by Profpatsch at 2023-08-04T12:24:26-04:00
base: Improve String & IsString documentation
- - - - -
01db1117 by Ben Gamari at 2023-08-04T12:25:02-04:00
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.
- - - - -
fdef003a by Ryan Scott at 2023-08-04T12:25:39-04:00
Look through TH splices in splitHsApps
This modifies `splitHsApps` (a key function used in typechecking function
applications) to look through untyped TH splices and quasiquotes. Not doing so
was the cause of #21077. This builds on !7821 by making `splitHsApps` match on
`HsUntypedSpliceTop`, which contains the `ThModFinalizers` that must be run as
part of invoking the TH splice. See the new `Note [Looking through Template
Haskell splices in splitHsApps]` in `GHC.Tc.Gen.Head`.
Along the way, I needed to make the type of `splitHsApps.set` slightly more
general to accommodate the fact that the location attached to a quasiquote is
a `SrcAnn NoEpAnns` rather than a `SrcSpanAnnA`.
Fixes #21077.
- - - - -
e77a0b41 by Ben Gamari at 2023-08-04T12:26:15-04:00
Bump deepseq submodule to 1.5.
And bump bounds
(cherry picked from commit 1228d3a4a08d30eaf0138a52d1be25b38339ef0b)
- - - - -
cebb5819 by Ben Gamari at 2023-08-04T12:26:15-04:00
configure: Bump minimal boot GHC version to 9.4
(cherry picked from commit d3ffdaf9137705894d15ccc3feff569d64163e8e)
- - - - -
83766dbf by Ben Gamari at 2023-08-04T12:26:15-04:00
template-haskell: Bump version to 2.21.0.0
Bumps exceptions submodule.
(cherry picked from commit bf57fc9aea1196f97f5adb72c8b56434ca4b87cb)
- - - - -
1211112a by Ben Gamari at 2023-08-04T12:26:15-04:00
base: Bump version to 4.19
Updates all boot library submodules.
(cherry picked from commit 433d99a3c24a55b14ec09099395e9b9641430143)
- - - - -
3ab5efd9 by Ben Gamari at 2023-08-04T12:26:15-04:00
testsuite: Normalise versions more aggressively
In backpack hashes can contain `+` characters.
(cherry picked from commit 024861af51aee807d800e01e122897166a65ea93)
- - - - -
d52be957 by Ben Gamari at 2023-08-04T12:26:15-04:00
testsuite: Declare bkpcabal08 as fragile
Due to spurious output changes described in #23648.
(cherry picked from commit c046a2382420f2be2c4a657c56f8d95f914ea47b)
- - - - -
e75a58d1 by Ben Gamari at 2023-08-04T12:26:15-04:00
gitlab-ci: Only mark linker_unload_native as broken in static jobs
This test passes on dynamically-linked Alpine.
(cherry picked from commit f356a7e8ec8ec3d6b2b30fd175598b9b80065d87)
- - - - -
8b176514 by Ben Gamari at 2023-08-04T12:26:15-04:00
testsuite: Update base-exports
- - - - -
4b647936 by Ben Gamari at 2023-08-04T12:26:15-04:00
testsuite/interface-stability: normalise versions
This eliminates spurious changes from version bumps.
- - - - -
0eb54c05 by Ben Gamari at 2023-08-04T12:26:51-04:00
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.
- - - - -
fd7ce39c by Ben Gamari at 2023-08-04T12:27:28-04:00
testsuite: Mark MulMayOflo_full as broken rather than skipping
To ensure that we don't accidentally fix it.
See #23742.
- - - - -
824092f2 by Ben Gamari at 2023-08-04T12:27:28-04:00
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.
- - - - -
1b15dbc4 by Jan Hrček at 2023-08-04T12:28:08-04:00
Fix haddock markup in code example for coerce
- - - - -
46fd8ced by Vladislav Zavialov at 2023-08-04T12:28:44-04:00
Fix (~) and (@) infix operators in TH splices (#23748)
8168b42a "Whitespace-sensitive bang patterns" allows GHC to accept
the following infix operators:
a ~ b = ()
a @ b = ()
But not if TH is used to generate those declarations:
$([d| a ~ b = ()
a @ b = ()
|])
-- Test.hs:5:2: error: [GHC-55017]
-- Illegal variable name: ‘~’
-- When splicing a TH declaration: (~_0) a_1 b_2 = GHC.Tuple.Prim.()
This is easily fixed by modifying `reservedOps` in GHC.Utils.Lexeme
- - - - -
a1899d8f by Aaron Allen at 2023-08-04T12:29:24-04:00
[#23663] Show Flag Suggestions in GHCi
Makes suggestions when using `:set` in GHCi with a misspelled flag. This
mirrors how invalid flags are handled when passed to GHC directly. Logic
for producing flag suggestions was moved to GHC.Driver.Sesssion so it
can be shared.
resolves #23663
- - - - -
03f2debd by Rodrigo Mesquita at 2023-08-04T12:30:00-04:00
Improve ghc-toolchain validation configure warning
Fixes the layout of the ghc-toolchain validation warning produced by
configure.
- - - - -
de25487d by Alan Zimmerman at 2023-08-04T12:30:36-04:00
EPA make getLocA a synonym for getHasLoc
This is basically a no-op change, but allows us to make future changes
that can rely on the HasLoc instances
And I presume this means we can use more precise functions based on
class resolution, so the Windows CI build reports
Metric Decrease:
T12234
T13035
- - - - -
3ac423b9 by Ben Gamari at 2023-08-04T12:31:13-04:00
ghc-platform: Add upper bound on base
Hackage upload requires this.
- - - - -
8ba20b21 by Matthew Craven at 2023-08-04T17:22:59-04:00
Adjust and clarify handling of primop effects
Fixes #17900; fixes #20195.
The existing "can_fail" and "has_side_effects" primop attributes
that previously governed this were used in inconsistent and
confusingly-documented ways, especially with regard to raising
exceptions. This patch replaces them with a single "effect"
attribute, which has four possible values: NoEffect, CanFail,
ThrowsException, and ReadWriteEffect. These are described in
Note [Classifying primop effects].
A substantial amount of related documentation has been re-drafted
for clarity and accuracy.
In the process of making this attribute format change for literally
every primop, several existing mis-classifications were detected and
corrected. One of these mis-classifications was tagToEnum#, which
is now considered CanFail; this particular fix is known to cause a
regression in performance for derived Enum instances. (See #23782.)
Fixing this is left as future work.
New primop attributes "cheap" and "work_free" were also added,
and used in the corresponding parts of GHC.Core.Utils.
In view of their actual meaning and uses, `primOpOkForSideEffects`
and `exprOkForSideEffects` have been renamed to `primOpOkToDiscard`
and `exprOkToDiscard`, respectively.
Metric Increase:
T21839c
- - - - -
41bf2c09 by sheaf at 2023-08-04T17:23:42-04:00
Update inert_solved_dicts for ImplicitParams
When adding an implicit parameter dictionary to the inert set, we must
make sure that it replaces any previous implicit parameter dictionaries
that overlap, in order to get the appropriate shadowing behaviour, as in
let ?x = 1 in let ?x = 2 in ?x
We were already doing this for inert_cans, but we weren't doing the same
thing for inert_solved_dicts, which lead to the bug reported in #23761.
The fix is thus to make sure that, when handling an implicit parameter
dictionary in updInertDicts, we update **both** inert_cans and
inert_solved_dicts to ensure a new implicit parameter dictionary
correctly shadows old ones.
Fixes #23761
- - - - -
43578d60 by Matthew Craven at 2023-08-05T01:05:36-04:00
Bump bytestring submodule to 0.11.5.1
- - - - -
91353622 by Ben Gamari at 2023-08-05T01:06:13-04:00
Initial commit of Note [Thunks, blackholes, and indirections]
This Note attempts to summarize the treatment of thunks, thunk update,
and indirections.
This fell out of work on #23185.
- - - - -
8d686854 by sheaf at 2023-08-05T01:06:54-04:00
Remove zonk in tcVTA
This removes the zonk in GHC.Tc.Gen.App.tc_inst_forall_arg and its
accompanying Note [Visible type application zonk]. Indeed, this zonk
is no longer necessary, as we no longer maintain the invariant that
types are well-kinded without zonking; only that typeKind does not
crash; see Note [The Purely Kinded Type Invariant (PKTI)].
This commit removes this zonking step (as well as a secondary zonk),
and replaces the aforementioned Note with the explanatory
Note [Type application substitution], which justifies why the
substitution performed in tc_inst_forall_arg remains valid without
this zonking step.
Fixes #23661
- - - - -
19dea673 by Ben Gamari at 2023-08-05T01:07:30-04:00
Bump nofib submodule
Ensuring that nofib can be build using the same range of bootstrap
compilers as GHC itself.
- - - - -
aa07402e by Luite Stegeman at 2023-08-05T23:15:55+09:00
JS: Improve compatibility with recent emsdk
The JavaScript code in libraries/base/jsbits/base.js had some
hardcoded offsets for fields in structs, because we expected
the layout of the data structures to remain unchanged. Emsdk
3.1.42 changed the layout of the stat struct, breaking this
assumption, and causing code in .hsc files accessing the
stat struct to fail.
This patch improves compatibility with recent emsdk by
removing the assumption that data layouts stay unchanged:
1. offsets of fields in structs used by JavaScript code are
now computed by the configure script, so both the .js and
.hsc files will automatically use the new layout if anything
changes.
2. the distrib/configure script checks that the emsdk version
on a user's system is the same version that a bindist was
booted with, to avoid data layout inconsistencies
See #23641
- - - - -
b938950d by Luite Stegeman at 2023-08-07T06:27:51-04:00
JS: Fix missing local variable declarations
This fixes some missing local variable declarations that were
found by running the testsuite in strict mode.
Fixes #23775
- - - - -
6c0e2247 by sheaf at 2023-08-07T13:31:21-04:00
Update Haddock submodule to fix #23368
This submodule update adds the following three commits:
bbf1c8ae - Check for puns
0550694e - Remove fake exports for (~), List, and Tuple<n>
5877bceb - Fix pretty-printing of Solo and MkSolo
These commits fix the issues with Haddock HTML rendering reported in
ticket #23368.
Fixes #23368
- - - - -
5b5be3ea by Matthew Pickering at 2023-08-07T13:32:00-04:00
Revert "Bump bytestring submodule to 0.11.5.1"
This reverts commit 43578d60bfc478e7277dcd892463cec305400025.
Fixes #23789
- - - - -
01961be3 by Ben Gamari at 2023-08-08T02:47:14-04:00
configure: Derive library version from ghc-prim.cabal.in
Since ghc-prim.cabal is now generated by Hadrian, we cannot depend upon
it.
Closes #23726.
- - - - -
3b373838 by Ryan Scott at 2023-08-08T02:47:49-04:00
tcExpr: Push expected types for untyped TH splices inwards
In !10911, I deleted a `tcExpr` case for `HsUntypedSplice` in favor of a much
simpler case that simply delegates to `tcApp`. Although this passed the test
suite at the time, this was actually an error, as the previous `tcExpr` case
was critically pushing the expected type inwards. This actually matters for
programs like the one in #23796, which GHC would not accept with type inference
alone—we need full-blown type _checking_ to accept these.
I have added back the previous `tcExpr` case for `HsUntypedSplice` and now
explain why we have two different `HsUntypedSplice` cases (one in `tcExpr` and
another in `splitHsApps`) in `Note [Looking through Template Haskell splices in
splitHsApps]` in `GHC.Tc.Gen.Head`.
Fixes #23796.
- - - - -
0ef1d8ae by sheaf at 2023-08-08T21:26:51-04:00
Compute all emitted diagnostic codes
This commit introduces in GHC.Types.Error.Codes the function
constructorCodes :: forall diag. (...) => Map DiagnosticCode String
which computes a collection of all the diagnostic codes that correspond
to a particular type. In particular, we can compute the collection of
all diagnostic codes emitted by GHC using the invocation
constructorCodes @GhcMessage
We then make use of this functionality in the new "codes" test which
checks consistency and coverage of GHC diagnostic codes.
It performs three checks:
- check 1: all non-outdated GhcDiagnosticCode equations
are statically used.
- check 2: all outdated GhcDiagnosticCode equations
are statically unused.
- check 3: all statically used diagnostic codes are covered by
the testsuite (modulo accepted exceptions).
- - - - -
4bc7b1e5 by Fraser Tweedale at 2023-08-08T21:27:32-04:00
numberToRangedRational: fix edge cases for exp ≈ (maxBound :: Int)
Currently a negative exponent less than `minBound :: Int` results in
Infinity, which is very surprising and obviously wrong.
```
λ> read "1e-9223372036854775808" :: Double
0.0
λ> read "1e-9223372036854775809" :: Double
Infinity
```
There is a further edge case where the exponent can overflow when
increased by the number of tens places in the integer part, or
underflow when decreased by the number of leading zeros in the
fractional part if the integer part is zero:
```
λ> read "10e9223372036854775807" :: Double
0.0
λ> read "0.01e-9223372036854775808" :: Double
Infinity
```
To resolve both of these issues, perform all arithmetic and
comparisons involving the exponent in type `Integer`. This approach
also eliminates the need to explicitly check the exponent against
`maxBound :: Int` and `minBound :: Int`, because the allowed range
of the exponent (i.e. the result of `floatRange` for the target
floating point type) is certainly within those bounds.
This change implements CLC proposal 192:
https://github.com/haskell/core-libraries-committee/issues/192
- - - - -
6eab07b2 by Alan Zimmerman at 2023-08-08T21:28:10-04:00
EPA: Remove Location from WarningTxt source
This is not needed.
- - - - -
1a98d673 by Sebastian Graf at 2023-08-09T16:24:29-04:00
Cleanup a TODO introduced in 1f94e0f7
The change must have slipped through review of !4412
- - - - -
2274abc8 by Sebastian Graf at 2023-08-09T16:24:29-04:00
More explicit strictness in GHC.Real
- - - - -
ce8aa54c by Sebastian Graf at 2023-08-09T16:24:30-04:00
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.)
- - - - -
d004a36d by Sebastian Graf at 2023-08-09T16:24:30-04:00
Simplify: Simplification of arguments in a single function
The Simplifier had a function `simplArg` that wasn't called in `rebuildCall`,
which seems to be the main way to simplify args. Hence I consolidated the code
path to call `simplArg`, too, renaming to `simplLazyArg`.
- - - - -
8c73505e by Sebastian Graf at 2023-08-09T16:24:30-04:00
Core.Ppr: Omit case binder for empty case alternatives
A minor improvement to pretty-printing
- - - - -
d8d993f1 by Sebastian Graf at 2023-08-09T16:24:30-04:00
Disable tests RepPolyWrappedVar2 and RepPolyUnsafeCoerce1 in JS backend
... because those coerce between incompatible/unknown PrimReps.
- - - - -
f06e87e4 by Sebastian Graf at 2023-08-09T16:24:30-04:00
Inlining literals into boring contexts is OK
- - - - -
4a6b7c87 by Sebastian Graf at 2023-08-09T16:24:30-04:00
Clarify floating of unsafeEqualityProofs (#23754)
- - - - -
b0f4752e by Sebastian Graf at 2023-08-09T16:24:30-04:00
Kill SetLevel.notWorthFloating.is_triv (#23270)
We have had it since b84ba676034, when it operated on annotated expressions.
Nowadays it operates on vanilla `CoreExpr` though, so we should just call
`exprIsTrivial`; thus handling empty cases and string literals correctly.
- - - - -
7e0c8b3b by Sebastian Graf at 2023-08-09T16:24:30-04:00
ANFise string literal arguments (#23270)
This instates the invariant that a trivial CoreExpr translates to an atomic
StgExpr. Nice.
Annoyingly, in -O0 we sometimes generate
```
foo = case "blah"# of sat { __DEFAULT -> unpackCString# sat }
```
which makes it a bit harder to spot that we can emit a standard
`stg_unpack_cstring` thunk.
Fixes #23270.
- - - - -
357f2738 by Sebastian Graf at 2023-08-09T16:24:30-04:00
Deactivate -fcatch-nonexhaustive-cases in ghc-bignum (#23345)
- - - - -
59202c80 by Sebastian Graf at 2023-08-09T16:24:30-04:00
CorePrep: Eliminate EmptyCase and unsafeEqualityProof in CoreToStg instead
We eliminate EmptyCase by way of `coreToStg (Case e _ _ []) = coreToStg e` now.
The main reason is that it plays far better in conjunction with eta expansion
(as we aim to do for arguments in CorePrep, #23083), because we can discard
any arguments, `(case e of {}) eta == case e of {}`, whereas in `(e |> co) eta`
it's impossible to discard the argument.
We do also give the same treatment to unsafeCoerce proofs and treat them as
trivial iff their RHS is trivial.
It is also both much simpler to describe than the previous mechanism of emitting
an unsafe coercion and simpler to implement, removing quite a bit of commentary
and `CorePrepProv`.
In the ghc/alloc perf test `LargeRecord`, we introduce an additional Simplifier
iteration due to #17910. E.g., FloatOut produces a binding
```
lvl_s6uK [Occ=Once1] :: GHC.Types.Int
[LclId]
lvl_s6uK = GHC.Types.I# 2#
lvl_s6uL [Occ=Once1] :: GHC.Types.Any
[LclId]
lvl_s6uL
= case Unsafe.Coerce.unsafeEqualityProof ... of
{ Unsafe.Coerce.UnsafeRefl v2_i6tr -> lvl_s6uK `cast` (... v2_i6tr ...)
}
```
That occurs once and hence is pre-inlined unconditionally in the next Simplifier
pass. It's non-trivial to find a way around that, but not really harmful
otherwise. Hence we accept a 1.2% increase on some architectures.
Metric Increase:
LargeRecord
- - - - -
00d31188 by Sebastian Graf at 2023-08-09T16:24:30-04:00
CorePrep: Eta expand arguments (#23083)
Previously, we'd only eta expand let bindings and lambdas,
now we'll also eta expand arguments such as in T23083:
```hs
g f h = f (h `seq` (h $))
```
Unless `-fpedantic-bottoms` is set, we'll now transform to
```hs
g f h = f (\eta -> h eta)
```
in CorePrep.
See the new `Note [Eta expansion of arguments in CorePrep]` for the details.
We only do this optimisation with -O2 because we saw 2-3% ghc/alloc regressions
in T4801 and T5321FD.
Fixes #23083.
- - - - -
bf885d7a by Matthew Craven at 2023-08-09T16:25:07-04:00
Bump bytestring submodule to 0.11.5, again
Fixes #23789.
The bytestring commit used here is unreleased;
a release can be made when necessary.
- - - - -
7f967fc8 by Simon Peyton Jones at 2023-08-09T23:30:09+01:00
Several improvements to the handling of coercions
* Make `mkSymCo` and `mkInstCo` smarter
Fixes #23642
* Fix return role of `SelCo` in the coercion optimiser.
Fixes #23617
* Make the coercion optimiser `opt_trans_rule` work better for newtypes
Fixes #23619
- - - - -
780aa756 by Simon Peyton Jones at 2023-08-09T23:30:09+01:00
Simplifier improvements
This MR started as: allow the simplifer to do more in one pass,
arising from places I could see the simplifier taking two iterations
where one would do. But it turned into a larger project, because
these changes unexpectedly made inlining blow up, especially join
points in deeply-nested cases.
The net result is good: a 2% improvement in compile time. The table
below shows changes over 1%.
The main changes are:
* The SimplEnv now has a seInlineDepth field, which says how deep
in unfoldings we are. See Note [Inline depth] in Simplify.Env
* Avoid repeatedly simplifying coercions.
see Note [Avoid re-simplifying coercions] in Simplify.Iteration
As you'll see from the Note, this makes use of the seInlineDepth.
* Allow Simplify.Utils.postInlineUnconditionally to inline variables
that are used exactly once. See Note [Post-inline for single-use things].
* Allow Simplify.Iteration.simplAuxBind to inline used-once things.
This is another part of Note [Post-inline for single-use things], and
is really good for reducing simplifier iterations in situations like
case K e of { K x -> blah }
wher x is used once in blah.
* Make GHC.Core.SimpleOpt.exprIsConApp_maybe do some simple case
elimination. Note [Case elim in exprIsConApp_maybe]
* When making join points, don't do so if the join point is so small
it will immediately be inlined. See Note [Duplicating alternatives]
* Do not add an unfolding to a join point at birth. This is a tricky one
and has a long Note [Do not add unfoldings to join points at birth]
It shows up in two places
- In `mkDupableAlt` do not add an inlining
- (trickier) In `simplLetUnfolding` don't add an unfolding for a
fresh join point
I am not fully satisifed with this, but it works and is well documented.
* Many new or rewritten Notes. E.g. Note [Avoiding simplifying repeatedly]
I discovered that GHC.HsToCore.Pmc.Solver.Types.trvVarInfo was very
delicately balanced. It's a small, heavily used, overloaded function
and it's important that it inlines. By a fluke it was before, but at
various times in my journey it stopped doing so. So I added an INLINE
pragma to it.
Metrics: compile_time/bytes allocated
------------------------------------------------
CoOpt_Singletons(normal) -4.3% GOOD
LargeRecord(normal) -23.3% GOOD
PmSeriesS(normal) -2.4%
T11195(normal) -1.7%
T12227(normal) -20.0% GOOD
T12545(normal) -5.4%
T13253-spj(normal) -50.7% GOOD
T13386(normal) -5.1% GOOD
T14766(normal) -2.4% GOOD
T15164(normal) -1.7%
T15304(normal) +1.0%
T15630(normal) -7.7%
T15630a(normal) NEW
T15703(normal) -7.5% GOOD
T16577(normal) -5.1% GOOD
T17516(normal) -3.6%
T18223(normal) -16.8% GOOD
T18282(normal) -1.5%
T18304(normal) +1.9%
T21839c(normal) -3.5% GOOD
T3064(normal) -1.5%
T5030(normal) -16.2% GOOD
T5321Fun(normal) -1.6%
T6048(optasm) -2.1% GOOD
T8095(normal) -6.1% GOOD
T9630(normal) -5.1% GOOD
WWRec(normal) -1.6%
geo. mean -2.1%
minimum -50.7%
maximum +1.9%
Metric Decrease:
CoOpt_Singletons
LargeRecord
T12227
T13253-spj
T13386
T14766
T15703
T16577
T18223
T21839c
T5030
T6048
T8095
T9630
- - - - -
4fa90861 by Simon Peyton Jones at 2023-08-09T23:30:09+01:00
Improve postInlineUnconditionally
This commit adds two things to postInlineUnconditionally:
1. Do not postInlineUnconditionally join point, ever.
Doing so does not reduce allocation, which is the main point,
and with join points that are used a lot it can bloat code.
See point (1) of Note [Duplicating join points] in
GHC.Core.Opt.Simplify.Iteration.
2. Do not postInlineUnconditionally a strict (demanded) binding.
It will not allocate a thunk (it'll turn into a case instead)
so again the main point of inlining it doesn't hold. Better
to check per-call-site.
- - - - -
3fbc6fb5 by Simon Peyton Jones at 2023-08-09T23:30:59+01:00
Update testsuite output
- - - - -
7dc2aafd by Simon Peyton Jones at 2023-08-09T23:30:59+01:00
Try effect of
* making multi-branch cases not work free (fixes #22423)
* use plan A for dataToTag and tagToEnum
- - - - -
6bfeb2f3 by Simon Peyton Jones at 2023-08-09T23:30:59+01:00
More changes
* No floating at all for join points
* Never inline j x = I x
Example: integerSignum !j = IS (integerSignum# j)
We want this to inline and then cancel with an enclosing case.
But it won't if we have changed it to
integerSignum x = case x of
IN a -> IS (...)
IS b -> IS (...)
IP c -> IS (...)
This involved changing
- UnfoldingGuidance to not say always-inline for j x = Ix
- callSiteInline to inline join points only if there is a real
benefit
- ok_to_dup_alt in Simplify.Iteration
* Row back (for now) on changes to GHC.Core.Utils.ExprIsCheap
- - - - -
76c54520 by Simon Peyton Jones at 2023-08-09T23:31:00+01:00
Wibble
- - - - -
0827304d by Simon Peyton Jones at 2023-08-09T23:31:00+01:00
Wibble
- - - - -
d0498f24 by Simon Peyton Jones at 2023-08-09T23:31:00+01:00
Further wibbles
- - - - -
7aa72977 by Simon Peyton Jones at 2023-08-09T23:31:01+01:00
One more wibble
Don't float an unlifted join point
- - - - -
12 changed files:
- .gitlab-ci.yml
- .gitlab/generate-ci/gen_ci.hs
- .gitlab/jobs.yaml
- compiler/GHC/Builtin/PrimOps.hs
- compiler/GHC/Builtin/primops.txt.pp
- compiler/GHC/Cmm/Parser.y
- compiler/GHC/Cmm/ThreadSanitizer.hs
- compiler/GHC/CmmToAsm/AArch64/CodeGen.hs
- compiler/GHC/Core.hs
- compiler/GHC/Core/Coercion.hs
- compiler/GHC/Core/Coercion/Opt.hs
- compiler/GHC/Core/FVs.hs
The diff was not included because it is too large.
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b86105011f27bc5d86b25a8a37593d7acb6b6ce5...7aa729774b16bf33ce3dbb4f2cfb69f9ec35e706
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b86105011f27bc5d86b25a8a37593d7acb6b6ce5...7aa729774b16bf33ce3dbb4f2cfb69f9ec35e706
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/20230809/e3f4c80c/attachment-0001.html>
More information about the ghc-commits
mailing list