summaryrefslogtreecommitdiff
path: root/compiler/stranal
Commit message (Collapse)AuthorAgeFilesLines
* White space onlySimon Peyton Jones2014-08-281-22/+22
|
* Comments onlySimon Peyton Jones2014-08-281-1/+5
|
* Make worker/wrapper work on INLINEABLE thingsSimon Peyton Jones2014-08-282-37/+78
| | | | | | | | | | | | | | | | 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
* stranal: detabify/dewhitespace DmdAnalAustin Seipp2014-08-201-302/+301
| | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
* stranal: detabify/dewhitespace WorkWrapAustin Seipp2014-08-201-85/+78
| | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
* Fix demand analyser for unboxed typesSimon Peyton Jones2014-07-011-1/+1
| | | | | | | | | 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
* Fix a serious, but rare, strictness analyser bug (Trac #9128)Simon Peyton Jones2014-06-111-1/+10
| | | | | | | | | 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.
* Add LANGUAGE pragmas to compiler/ source filesHerbert Valerio Riedel2014-05-153-2/+6
| | | | | | | | | | | | | | | | | | 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.
* Be less verbose when printing Names when we don't know what's in scopeSimon Peyton Jones2014-04-241-1/+1
| | | | | | | | 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
* Refactor in worker/wrapper generationSimon Peyton Jones2014-04-081-39/+31
| | | | | | | 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.
* Allow a longer demand signature than aritySimon Peyton Jones2014-04-081-6/+14
| | | | | | | | | | 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.
* Make the demand on a binder compatible with type (fixes Trac #8569)Simon Peyton Jones2014-03-062-34/+65
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Add some debug tracingSimon Peyton Jones2014-03-061-15/+18
|
* In deepSplitCprType_maybe, be more forgivingJoachim Breitner2014-02-071-1/+3
| | | | | | 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.
* Some polishing of the demand analyser.Joachim Breitner2014-01-231-7/+8
| | | | | | | | | | | | | | | | | 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.
* Make worker-wrapper unbox data familiesJoachim Breitner2014-01-203-66/+83
| | | | by passing the FamInstEnvs all the way down. This closes #7619.
* Typos in commentsKrzysztof Gogolewski2014-01-161-2/+2
|
* Refactor WorkWrap, get rid of worthSplittingArgDmdJoachim Breitner2014-01-162-81/+96
| | | | | | | | | | | 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.
* Replace worthSplittingThunkDmd by worthSplittingArgDmdJoachim Breitner2014-01-161-1/+1
| | | | | | | 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.)
* Make types of bothDmdType more preciseJoachim Breitner2013-12-161-5/+4
| | | | | by only passing the demand on the free variables, and whether the argument (resp. scrunitee) may or will diverge.
* Rename postProcessDmdType to postProcessUnsat and use* to reuse*Joachim Breitner2013-12-161-2/+2
|
* Split DmdResult into DmdResult and CPRResultJoachim Breitner2013-12-161-10/+6
| | | | | this is a small-step-refactoring patch and not very interesting on its own.
* Add Note [non-algebraic or open body type warning]Joachim Breitner2013-12-161-0/+20
|
* Remove dmdAnalArg and replace by easier to understand codeJoachim Breitner2013-12-161-8/+8
|
* Clarify the default demand on demand environmentsJoachim Breitner2013-12-161-10/+0
| | | | by adding Notes and using easier to understand combinators.
* Move peelFV from DmdAnal to DemandJoachim Breitner2013-12-121-22/+11
|
* Improve the handling of used-once stuffSimon Peyton Jones2013-12-122-59/+58
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Do not split void functionsSimon Peyton Jones2013-12-121-2/+20
| | | | | This is authored by SPJ, and split out out "Improve the handling of used-once stuff" by Joachim.
* Some refactoring of Demand and DmdAnalSimon Peyton Jones2013-12-122-24/+27
| | | | | This was authored by SPJ and extracted from the "Improve the handling of used-once stuff" patch by Joachim.
* Sort the output of -dump-strsigsJoachim Breitner2013-12-091-5/+8
|
* Replace mkTopDmdType by mkClosedStrictSigJoachim Breitner2013-12-091-3/+3
| | | | | because it is not a top deman (see previous commit), and it is only used in an argument to mkStrictSig.
* Rename topDmdType to nopDmdTypeJoachim Breitner2013-12-091-4/+6
| | | | | | | | | 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.
* Do not forget CPR information after an IO actionJoachim Breitner2013-12-091-1/+1
| | | | | | | | | 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.
* New flag: -ddump-strsigsJoachim Breitner2013-12-091-0/+12
| | | | | | | 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.
* Replace (State# RealWorld) with Void# where we just want a 0-bit valueSimon Peyton Jones2013-11-221-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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!
* Typos in [CPR for sum types]Joachim Breitner2013-11-191-2/+2
|
* Typos in noteGabor Greif2013-11-121-1/+1
|
* Make worker/wrapper robust to bogus unsafeCoreceSimon Peyton Jones2013-11-081-0/+9
| | | | Fixes Trac #8037
* Untabify and remove trailing spacesSimon Peyton Jones2013-10-241-206/+199
|
* Refactor the topNormaliseNewType story, fixing Trac #8467Simon Peyton Jones2013-10-241-56/+54
| | | | | | | | | | | | 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
* Remove deprecated _scc_ (#8170)Krzysztof Gogolewski2013-10-051-3/+3
|
* Globally replace "hackage.haskell.org" with "ghc.haskell.org"Simon Marlow2013-10-012-2/+2
|
* TyposKrzysztof Gogolewski2013-09-231-1/+1
|
* resurrected -fdicts-strict, off by defaultNicolas Frisby2013-09-081-9/+40
| | | | also added -fdmd-tx-dict-sel, on by default
* documentation and comments for -ffun-to-thunk and -flate-dmd-analNicolas Frisby2013-09-041-2/+5
|
* simplified the .hi format and added the -flate-dmd-anal flag (fixes #7782)Nicolas Frisby2013-08-291-27/+5
| | | | cf http://ghc.haskell.org/trac/ghc/wiki/LateDmd
* Implement "roles" into GHC.Richard Eisenberg2013-08-021-2/+2
| | | | | | | | | | | | | | | | 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.
* Comment out a leftover pprTraceGabor Greif2013-07-031-8/+8
|
* Traces and comments onlySimon Peyton Jones2013-06-061-5/+5
|
* Transfer strictness on trivial right-hand sidesSimon Peyton Jones2013-06-061-2/+35
| | | | See Note [Trivial right-hand sides]