[Git][ghc/ghc][wip/refactor-demand] 81 commits: Add flags for annotating Generic{,1} methods INLINE[1] (#11068)

Sebastian Graf gitlab at gitlab.haskell.org
Mon Nov 2 16:58:01 UTC 2020



Sebastian Graf pushed to branch wip/refactor-demand at Glasgow Haskell Compiler / GHC


Commits:
998803dc by Andrzej Rybczak at 2020-10-15T11:40:32+02:00
Add flags for annotating Generic{,1} methods INLINE[1] (#11068)

Makes it possible for GHC to optimize away intermediate Generic representation
for more types.

Metric Increase:
    T12227

- - - - -
6b14c418 by GHC GitLab CI at 2020-10-15T21:57:50-04:00
Extend mAX_TUPLE_SIZE to 64

As well a ctuples and sums.

- - - - -
d495f36a by Ben Gamari at 2020-10-15T21:58:27-04:00
rts: Clean-up whitespace in Interpreter

- - - - -
cf10becd by Ben Gamari at 2020-10-15T21:58:27-04:00
compiler/ByteCode: Use strict Maps in bytecode assembler

- - - - -
ae146b53 by Ben Gamari at 2020-10-15T21:58:27-04:00
compiler/ByteCode: Make LocalLabel a newtype

- - - - -
cc536288 by Ben Gamari at 2020-10-15T21:58:27-04:00
compiler/ByteCode: Allow 2^32 local labels

This widens LocalLabel to 2^16, avoiding the crash observed in #14334.

Closes #14334.

- - - - -
1bb0512f by Ben Gamari at 2020-10-16T00:15:31-04:00
mingw: Extract zst toolchain archives

This should have been done when the toolchain was bumped.

- - - - -
bf7c5b6d by Ben Gamari at 2020-10-16T00:15:31-04:00
base: Reintroduce necessary LANGUAGE pragmas

These were incorrectly removed in a recent cleanup commit.

- - - - -
c6b4be4b by Ben Gamari at 2020-10-16T00:15:31-04:00
testsuite: Sort metrics by metric type

Closes #18838.

- - - - -
c7989c93 by Ben Gamari at 2020-10-16T00:15:31-04:00
testsuite: Account for -Wnoncanonical-monoid-instances changes on Windows

- - - - -
330a5433 by Ben Gamari at 2020-10-16T00:15:31-04:00
rts: Add __mingw_vfprintf to RtsSymbols.c

Following the model of the other printf symbols. See Note [Symbols for
MinGW's printf].

- - - - -
c4a69f37 by Ben Gamari at 2020-10-16T00:15:31-04:00
gitlab-ci: Remove allow_failure from Windows jobs

- - - - -
9a9679db by Ben Gamari at 2020-10-16T00:15:31-04:00
gitlab-ci: Fix Hadrian bindist names

- - - - -
07b0db86 by f-a at 2020-10-16T10:14:39-04:00
Clarify Eq documentation #18713
- - - - -
aca0e63b by Ben Gamari at 2020-10-17T10:20:31-04:00
gitlab-ci: Allow doc-tarball job to fail

Currently the Hadrian build appears not to package documentation correctly,
causing doc-tarball to fail due to the Windows build.
- - - - -
b02a9ea7 by Ben Gamari at 2020-10-17T13:26:24-04:00
gitlab-ci: s/allow_newer/allow_failure

Silly mistake on my part.
- - - - -
59d7c9f4 by John Ericson at 2020-10-17T22:01:38-04:00
Skip type family defaults with hs-boot and hsig files

Works around #17190, possible resolution for #17224. New design is is
according to accepted [GHC Propoal 320].

Instances in signatures currently unconditionally opt into associated
family defaults if no explicit instance is given. This is bad for two
reasons:

  1. It constrains possible instantiations to use the default, rather
  than possibly define the associated family differently.

  2. It breaks compilation as type families are unsupported in
  signatures.

This PR simply turns off the filling in of defaults in those cases.
Additionally, it squelches a missing definition warning for hs-boot too
that was only squelched for hsig before.

The downsides are:

  1. There is no way to opt into the default, other than copying its
  definition.

  2. If we fixed type classes in signatures, and wanted instances to
  have to explicitly *out of* rather than into the default, that would
  now be a breaking change.

The change that is most unambiguously goood is harmonizing the warning
squelching between hs-boot or hsig. Maybe they should have the warning
(opt out of default) maybe they shouldn't (opt in to default), but
surely it should be the same for both.

Add hs-boot version of a backpack test regarding class-specified
defaults in instances that appear in an hs-boot file.

The metrics increase is very slight and makes no sense --- at least no
one has figured anything out after this languishing for a while, so I'm
just going to accept it.

Metric Increase:
  T10421a

[GHC proposal 320]: https://github.com/ghc-proposals/ghc-proposals/pull/320

- - - - -
7eb46a09 by Sebastian Graf at 2020-10-17T22:02:13-04:00
Arity: Refactor fixed-point iteration in GHC.Core.Opt.Arity

Arity analysis used to propagate optimistic arity types during
fixed-point interation through the `ArityEnv`'s `ae_cheap_fun` field,
which is like `GHC.Core.Utils.exprIsCheap`, but also considers the
current iteration's optimistic arity, for the binder in question only.

In #18793, we have seen that this is a problematic design, because it
doesn't allow us to look through PAP bindings of that binder.

Hence this patch refactors to a more traditional form with an explicit
signature environment, in which we record the optimistic `ArityType` of
the binder in question (and at the moment is the *only* binder that is
recorded in the arity environment).

- - - - -
6b3eb06a by Sebastian Graf at 2020-10-17T22:02:13-04:00
Arity: Record arity types for non-recursive lets

In #18793, we saw a compelling example which requires us to look at
non-recursive let-bindings during arity analysis and unleash their arity
types at use sites.

After the refactoring in the previous patch, the needed change is quite
simple and very local to `arityType`'s defn for non-recurisve `Let`.

Apart from that, we had to get rid of the second item of
`Note [Dealing with bottoms]`, which was entirely a safety measure and
hindered optimistic fixed-point iteration.

Fixes #18793.

The following metric increases are all caused by this commit and a
result of the fact that we just do more work now:

Metric Increase:
    T3294
    T12545
    T12707

- - - - -
451455fd by Sebastian Graf at 2020-10-17T22:02:13-04:00
Testsuite: Add dead arity analysis tests

We didn't seem to test these old tests at all, judging from their
expected output.

- - - - -
50e9df49 by Dylan Yudaken at 2020-10-17T22:02:50-04:00
When using rts_setInCallCapability, lock incall threads

This diff makes sure that incall threads, when using `rts_setInCallCapability`, will be created as locked.
If the thread is not locked, the thread might end up being scheduled to a different capability.
While this is mentioned in the docs for `rts_setInCallCapability,`, it makes the method significantly less useful as there is no guarantees on the capability being used.

This commit also adds a test to make sure things stay on the correct capability.

- - - - -
0b995759 by DylanZA at 2020-10-17T22:02:50-04:00
Apply suggestion to testsuite/tests/ffi/should_run/all.T
- - - - -
a91dcb66 by Sylvain Henry at 2020-10-17T22:04:02-04:00
Don't get host RTS ways via settings (#18651)

To correctly perform a linking hack for Windows we need to link with the
RTS GHC is currently using. We used to query the RTS ways via the
"settings" file but it is fragile (#18651). The hack hasn't been fixed
to take into account all the ways (Tracing) and it makes linking of GHC
with another RTS more difficult (we need to link with another RTS and to
regenerate the settings file).

So this patch uses the ways reported by the RTS itself
(GHC.Platform.Ways.hostWays) instead of the "settings" file.

- - - - -
d858a3ae by Hécate at 2020-10-17T22:04:38-04:00
Linting corrections

* Bring back LANGUAGE pragmas in GHC.IO.Handle.Lock.Windows
* Exclude some modules that are wrongfully reported

- - - - -
b5b3e34e by Vladislav Zavialov at 2020-10-19T18:16:20-04:00
Implement -Woperator-whitespace (#18834)

This patch implements two related warnings:

  -Woperator-whitespace-ext-conflict
      warns on uses of infix operators that would be parsed
      differently were a particular GHC extension enabled

  -Woperator-whitespace
      warns on prefix, suffix, and tight infix uses of infix
      operators

Updates submodules: haddock, containers.

- - - - -
9648d680 by Sylvain Henry at 2020-10-19T18:16:58-04:00
Remove pdocPrec

pdocPrec was only used in GHC.Cmm.DebugBlock.pprUnwindExpr, so remove
it. OutputableP becomes a one-function class which might be better for
performance.

- - - - -
ee5dcdf9 by Ben Gamari at 2020-10-20T00:47:54-04:00
testsuite: Add test for #18346

This was fixed by 4291bddaea3148908c55f235ee8978e1d9aa6f20.

- - - - -
6c7a5c0c by Krzysztof Gogolewski at 2020-10-20T00:48:29-04:00
Minor comments, update linear types docs

- Update comments: placeHolderTypeTc no longer exists
  "another level check problem" was a temporary comment from linear types
- Use Mult type synonym (reported in #18676)
- Mention multiplicity-polymorphic fields in linear types docs

- - - - -
58a1ca38 by nineonine at 2020-10-20T00:49:07-04:00
Compile modules with `-fobject-code` enabled to byte-code when loaded with `*` prefix in ghci (#8042)

The documentation states that when using :add and :load, the `*` prefix forces a module
to be loaded as byte-code. However, this seems to be ignored when -fobject-code has been
enabled. In that case, the compiled code is always used, regardless of whether the *-form
is used.

The idea is to consult the Targets in HscEnv and check the 'targetAllowObjCode' flag. If
the flag for given module is set, then patch up DynFlags and select compilation backend
accordingly.

This would require a linear scan of course, but that shouldn't be too costly.

- - - - -
59b08a5d by Ben Gamari at 2020-10-20T00:49:41-04:00
gitlab-ci: Rename FLAVOUR -> BUILD_FLAVOUR

Previously the Hadrian jobs used the `FLAVOUR` environment variable to
communicate which flavour `ci.sh` should build whereas `make` used
`BUILD_FLAVOUR`. This caused unnecessary confusion. Consolidate these
two.

- - - - -
ea736839 by Alan Zimmerman at 2020-10-20T08:35:34+01:00
API Annotations: Keep track of unicode for linear arrow notation

The linear arrow can be parsed as `%1 ->` or a direct single token unicode
equivalent.

Make sure that this distinction is captured in the parsed AST by using
IsUnicodeSyntax where it appears, and introduce a new API Annotation,
AnnMult to represent its location when unicode is not used.

Updated haddock submodule

- - - - -
cf3c3bcd by Ben Gamari at 2020-10-20T22:56:31-04:00
testsuite: Mark T12971 as fragile on Windows

Due to #17945.

- - - - -
e2c4a947 by Vladislav Zavialov at 2020-10-21T16:00:30+03:00
Parser regression tests, close #12862 #12446

These issues were fixed by earlier parser changes, most likely related
to whitespace-sensitive parsing.

- - - - -
711929e6 by Simon Peyton Jones at 2020-10-23T02:42:59-04:00
Fix error message location in tcCheckPatSynDecl

Ticket #18856 showed that we were failing to set the right location
for an error message.  Easy to fix, happily.

Turns out that this also improves the error location in test T11010,
which was bogus before but we had never noticed.

- - - - -
730bb590 by Ben Gamari at 2020-10-23T02:43:33-04:00
cmm: Add Note reference to ForeignHint
- - - - -
9ad51bc9 by David Beacham at 2020-10-27T13:59:35-04:00
Fix `instance Bounded a => Bounded (Down a)` (#18716)

* Flip `minBound` and `maxBound` to respect the change in ordering
* Remove awkward `Enum` (and hence `Integral`) instances for
  `Data.Ord.Down`
* Update changelog

- - - - -
eedec53d by Vladislav Zavialov at 2020-10-27T14:00:11-04:00
Version bump: base-4.16 (#18712)

Also bumps upper bounds on base in boot libraries (incl. submodules).

- - - - -
412018c1 by Tamar Christina at 2020-10-27T14:00:49-04:00
winio: simplify logic remove optimization step.

- - - - -
4950dd07 by Ben Gamari at 2020-10-27T14:01:24-04:00
hadrian: Suppress xelatex output unless it fails

As noted in #18835, xelatex produces an absurd amount of output, nearly
all of which is meaningless. Silence this.

Fixes #18835.

- - - - -
f3d8ab2e by Ben Gamari at 2020-10-27T14:02:00-04:00
build system: Clean mingw tarballs

Tamar noticed in !4293 that the build systems fail to clean up the mingw
tarballs directory (`ghc-tarballs`). Fix this in both the make build
system and Hadrian.

- - - - -
0b3d23af by Simon Peyton Jones at 2020-10-27T14:02:34-04:00
Fix two constraint solving problems

This patch fixes two problems in the constraint solver.

* An actual bug #18555: we were floating out a constraint to eagerly,
  and that was ultimately fatal.  It's explained in
  Note [Do not float blocked constraints] in GHC.Core.Constraint.

  This is all very delicate, but it's all going to become irrelevant
  when we stop floating constraints (#17656).

* A major performance infelicity in the flattener.  When flattening
  (ty |> co) we *never* generated Refl, even when there was nothing
  at all to do.  Result: we would gratuitously rewrite the constraint
  to exactly the same thing, wasting work.  Described in #18413, and
  came up again in #18855.

  Solution: exploit the special case by calling the new function
  castCoercionKind1.  See Note [castCoercionKind1] in
  GHC.Core.Coercion

- - - - -
f76c5a08 by Sergei Trofimovich at 2020-10-27T14:03:14-04:00
ghc.mk: amend 'make sdist'

Noticed 'make sdist' failure seen as:

```
"rm" -rf sdistprep/ghc/ghc-9.1.0.20201020/hadrian/_build/ (SRC_DIST_GHC_DIR)/hadrian/dist-newstyle/
/bin/sh: -c: line 0: syntax error near unexpected token `('
```

commit 9657f6f34
("sdist: Include hadrian sources in source distribution")
added a new cleanup path without a variable expantion.

The change adds variable reference. While at it move directory
cleanup to a separate statement.

Amends #18794

Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org>

- - - - -
78b52c88 by David Eichmann at 2020-10-27T14:03:51-04:00
Use config.run_ways for multi_compile_and_run tests

- - - - -
e3fdd419 by Alan Zimmerman at 2020-10-27T14:04:26-04:00
Api Annotations: Introduce AnnPercent for HsExplicitMult

For the case

  foo :: a %p -> b

The location of the '%' is captured, separate from the 'p'

- - - - -
d2a25f42 by Ben Gamari at 2020-10-27T14:05:02-04:00
gitlab-ci: Bump ci-images

Bumps bootstrap compiler to 8.10.1.

- - - - -
28f98b01 by Sebastian Graf at 2020-10-27T14:05:37-04:00
DmdAnal: Kill `is_thunk` case in `splitFV`

The `splitFV` function implements the highly dubious hack
described in `Note [Lazy und unleashable free variables]` in
GHC.Core.Opt.DmdAnal. It arranges it so that demand signatures only
carry strictness info on free variables. Usage info is released through
other means, see the Note. It's purely for analysis performance reasons.

It turns out that `splitFV` has a quite involved case for thunks that
produces slightly different usage signatures and it's not clear why we
need it: `splitFV` is only relevant in the LetDown case and the only
time we call it on thunks is for top-level or local recursive thunks.

Since usage signatures of top-level thunks can only reference other
top-level bindings and we completely discard demand info we have on
top-level things (see the lack of `setIdDemandInfo` in
`dmdAnalTopBind`), the `is_thunk` case is completely irrelevant here.

For local, recursive thunks, the added benefit of the `is_thunk` test
is marginal: We get used-multiple-times in some cases where previously
we had used-once if a recursive thunk has multiple call sites. It's
very unlikely and not a case to optimise for.

So we kill the `is_thunk` case and inline `splitFV` at its call site,
exposing `isWeakDmd` from `GHC.Types.Demand` instead.

The NoFib summary supports this decision:

```
            Min           0.0%     -0.0%
            Max           0.0%     +0.0%
 Geometric Mean          -0.0%     -0.0%
```

- - - - -
60322f93 by Ben Gamari at 2020-10-28T21:11:39-04:00
hadrian: Don't quote metric baseline argument

Previously this was quoted inappropriately.
- - - - -
c85eb372 by Alan Zimmerman at 2020-10-28T21:12:15-04:00
API Annotations: put constructors in alphabetical order

- - - - -
795908dc by John Ericson at 2020-10-29T03:53:14-04:00
Widen acceptance threshold for T10421a

Progress towards #18842. As @sgraf812 points out, widening the window is
dangerous until the exponential described in #17658 is fixed. But this
test has caused enough misery and is low stakes enough that we and
@bgamari think it's worth it in this one case for the time being.

- - - - -
0e9f6def by Sylvain Henry at 2020-10-29T03:53:52-04:00
Split GHC.Driver.Types

I was working on making DynFlags stateless (#17957), especially by
storing loaded plugins into HscEnv instead of DynFlags. It turned out to
be complicated because HscEnv is in GHC.Driver.Types but LoadedPlugin
isn't: it is in GHC.Driver.Plugins which depends on GHC.Driver.Types. I
didn't feel like introducing yet another hs-boot file to break the loop.

Additionally I remember that while we introduced the module hierarchy
(#13009) we talked about splitting GHC.Driver.Types because it contained
various unrelated types and functions, but we never executed. I didn't
feel like making GHC.Driver.Types bigger with more unrelated Plugins
related types, so finally I bit the bullet and split GHC.Driver.Types.

As a consequence this patch moves a lot of things. I've tried to put
them into appropriate modules but nothing is set in stone.

Several other things moved to avoid loops.

* Removed Binary instances from GHC.Utils.Binary for random compiler
  things
* Moved Typeable Binary instances into GHC.Utils.Binary.Typeable: they
  import a lot of things that users of GHC.Utils.Binary don't want to
  depend on.
* put everything related to Units/Modules under GHC.Unit:
  GHC.Unit.Finder, GHC.Unit.Module.{ModGuts,ModIface,Deps,etc.}
* Created several modules under GHC.Types: GHC.Types.Fixity, SourceText,
  etc.
* Split GHC.Utils.Error (into GHC.Types.Error)
* Finally removed GHC.Driver.Types

Note that this patch doesn't put loaded plugins into HscEnv. It's left
for another patch.

Bump haddock submodule

- - - - -
22f5d9a9 by Sylvain Henry at 2020-10-29T03:53:52-04:00
GC: Avoid data race (#18717, #17964)

- - - - -
2ef2fac4 by Ryan Scott at 2020-10-29T04:18:52-04:00
Check for large tuples more thoroughly

This fixes #18723 by:

* Moving the existing `GHC.Tc.Gen.HsType.bigConstraintTuple` validity
  check to `GHC.Rename.Utils.checkCTupSize` for consistency with
  `GHC.Rename.Utils.checkTupSize`, and
* Using `check(C)TupSize` when checking tuple _types_, in addition
  to checking names, expressions, and patterns.

Note that I put as many of these checks as possible in the typechecker so
that GHC can properly distinguish between boxed and constraint tuples. The
exception to this rule is checking names, which I perform in the renamer
(in `GHC.Rename.Env`) so that we can rule out `(,, ... ,,)` and
`''(,, ... ,,)` alike in one fell swoop.

While I was in town, I also removed the `HsConstraintTuple` and
`HsBoxedTuple` constructors of `HsTupleSort`, which are functionally
unused. This requires a `haddock` submodule bump.

- - - - -
7f8be3eb by Richard Eisenberg at 2020-10-29T22:08:13-04:00
Remove unnecessary gender from comments/docs

While, say, alternating "he" and "she" in sequential writing
may be nicer than always using "they", reading code/documentation
is almost never sequential. If this small change makes individuals
feel more welcome in GHC's codebase, that's a good thing.

- - - - -
9902d9ec by Viktor Dukhovni at 2020-10-30T05:28:30-04:00
[skip ci] Fix typo in `callocBytes` haddock.

- - - - -
31fcb55f by Ryan Scott at 2020-10-30T18:52:50-04:00
Split HsConDecl{H98,GADT}Details

Haskell98 and GADT constructors both use `HsConDeclDetails`, which includes
`InfixCon`. But `InfixCon` is never used for GADT constructors, which results
in an awkward unrepresentable state. This removes the unrepresentable state by:

* Renaming the existing `HsConDeclDetails` synonym to `HsConDeclH98Details`,
  which emphasizes the fact that it is now only used for Haskell98-style data
  constructors, and
* Creating a new `HsConDeclGADTDetails` data type with `PrefixConGADT` and
  `RecConGADT` constructors that closely resemble `PrefixCon` and `InfixCon`
  in `HsConDeclH98Details`. The key difference is that `HsConDeclGADTDetails`
  lacks any way to represent infix constructors.

The rest of the patch is refactoring to accommodate the new structure of
`HsConDecl{H98,GADT}Details`. Some highlights:

* The `getConArgs` and `hsConDeclArgTys` functions have been removed, as
  there is no way to implement these functions uniformly for all
  `ConDecl`s. For the most part, their previous call sites now
  pattern match on the `ConDecl`s directly and do different things for
  `ConDeclH98`s and `ConDeclGADT`s.

  I did introduce one new function to make the transition easier:
  `getRecConArgs_maybe`, which extracts the arguments from a `RecCon(GADT)`.
  This is still possible since `RecCon(GADT)`s still use the same representation
  in both `HsConDeclH98Details` and `HsConDeclGADTDetails`, and since the
  pattern that `getRecConArgs_maybe` implements is used in several places,
  I thought it worthwhile to factor it out into its own function.
* Previously, the `con_args` fields in `ConDeclH98` and `ConDeclGADT` were
  both of type `HsConDeclDetails`. Now, the former is of type
  `HsConDeclH98Details`, and the latter is of type `HsConDeclGADTDetails`,
  which are distinct types. As a result, I had to rename the `con_args` field
  in `ConDeclGADT` to `con_g_args` to make it typecheck.

  A consequence of all this is that the `con_args` field is now partial, so
  using `con_args` as a top-level field selector is dangerous. (Indeed, Haddock
  was using `con_args` at the top-level, which caused it to crash at runtime
  before I noticed what was wrong!) I decided to add a disclaimer in the 9.2.1
  release notes to advertise this pitfall.

Fixes #18844. Bumps the `haddock` submodule.

- - - - -
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.

- - - - -
4a03ac55 by Sebastian Graf at 2020-11-02T14:04:28+01:00
tmp

- - - - -
93bbe37a by Sebastian Graf at 2020-11-02T14:05:03+01:00
More stuff

- - - - -
12649a26 by Sebastian Graf at 2020-11-02T14:05:04+01:00
tmp

- - - - -
3c49b9c2 by Sebastian Graf at 2020-11-02T14:05:48+01:00
No more errors

- - - - -
82fd4eb0 by Sebastian Graf at 2020-11-02T14:07:49+01:00
It bootstraps

- - - - -
75589459 by Sebastian Graf at 2020-11-02T14:07:50+01:00
Accept some test outputs

- - - - -
1e4274c7 by Sebastian Graf at 2020-11-02T14:07:50+01:00
Fix absDmd

- - - - -
ccf9de85 by Sebastian Graf at 2020-11-02T14:07:50+01:00
More accepted test outputs

- - - - -
5b84e571 by Sebastian Graf at 2020-11-02T14:07:50+01:00
Fix oversight in lubCard

- - - - -
452db8eb by Sebastian Graf at 2020-11-02T14:07:51+01:00
Accept more tests

- - - - -
a7dcbe4c by Sebastian Graf at 2020-11-02T14:07:51+01:00
Smart constructor for product demands

- - - - -
ce542c65 by Sebastian Graf at 2020-11-02T14:07:51+01:00
Unrelated pretty-printing improvement

- - - - -
50d3540e by Sebastian Graf at 2020-11-02T14:07:51+01:00
typo

- - - - -
a4d0092c by Sebastian Graf at 2020-11-02T14:07:51+01:00
Discard absent call demands in `lub` and `plus` (#18903)

Call demands are *relative* in the sense that a call demand `Cn(cd)`
on `g` says "`g` is called `n` times. Whenever `g` is called, the result
is used according to `cd`". Example from #18903:

```
h :: Int -> Int
h m =
  let g :: Int -> (Int,Int)
      g 1 = (m, 0)
      g n = (2 * n, 2 `div` n)
      {-# NOINLINE g #-}
  in case m of
    1 -> 0
    2 -> snd (g m)
    _ -> uncurry (+) (g m)
```

We want `1C1((1(U),S(U)))` as the demand on `g`, meaning that whenever
`g` is called, its second component is used strictly.

But from the first case alternative, where `g` is not called at all,
we get what is effectively an absent demand, which expands to `ACA(A)`.
If we blindly `lub` the A with the `(1(U),S(U))` from the other case
branches, we'll get `(1(U),1(U))`, so lazy in the second component.
But the `A` certainly means that the nested demands are redundant! The
premise for the information they encode is not met and should be
ignored, effectively treated like a bottom cardinality.

Thus, when we compute the `lub` or the `plus` of such an absent demand
with a proper call demand like `1C1((1(U),S(U)))`, we lub with
`botCleanDmd`. Thus we get `1C1((1(U),S(U)))` as the result, not
`1C1((1(U),1(U)))`, as wanted.

Fixes #18903.

- - - - -


30 changed files:

- .gitlab-ci.yml
- .gitlab/ci.sh
- compiler/.hlint.yaml
- compiler/GHC.hs
- compiler/GHC/Builtin/PrimOps.hs
- compiler/GHC/Builtin/Types.hs
- compiler/GHC/Builtin/Types/Prim.hs
- compiler/GHC/Builtin/Utils.hs
- + compiler/GHC/Builtin/bytearray-ops.txt.pp
- compiler/GHC/Builtin/primops.txt.pp
- compiler/GHC/ByteCode/Asm.hs
- compiler/GHC/ByteCode/InfoTable.hs
- compiler/GHC/ByteCode/Instr.hs
- compiler/GHC/ByteCode/Linker.hs
- compiler/GHC/Cmm/CallConv.hs
- compiler/GHC/Cmm/DebugBlock.hs
- compiler/GHC/Cmm/Graph.hs
- compiler/GHC/Cmm/LayoutStack.hs
- compiler/GHC/Cmm/Pipeline.hs
- compiler/GHC/Cmm/ProcPoint.hs
- compiler/GHC/Cmm/Type.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/CmmToLlvm/CodeGen.hs
- compiler/GHC/CmmToLlvm/Regs.hs


The diff was not included because it is too large.


View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/87f49c7af6db5813549bdad74a53d0c3c89a3ec0...a4d0092c842ac4ea374cf3f8f8c3c7f029d21fc5

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/87f49c7af6db5813549bdad74a53d0c3c89a3ec0...a4d0092c842ac4ea374cf3f8f8c3c7f029d21fc5
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/20201102/37cee379/attachment-0001.html>


More information about the ghc-commits mailing list