| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This fixes a long-standing bug: Trac #6056. The trouble was that
INLINEABLE "used up" the unfolding for the Id, so it couldn't be
worker/wrapper'd by the strictness analyser.
This patch allows the w/w to go ahead, and makes the *worker* INLINEABLE
instead, so it can later be specialised.
However, that doesn't completely solve the problem, because the dictionary
argument (which the specialiser treats specially) may be strict and
hence unpacked by w/w, so now the worker won't be specilialised after all.
Solution: never unpack dictionary arguments, which is done by the isClassTyCon
test in WwLib.deepSplitProductType_maybe
|
|
|
|
| |
Signed-off-by: Austin Seipp <austin@well-typed.com>
|
|
|
|
| |
Signed-off-by: Austin Seipp <austin@well-typed.com>
|
|
|
|
|
|
|
|
|
| |
This is a tricky case exposed by Trac #9254. I'm surprised it hasn't
shown up before, because it's happens when you use unsafePerformIO in
the right way.
Anyway, fixed now. See Note [Analysing with absent demand]
in Demand.lhs
|
|
|
|
|
|
|
|
|
| |
In a special case for trivial RHSs (see DmdAnal.unpackTrivial),
I'd forgotten to include a demand for the RHS itself.
See Note [Remember to demand the function itself].
Thanks to David Terei for guiding me to the bug,
at PLDI in Edinburgh.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
In some cases, the layout of the LANGUAGE/OPTIONS_GHC lines has been
reorganized, while following the convention, to
- place `{-# LANGUAGE #-}` pragmas at the top of the source file, before
any `{-# OPTIONS_GHC #-}`-lines.
- Moreover, if the list of language extensions fit into a single
`{-# LANGUAGE ... -#}`-line (shorter than 80 characters), keep it on one
line. Otherwise split into `{-# LANGUAGE ... -#}`-lines for each
individual language extension. In both cases, try to keep the
enumeration alphabetically ordered.
(The latter layout is preferable as it's more diff-friendly)
While at it, this also replaces obsolete `{-# OPTIONS ... #-}` pragma
occurences by `{-# OPTIONS_GHC ... #-}` pragmas.
|
|
|
|
|
|
|
|
| |
Previously we always printed qualified names, but that makes a lot of debug or
warning output very verbose. So now we only print qualified names with -dppr-debug.
Civilised output (from pukka error messages, with the environment available) is
unaffected
|
|
|
|
|
|
|
| |
I don't think there should be any change in behaviour, but
the code is clearer now. Function checkSize is elimiated
in favour of doing those checks before (rather than after)
splitFun/splitThunk.
|
|
|
|
|
|
|
|
|
|
| |
See Note [Demand analysis for trivial right-hand sides] in DmdAnal.
This allows a function with arity 2 to have a DmdSig with 3 args;
which in turn had a knock-on effect, which showed up in the test for
Trac #8963.
In fact it seems entirely reasonable, so this patch removes the
WARN and CoreLint checks that were complaining.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Because of GADTs and casts we were getting binders whose
demand annotation was more deeply nested than made sense
for its type.
See Note [Trimming a demand to a type], in Demand.lhs,
which I reproduce here:
Note [Trimming a demand to a type]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Consider this:
f :: a -> Bool
f x = case ... of
A g1 -> case (x |> g1) of (p,q) -> ...
B -> error "urk"
where A,B are the constructors of a GADT. We'll get a U(U,U) demand
on x from the A branch, but that's a stupid demand for x itself, which
has type 'a'. Indeed we get ASSERTs going off (notably in
splitUseProdDmd, Trac #8569).
Bottom line: we really don't want to have a binder whose demand is more
deeply-nested than its type. There are various ways to tackle this.
When processing (x |> g1), we could "trim" the incoming demand U(U,U)
to match x's type. But I'm currently doing so just at the moment when
we pin a demand on a binder, in DmdAnal.findBndrDmd.
|
| |
|
|
|
|
|
|
| |
the ConTag may be out of range (e.g. if the type constructor is imported
via SOURCE and we don't know any of its data constructors); just return
Nothing without complaining in that case. This fixes #8743.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
I did some refactoring of the demand analyser, because I was smelling
some minor code smell. Most of my changes I had to undo, though,
adding notes and testcases on why the existing code was correct after
all.
Especially the semantics of the DmdResult is confusing, as it differs in
a DmdType and a StrictSig.
I got to imrpove the readability of the code for lubDmdType, though.
Also, dmdAnalRhs was a bit fishy in how it removed the demand on
further arguments of the body, but used the DmdResult. This would be
wrong if a body would return a demand type of "<L>m" (which currently
does not happen). This is now treated better in removeDmdTyArgs.
|
|
|
|
| |
by passing the FamInstEnvs all the way down. This closes #7619.
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
Instead of first checking whether splitting is useful, and then firing
up the worker-wrapper-machinery, which will do the same checks again, we
now simply generate a worker and wrapper, and while doing so keep track
of whether what we did was in any way useful.
So now there is only one place left where we decide whether we want to
do w/w, and that place has access to more information, in particular the
actual types at hand.
|
|
|
|
|
|
|
| |
these functions were almost equal, and neither validate nor nofib show
any difference replacing one by the other. So lets simplify this.
(This also prepares for a refactoring that will get rid of
worthSplittingArgDmd completely.)
|
|
|
|
|
| |
by only passing the demand on the free variables, and whether the
argument (resp. scrunitee) may or will diverge.
|
| |
|
|
|
|
|
| |
this is a small-step-refactoring patch and not very interesting on its
own.
|
| |
|
| |
|
|
|
|
| |
by adding Notes and using easier to understand combinators.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Joachim and I are committing this onto a branch so that we can share it,
but we expect to do a bit more work before merging it onto head.
Nofib staus:
- Most programs, no change
- A few improve
- A couple get worse (cacheprof, tak, rfib)
Investigating the "get worse" set is what's holding up putting this
on head.
The major issue is this. Consider
map (f g) ys
where f's demand signature looks like
f :: <L,C1(C1(U))> -> <L,U> -> .
So 'f' is not saturated. What demand do we place on g?
Answer
C(C1(U))
That is, the inner C1 should stay, even though f is not saturated.
I found that this made a significant difference in the demand signatures
inferred in GHC.IO, which uses lots of higher-order exception handlers.
I also had to add used-once demand signatures for some of the
'catch' primops, so that we know their handlers are only called once.
|
|
|
|
|
| |
This is authored by SPJ, and split out out "Improve the handling of
used-once stuff" by Joachim.
|
|
|
|
|
| |
This was authored by SPJ and extracted from the "Improve the handling of
used-once stuff" patch by Joachim.
|
| |
|
|
|
|
|
| |
because it is not a top deman (see previous commit), and it is only used
in an argument to mkStrictSig.
|
|
|
|
|
|
|
|
|
| |
because topDmdType is ''not'' the top of the lattice, as it puts an
implicit absent demand on free variables, but Abs is the bottom of the
Usage lattice.
Why nopDmdType? Becuase it is the demand of doing nothing: Everything
lazy, everything absent, no definite divergence.
|
|
|
|
|
|
|
|
|
| |
but do forget about certain divergence, if required. Fixes one part of
ticket #8598.
The added function (deferAfterIO) can maybe be merged with existing
code, but given the ongoing work in the nested-cpr branch, I defer that
work.
|
|
|
|
|
|
|
| |
The existing flag -ddump-stranal dumps the full Core, which is very
verbose and not always helpful. This adds a more concise output (one
line per top-level bind) that is faster to read, and especially more
suitable to be used when writing test cases for the strictness analiser.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
We were re-using the super-magical "state token" type (which has
VoidRep and is zero bits wide) for situations in which we simply want
to lambda-abstract over a zero-bit argument. For example, join points:
case (case x of { True -> e1; False -> e2 }) of
Red -> f1
Blue -> True
==>
let $j1 = \voidArg::Void# -> f1
in
case x of
True -> case e1 of
Red -> $j1 void
Blue -> True
False -> case e2 of
Red -> $j1 void
Blue -> True
This patch introduces
* The new primitive type GHC.Prim.Void#, with PrimRep = VoidRep
* A new global Id GHC.Prim.voidPrimId :: Void#.
This has no binding because the code generator drops it,
but is used as an argument (eg in the call of $j1)
* A new local Id, MkId.voidArgId, which can be lambda-bound
when you need to lambda-abstract over it.
and uses them throughout.
Now the State# thing is used only when we need state!
|
| |
|
| |
|
|
|
|
| |
Fixes Trac #8037
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
A bit of a mess had accumulated, with unclear invariants.
* Remove splitNewTypeRepCo_maybe, in favour of topNormaliseNewType_maybe
(which had the same signature but behaved subtly differently).
* Make topNormaliseNewType_maybe guaranteed to return a non-newtype
if it says (Just ty). This is what was causing the loop in #8467
* Apply similar tidying up to FamInstEnv.topNormaliseType
|
| |
|
| |
|
| |
|
|
|
|
| |
also added -fdmd-tx-dict-sel, on by default
|
| |
|
|
|
|
| |
cf http://ghc.haskell.org/trac/ghc/wiki/LateDmd
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Roles are a solution to the GeneralizedNewtypeDeriving type-safety
problem.
Roles were first described in the "Generative type abstraction" paper,
by Stephanie Weirich, Dimitrios Vytiniotis, Simon PJ, and Steve Zdancewic.
The implementation is a little different than that paper. For a quick
primer, check out Note [Roles] in Coercion. Also see
http://ghc.haskell.org/trac/ghc/wiki/Roles
and
http://ghc.haskell.org/trac/ghc/wiki/RolesImplementation
For a more formal treatment, check out docs/core-spec/core-spec.pdf.
This fixes Trac #1496, #4846, #7148.
|
| |
|
| |
|
|
|
|
| |
See Note [Trivial right-hand sides]
|