[Git][ghc/ghc][wip/T18389] 34 commits: Make typechecker equality consider visibility in ForAllTys
Ryan Scott
gitlab at gitlab.haskell.org
Sat Nov 7 14:19:11 UTC 2020
Ryan Scott pushed to branch wip/T18389 at Glasgow Haskell Compiler / GHC
Commits:
57c3db96 by Ryan Scott at 2020-10-31T02:53:55-04:00
Make typechecker equality consider visibility in ForAllTys
Previously, `can_eq_nc'` would equate `ForAllTy`s regardless of their
`ArgFlag`, including `forall i -> i -> Type` and `forall i. i -> Type`! To fix
this, `can_eq_nc'` now uses the `sameVis` function to first check if the
`ArgFlag`s are equal modulo specificity. I have also updated `tcEqType`'s
implementation to match this behavior. For more explanation on the "modulo
specificity" part, see the new `Note [ForAllTy and typechecker equality]`
in `GHC.Tc.Solver.Canonical`.
While I was in town, I fixed some related documentation issues:
* I added `Note [Typechecker equality]` to `GHC.Tc.Utils.TcType` to describe
what exactly distinguishes `can_eq_nc'` and `tcEqType` (which implement
typechecker equality) from `eqType` (which implements definitional equality,
which does not care about the `ArgFlags` of `ForAllTy`s at all).
* The User's Guide had some outdated prose on the specified/inferred
distinction being different for types and kinds, a holdover from #15079. This
is no longer the case on today's GHC, so I removed this prose, added some new
prose to take its place, and added a regression test for the programs in
#15079.
* The User's Guide had some _more_ outdated prose on inferred type variables
not being allowed in `default` type signatures for class methods, which is no
longer true as of the resolution of #18432.
* The related `Note [Deferred Unification]` was being referenced as
`Note [Deferred unification]` elsewhere, which made it harder to `grep`
for. I decided to change the name of the Note to `Deferred unification`
for consistency with the capitalization style used for most other Notes.
Fixes #18863.
- - - - -
a98593f0 by Sylvain Henry at 2020-10-31T02:54:34-04:00
Refactor numeric constant folding rules
Avoid the use of global pattern synonyms.
1) I think it's going to be helpful to implement constant folding for
other numeric types, especially Natural which doesn't have a wrapping
behavior. We'll have to refactor these rules even more so we'd better
make them less cryptic.
2) It should also be slightly faster because global pattern synonyms
matched operations for every numeric types instead of the current one:
e.g., ":**:" pattern was matching multiplication for both Int# and
Word# types. As we will probably want to implement constant folding
for other numeric types (Int8#, Int16#, etc.), it is more efficient
to only match primops for a given type as we do now.
- - - - -
730ef38f by Sylvain Henry at 2020-10-31T02:54:34-04:00
Simplify constant-folding (#18032)
See #18032 for the details.
* Use `Lit (LitNumber _ i)` instead of `isLitValue_maybe` which does
more work but that is not needed for constant-folding
* Don't export `GHC.Types.Literal.isLitValue_maybe`
* Kill `GHC.Types.Literal.isLitValue` which isn't used
- - - - -
d5a53c1a by Ben Gamari at 2020-10-31T02:55:10-04:00
primops.txt.pp: Move ByteArray# primops to separate file
This file will be generated.
- - - - -
b4278a41 by Ben Gamari at 2020-10-31T02:55:10-04:00
primops: Generate ByteArray# index/read/write primops
Previously these were mostly undocumented and was ripe for potential
inconsistencies.
- - - - -
08e6993a by Sylvain Henry at 2020-10-31T02:55:50-04:00
Move loadDecl into IfaceToCore
- - - - -
cb1f755c by Tamar Christina at 2020-10-31T09:26:56-04:00
winio: Fix unused variables warnings
- - - - -
eb368078 by Andrzej Rybczak at 2020-10-31T09:27:34-04:00
Add testcase for #816
- - - - -
bd4abdc9 by Ben Gamari at 2020-11-01T01:10:31-04:00
testsuite: Add performance test for #18698
- - - - -
dfd27445 by Hécate at 2020-11-01T01:11:09-04:00
Add the proper HLint rules and remove redundant keywords from compiler
- - - - -
ce1bb995 by Hécate at 2020-11-01T08:52:08-05:00
Fix a leak in `transpose`
This patch was authored by David Feuer <david.feuer at gmail.com>
- - - - -
e63db32c by Ben Gamari at 2020-11-01T08:52:44-05:00
Scav: Use bd->gen_no instead of bd->gen->no
This potentially saves a cache miss per scavenge.
- - - - -
4ce2f7d6 by GHC GitLab CI at 2020-11-02T23:45:06-05:00
testsuite: Add --top flag to driver
This allows us to make `config.top` a proper Path. Previously it was a
str, which caused the Ghostscript detection logic to break.
- - - - -
0b772221 by Ben Gamari at 2020-11-02T23:45:42-05:00
Document that ccall convention doesn't support varargs
We do not support foreign "C" imports of varargs functions. While this
works on amd64, in general the platform's calling convention may need
more type information that our Cmm representation can currently provide.
For instance, this is the case with Darwin's AArch64 calling convention.
Document this fact in the users guide and fix T5423 which makes use of a
disallowed foreign import.
Closes #18854.
- - - - -
81006a06 by David Eichmann at 2020-11-02T23:46:19-05:00
RtsAPI: pause and resume the RTS
The `rts_pause` and `rts_resume` functions have been added to `RtsAPI.h` and
allow an external process to completely pause and resume the RTS.
Co-authored-by: Sven Tennie <sven.tennie at gmail.com>
Co-authored-by: Matthew Pickering <matthewtpickering at gmail.com>
Co-authored-by: Ben Gamari <bgamari.foss at gmail.com>
- - - - -
bfb1e272 by Ryan Scott at 2020-11-02T23:46:55-05:00
Display results of GHC.Core.Lint.lint* functions consistently
Previously, the functions in `GHC.Core.Lint` used a patchwork of
different ways to display Core Lint errors:
* `lintPassResult` (which is the source of most Core Lint errors) renders
Core Lint errors with a distinctive banner (e.g.,
`*** Core Lint errors : in result of ... ***`) that sets them apart
from ordinary GHC error messages.
* `lintAxioms`, in contrast, uses a completely different code path that
displays Core Lint errors in a rather confusing manner. For example,
the program in #18770 would give these results:
```
Bug.hs:1:1: error:
Bug.hs:12:1: warning:
Non-*-like kind when *-like expected: RuntimeRep
when checking the body of forall: 'TupleRep '[r]
In the coercion axiom Bug.N:T :: []. Bug.T ~_R Any
Substitution: [TCvSubst
In scope: InScope {r}
Type env: [axl :-> r]
Co env: []]
|
1 | {-# LANGUAGE DataKinds #-}
| ^
```
* Further digging reveals that `GHC.IfaceToCore` displays Core Lint
errors for iface unfoldings as though they were a GHC panic. See, for
example, this excerpt from #17723:
```
ghc: panic! (the 'impossible' happened)
(GHC version 8.8.2 for x86_64-unknown-linux):
Iface Lint failure
In interface for Lib
...
```
This patch makes all of these code paths display Core Lint errors and
warnings consistently. I decided to adopt the conventions that
`lintPassResult` currently uses, as they appear to have been around the
longest (and look the best, in my subjective opinion). We now use the
`displayLintResult` function for all three scenarios mentioned above.
For example, here is what the Core Lint error for the program in #18770 looks
like after this patch:
```
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
*** Core Lint errors : in result of TcGblEnv axioms ***
Bug.hs:12:1: warning:
Non-*-like kind when *-like expected: RuntimeRep
when checking the body of forall: 'TupleRep '[r_axn]
In the coercion axiom N:T :: []. T ~_R Any
Substitution: [TCvSubst
In scope: InScope {r_axn}
Type env: [axn :-> r_axn]
Co env: []]
*** Offending Program ***
axiom N:T :: T = Any -- Defined at Bug.hs:12:1
*** End of Offense ***
<no location info>: error:
Compilation had errors
```
Fixes #18770.
- - - - -
a9e5f52c by Simon Peyton Jones at 2020-11-02T23:47:31-05:00
Expand type synonyms with :kind!
The User's Guide claims that `:kind!` should expand type synonyms,
but GHCi wasn't doing this in practice. Let's just update the implementation
to match the specification in the User's Guide.
Fixes #13795. Fixes #18828.
Co-authored-by: Ryan Scott <ryan.gl.scott at gmail.com>
- - - - -
1370eda7 by Ben Gamari at 2020-11-02T23:48:06-05:00
hadrian: Don't capture RunTest output
There are a few reasons why capturing the output of the RunTest builder
is undesirable:
* there is a large amount of output which then gets unnecessarily
duplicated by Hadrian if the builder fails
* the output may contain codepoints which are unrepresentable in the
current codepage on Windows, causing Hadrian to crash
* capturing the output causes the testsuite driver to disable
its colorisation logic, making the output less legible.
- - - - -
78f2767d by Matthew Pickering at 2020-11-03T17:39:53-05:00
Update inlining flags documentation
- - - - -
14ce454f by Sylvain Henry at 2020-11-03T17:40:34-05:00
Linker: reorganize linker related code
Move linker related code into GHC.Linker. Previously it was scattered
into GHC.Unit.State, GHC.Driver.Pipeline, GHC.Runtime.Linker, etc.
Add documentation in GHC.Linker
- - - - -
616bec0d by Alan Zimmerman at 2020-11-03T17:41:10-05:00
Restrict Linear arrow %1 to exactly literal 1 only
This disallows `a %001 -> b`, and makes sure the type literal is
printed from its SourceText so it is clear why.
Closes #18888
- - - - -
3486ebe6 by Sylvain Henry at 2020-11-03T17:41:48-05:00
Hadrian: don't fail if ghc-tarballs dir doesn't exist
- - - - -
37f0434d by Sylvain Henry at 2020-11-03T17:42:26-05:00
Constant-folding: don't pass through GHC's Int/Word (fix #11704)
Constant-folding rules for integerToWord/integerToInt were performing
the following coercions at compilation time:
integerToWord: target's Integer -> ghc's Word -> target's Word
integerToInt : target's Integer -> ghc's Int -> target's Int
1) It was wrong for cross-compilers when GHC's word size is smaller than
the target one. This patch avoids passing through GHC's word-sized
types:
integerToWord: target's Integer -> ghc's Integer -> target's Word
integerToInt : target's Integer -> ghc's Integer -> target's Int
2) Additionally we didn't wrap the target word/int literal to make it
fit into the target's range! This broke the invariant of literals
only containing values in range.
The existing code is wrong only with a 64-bit cross-compiling GHC,
targeting a 32-bit platform, and performing constant folding on a
literal that doesn't fit in a 32-bit word. If GHC was built with
DEBUG, the assertion in GHC.Types.Literal.mkLitWord would fail.
Otherwise the bad transformation would go unnoticed.
- - - - -
bff74de7 by Sylvain Henry at 2020-11-03T17:43:03-05:00
Bignum: make GMP's bignat_add not recursive
bignat_add was a loopbreaker with an INLINE pragma (spotted by
@mpickering). This patch makes it non recursive to avoid the issue.
- - - - -
bb100805 by Andreas Klebinger at 2020-11-04T16:47:24-05:00
NCG: Fix 64bit int comparisons on 32bit x86
We no compare these by doing 64bit subtraction and
checking the resulting flags.
We used to do this differently but the old approach was
broken when the high bits compared equal and the comparison
was one of >= or <=.
The new approach should be both correct and faster.
- - - - -
b790b7f9 by Andreas Klebinger at 2020-11-04T16:47:59-05:00
Testsuite: Support for user supplied package dbs
We can now supply additional package dbs to the testsuite.
For make the package db can be supplied by
passing PACKAGE_DB=/path/to/db.
In the testsuite driver it's passed via the --test-package-db
argument.
- - - - -
81560981 by Sylvain Henry at 2020-11-04T16:48:42-05:00
Don't use LEA with 8-bit registers (#18614)
- - - - -
17d5c518 by Viktor Dukhovni at 2020-11-05T00:50:23-05:00
Naming, value types and tests for Addr# atomics
The atomic Exchange and CAS operations on integral types are updated to
take and return more natural `Word#` rather than `Int#` values. These
are bit-block not arithmetic operations, and the sign bit plays no
special role.
Standardises the names to `atomic<OpType><ValType>Addr#`, where `OpType` is one
of `Cas` or `Exchange` and `ValType` is presently either `Word` or `Addr`.
Eventually, variants for `Word32` and `Word64` can and should be added,
once #11953 and related issues (e.g. #13825) are resolved.
Adds tests for `Addr#` CAS that mirror existing tests for
`MutableByteArray#`.
- - - - -
2125b1d6 by Ryan Scott at 2020-11-05T00:51:01-05:00
Add a regression test for #18920
Commit f594a68a5500696d94ae36425bbf4d4073aca3b2
(`Use level numbers for generalisation`) ended up fixing #18920. Let's add a
regression test to ensure that it stays fixed.
Fixes #18920.
- - - - -
e07e383a by Ryan Scott at 2020-11-06T03:45:28-05:00
Replace HsImplicitBndrs with HsOuterTyVarBndrs
This refactors the GHC AST to remove `HsImplicitBndrs` and replace it with
`HsOuterTyVarBndrs`, a type which records whether the outermost quantification
in a type is explicit (i.e., with an outermost, invisible `forall`) or
implicit. As a result of this refactoring, it is now evident in the AST where
the `forall`-or-nothing rule applies: it's all the places that use
`HsOuterTyVarBndrs`. See the revamped `Note [forall-or-nothing rule]` in
`GHC.Hs.Type` (previously in `GHC.Rename.HsType`).
Moreover, the places where `ScopedTypeVariables` brings lexically scoped type
variables into scope are a subset of the places that adhere to the
`forall`-or-nothing rule, so this also makes places that interact with
`ScopedTypeVariables` easier to find. See the revamped
`Note [Lexically scoped type variables]` in `GHC.Hs.Type` (previously in
`GHC.Tc.Gen.Sig`).
`HsOuterTyVarBndrs` are used in type signatures (see `HsOuterSigTyVarBndrs`)
and type family equations (see `HsOuterFamEqnTyVarBndrs`). The main difference
between the former and the latter is that the former cares about specificity
but the latter does not.
There are a number of knock-on consequences:
* There is now a dedicated `HsSigType` type, which is the combination of
`HsOuterSigTyVarBndrs` and `HsType`. `LHsSigType` is now an alias for an
`XRec` of `HsSigType`.
* Working out the details led us to a substantial refactoring of
the handling of explicit (user-written) and implicit type-variable
bindings in `GHC.Tc.Gen.HsType`.
Instead of a confusing family of higher order functions, we now
have a local data type, `SkolemInfo`, that controls how these
binders are kind-checked.
It remains very fiddly, not fully satisfying. But it's better
than it was.
Fixes #16762. Bumps the Haddock submodule.
Co-authored-by: Simon Peyton Jones <simonpj at microsoft.com>
Co-authored-by: Richard Eisenberg <rae at richarde.dev>
Co-authored-by: Zubin Duggal <zubin at cmi.ac.in>
- - - - -
c85f4928 by Sylvain Henry at 2020-11-06T03:46:08-05:00
Refactor -dynamic-too handling
1) Don't modify DynFlags (too much) for -dynamic-too: now when we
generate dynamic outputs for "-dynamic-too", we only set "dynamicNow"
boolean field in DynFlags instead of modifying several other fields.
These fields now have accessors that take dynamicNow into account.
2) Use DynamicTooState ADT to represent -dynamic-too state. It's much
clearer than the undocumented "DynamicTooConditional" that was used
before.
As a result, we can finally remove the hscs_iface_dflags field in
HscRecomp. There was a comment on this field saying:
"FIXME (osa): I don't understand why this is necessary, but I spent
almost two days trying to figure this out and I couldn't .. perhaps
someone who understands this code better will remove this later."
I don't fully understand the details, but it was needed because of the
changes made to the DynFlags for -dynamic-too.
There is still something very dubious in GHC.Iface.Recomp: we have to
disable the "dynamicNow" flag at some point for some Backpack's "heinous
hack" to continue to work. It may be because interfaces for indefinite
units are always non-dynamic, or because we mix and match dynamic and
non-dynamic interfaces (#9176), or something else, who knows?
- - - - -
2cb87909 by Moritz Angermann at 2020-11-06T03:46:44-05:00
[AArch64] Aarch64 Always PIC
- - - - -
b1d2c1f3 by Ben Gamari at 2020-11-06T03:47:19-05:00
rts/Sanity: Avoid nasty race in weak pointer sanity-checking
See Note [Racing weak pointer evacuation] for all of the gory details.
- - - - -
8da38465 by Simon Peyton Jones at 2020-11-07T09:18:08-05:00
Work in progress on #18359
Joint work between Richard, Simon, Ryan
- - - - -
30 changed files:
- compiler/.hlint.yaml
- compiler/GHC.hs
- + compiler/GHC/Builtin/bytearray-ops.txt.pp
- compiler/GHC/Builtin/primops.txt.pp
- compiler/GHC/Cmm/Graph.hs
- compiler/GHC/Cmm/LayoutStack.hs
- compiler/GHC/Cmm/Pipeline.hs
- compiler/GHC/Cmm/ProcPoint.hs
- compiler/GHC/CmmToAsm.hs
- compiler/GHC/CmmToAsm/BlockLayout.hs
- compiler/GHC/CmmToAsm/CFG/Dominators.hs
- compiler/GHC/CmmToAsm/PPC/CodeGen.hs
- compiler/GHC/CmmToAsm/Reg/Graph/Spill.hs
- compiler/GHC/CmmToAsm/SPARC/CodeGen.hs
- compiler/GHC/CmmToAsm/X86/CodeGen.hs
- compiler/GHC/CmmToAsm/X86/Cond.hs
- compiler/GHC/CmmToLlvm/CodeGen.hs
- compiler/GHC/Core.hs
- compiler/GHC/Core/Coercion.hs
- compiler/GHC/Core/Lint.hs
- compiler/GHC/Core/Make.hs
- compiler/GHC/Core/Opt/ConstantFold.hs
- compiler/GHC/Core/Opt/Exitify.hs
- compiler/GHC/Core/Opt/Monad.hs
- compiler/GHC/Core/Opt/Pipeline.hs
- compiler/GHC/Core/Opt/Simplify.hs
- compiler/GHC/Core/Opt/SpecConstr.hs
- compiler/GHC/Core/Opt/Specialise.hs
- compiler/GHC/Core/Opt/StaticArgs.hs
- compiler/GHC/Core/TyCo/Rep.hs
The diff was not included because it is too large.
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b9fd0f0f98706e4eda4657c014ed69e5a9afc57e...8da38465bfce4dab706429ea3197f7b70d832320
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/b9fd0f0f98706e4eda4657c014ed69e5a9afc57e...8da38465bfce4dab706429ea3197f7b70d832320
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/20201107/a6b49361/attachment-0001.html>
More information about the ghc-commits
mailing list