summaryrefslogtreecommitdiff
path: root/compiler/simplCore/LiberateCase.lhs
Commit message (Collapse)AuthorAgeFilesLines
* Globally replace "hackage.haskell.org" with "ghc.haskell.org"Simon Marlow2013-10-011-1/+1
|
* typosGabor Greif2013-01-301-1/+1
|
* Make the opt_UF_* static flags dynamicIan Lynagh2012-10-091-6/+7
| | | | | | | | I also removed the default values from the "Discounts and thresholds" note: most of them were no longer up-to-date. Along the way I added FloatSuffix to the argument parser, analogous to IntSuffix.
* Use -fwarn-tabs when validatingIan Lynagh2011-11-041-0/+7
| | | | | We only use it for "compiler" sources, i.e. not for libraries. Many modules have a -fno-warn-tabs kludge for now.
* Overhaul of infrastructure for profiling, coverage (HPC) and breakpointsSimon Marlow2011-11-021-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | User visible changes ==================== Profilng -------- Flags renamed (the old ones are still accepted for now): OLD NEW --------- ------------ -auto-all -fprof-auto -auto -fprof-exported -caf-all -fprof-cafs New flags: -fprof-auto Annotates all bindings (not just top-level ones) with SCCs -fprof-top Annotates just top-level bindings with SCCs -fprof-exported Annotates just exported bindings with SCCs -fprof-no-count-entries Do not maintain entry counts when profiling (can make profiled code go faster; useful with heap profiling where entry counts are not used) Cost-centre stacks have a new semantics, which should in most cases result in more useful and intuitive profiles. If you find this not to be the case, please let me know. This is the area where I have been experimenting most, and the current solution is probably not the final version, however it does address all the outstanding bugs and seems to be better than GHC 7.2. Stack traces ------------ +RTS -xc now gives more information. If the exception originates from a CAF (as is common, because GHC tends to lift exceptions out to the top-level), then the RTS walks up the stack and reports the stack in the enclosing update frame(s). Result: +RTS -xc is much more useful now - but you still have to compile for profiling to get it. I've played around a little with adding 'head []' to GHC itself, and +RTS -xc does pinpoint the problem quite accurately. I plan to add more facilities for stack tracing (e.g. in GHCi) in the future. Coverage (HPC) -------------- * derived instances are now coloured yellow if they weren't used * likewise record field names * entry counts are more accurate (hpc --fun-entry-count) * tab width is now correct (markup was previously off in source with tabs) Internal changes ================ In Core, the Note constructor has been replaced by Tick (Tickish b) (Expr b) which is used to represent all the kinds of source annotation we support: profiling SCCs, HPC ticks, and GHCi breakpoints. Depending on the properties of the Tickish, different transformations apply to Tick. See CoreUtils.mkTick for details. Tickets ======= This commit closes the following tickets, test cases to follow: - Close #2552: not a bug, but the behaviour is now more intuitive (test is T2552) - Close #680 (test is T680) - Close #1531 (test is result001) - Close #949 (test is T949) - Close #2466: test case has bitrotted (doesn't compile against current version of vector-space package)
* Make a new type synonym CoreProgram = [CoreBind]Simon Peyton Jones2011-09-231-1/+1
| | | | | | | | | | | and comment its invariants in Note [CoreProgram] in CoreSyn I'm not totally convinced that CoreProgram is the right name (perhaps CoreTopBinds might better), but it is useful to have a clue that you are looking at the top-level bindings. This is only a matter of a type synonym change; no deep refactoring here.
* This BIG PATCH contains most of the work for the New Coercion RepresentationSimon Peyton Jones2011-04-191-0/+1
| | | | | | | | | | | | | | See the paper "Practical aspects of evidence based compilation in System FC" * Coercion becomes a data type, distinct from Type * Coercions become value-level things, rather than type-level things, (although the value is zero bits wide, like the State token) A consequence is that a coerion abstraction increases the arity by 1 (just like a dictionary abstraction) * There is a new constructor in CoreExpr, namely Coercion, to inject coercions into terms
* Two small improvements to LiberateCasesimonpj@microsoft.com2009-02-041-26/+65
| | | | | | | | | | | | | | | | | Max Bolingbroke suggested these two small improvements to LiberateCase (most of the size increase is comments :-)): a) Do LiberateCase on small functions even if they are mutually recursive See Note [Small enough] b) Don't do LiberateCase on functions for which it'd be fruitless, namely when a free varible is scrutinised *outside* the function See Note [Avoiding fruitless liberate-case] There is virtually no effect on nofib, but Max tripped over cases where it mattered slightly.
* Add (a) CoreM monad, (b) new Annotations featuresimonpj@microsoft.com2008-10-301-16/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch, written by Max Bolingbroke, does two things 1. It adds a new CoreM monad (defined in simplCore/CoreMonad), which is used as the top-level monad for all the Core-to-Core transformations (starting at SimplCore). It supports * I/O (for debug printing) * Unique supply * Statistics gathering * Access to the HscEnv, RuleBase, Annotations, Module The patch therefore refactors the top "skin" of every Core-to-Core pass, but does not change their functionality. 2. It adds a completely new facility to GHC: Core "annotations". The idea is that you can say {#- ANN foo (Just "Hello") #-} which adds the annotation (Just "Hello") to the top level function foo. These annotations can be looked up in any Core-to-Core pass, and are persisted into interface files. (Hence a Core-to-Core pass can also query the annotations of imported things.) Furthermore, a Core-to-Core pass can add new annotations (eg strictness info) of its own, which can be queried by importing modules. The design of the annotation system is somewhat in flux. It's designed to work with the (upcoming) dynamic plug-ins mechanism, but is meanwhile independently useful. Do not merge to 6.10!
* Tidy up the treatment of dead binderssimonpj@microsoft.com2008-09-201-4/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch does a lot of tidying up of the way that dead variables are handled in Core. Just the sort of thing to do on an aeroplane. * The tricky "binder-swap" optimisation is moved from the Simplifier to the Occurrence Analyser. See Note [Binder swap] in OccurAnal. This is really a nice change. It should reduce the number of simplifier iteratoins (slightly perhaps). And it means that we can be much less pessimistic about zapping occurrence info on binders in a case expression. * For example: case x of y { (a,b) -> e } Previously, each time around, even if y,a,b were all dead, the Simplifier would pessimistically zap their OccInfo, so that we can't see they are dead any more. As a result virtually no case expression ended up with dead binders. This wasn't Bad in itself, but it always felt wrong. * I added a check to CoreLint to check that a dead binder really isn't used. That showed up a couple of bugs in CSE. (Only in this sense -- they didn't really matter.) * I've changed the PprCore printer to print "_" for a dead variable. (Use -dppr-debug to see it again.) This reduces clutter quite a bit, and of course it's much more useful with the above change. * Another benefit of the binder-swap change is that I could get rid of the Simplifier hack (working, but hacky) in which the InScopeSet was used to map a variable to a *different* variable. That allowed me to remove VarEnv.modifyInScopeSet, and to simplify lookupInScopeSet so that it doesn't look for a fixpoint. This fixes no bugs, but is a useful cleanup. * Roman pointed out that Id.mkWildId is jolly dangerous, because of its fixed unique. So I've - localied it to MkCore, where it is private (not exported) - renamed it to 'mkWildBinder' to stress that you should only use it at binding sites, unless you really know what you are doing - provided a function MkCore.mkWildCase that emodies the most common use of mkWildId, and use that elsewhere So things are much better * A knock-on change is that I found a common pattern of localising a potentially global Id, and made a function for it: Id.localiseId
* Make LiberateCase warning-freeIan Lynagh2008-05-041-13/+9
|
* Separate and optional size thresholds for SpecConstr and LiberateCaseRoman Leshchinskiy2007-12-141-3/+4
| | | | | | This patch replaces -fspec-threshold by -fspec-constr-threshold and -fliberate-case-threshold. The thresholds can be disabled by -fno-spec-constr-threshold and -fno-liberate-case-threshold.
* Fix LiberateCasesimonpj@microsoft.com2007-10-291-40/+47
| | | | | | | | | | | | | | | | Merge to STABLE please Liberate case was being far too gung-ho about what to specialise. This bug only showed up when a recursive function 'f' has a nested recursive function 'g', where 'g' calls 'f' (as well as recursively calling 'g'). This exact situation happens in GHC/IO.writeLines. This patch puts things right; see Note [When to specialise]. Result: much less code bloat.
* Fix CodingStyle#Warnings URLsIan Lynagh2007-09-041-1/+1
|
* Use OPTIONS rather than OPTIONS_GHC for pragmasIan Lynagh2007-09-031-2/+2
| | | | | | | Older GHCs can't parse OPTIONS_GHC. This also changes the URL referenced for the -w options from WorkingConventions#Warnings to CodingStyle#Warnings for the compiler modules.
* Add {-# OPTIONS_GHC -w #-} and some blurb to all compiler modulesIan Lynagh2007-09-011-0/+7
|
* Fix egregious sharing bug in LiberateCasesimonpj@microsoft.com2007-06-201-4/+22
| | | | | | | | | | | | | | | | | | | | | Andy Gill writes: consider the following code f = g (case v of V a b -> a : t f) where g is expensive. Liberate case will turn this into f = g (case v of V a b -> a : t (letrec f = g (case v of V a b -> a : f t) in f) ) Yikes! We evaluate g twice. This leads to a O(2^n) explosion if g calls back to the same code recursively. This may be the same as Trac #1366.
* Improve the interaction of 'seq' and associated data typessimonpj@microsoft.com2007-05-231-70/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Roman produced programs involving associated types that did not optimise well. His programs were something like this: data family T a data instance T Int = MkT Bool Char bar :: T Int -> Int bar t = t `seq` loop 0 where loop = ... You'd think that the `seq` should unbox 't' outside the loop, since a (T Int) is just a MkT pair. The most robust way to make this happen is for the simplifier to understand a bit about type-family instances. See Note [Improving seq] in Simplify.lhs. We use FamInstEnv.topNormaliseType to do the interesting work. To make this happen I did a bit of refactoring to the simplifier monad. I'd previously done a very similar transformation in LiberateCase, but it was happening too late. So this patch takes it out of LiberateCase as well as adding it to Simplify.
* Revised signature of tcLookupFamInst and lookupFamInstEnvManuel M T Chakravarty2007-05-141-2/+1
| | | | | | | | - This changes the signature of FamInstEnv.lookupFamInstEnv and FamInstEnv.lookupFamInstEnvUnify in a manner similar to SPJ's previous patch for InstEnv.llokupInstEnv - tcLookupFamInst now permits the lookup of instances that are more general than the type instance requested.
* Correct an egregious typo in LiberateCase that emasculated itsimonpj@microsoft.com2007-05-111-1/+1
| | | | | | | | | | | Somehow in the patch * Record-ise the liberate-case envt, in preparation for new stuff I managed to make lookupLevelEnv do entirely the wrong thing. I think it was just a typo. The result was that LiberateCase essentially never did anything any more. Easily fixed though!
* Warning fix for unused and redundant importsMichael D. Adams2007-05-101-1/+0
|
* Major improvement to SpecConstrsimonpj@microsoft.com2007-02-091-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch improves the SpecConstr pass, by a) making it work with join points b) making it generate specialisations transitively As part of it, SpecConstr now carries a substitution with it, which runs over the whole program as it goes. This turned out to be a big win; simplified the implementation quite a bit. I have *disabled* the specialisation on lambdas; it's pretty fragile, and sometimes generates more and more specialisations. Something to come back to, perhaps. I rejigged the flag-handling a bit. Now the specification of passes in DynFlags is a bit nicer; see - optLevelFlags top-level data structure - runWhen function - CoreDoPasses constructor There are now command-line flags -fspec-constr -fliberate-case -fspec-threshold=N which do the obvious thing. -O2 switches on both spec-constr and liberate-case. You can use -fno-liberate-case, -fno-spec-constr after -O2 to switch them off again. The spec-threshold applies to both these transformations; default value 200 for now.
* Use Id.isStrictIdsimonpj@microsoft.com2007-01-311-2/+1
|
* Make the LiberateCase transformation understand associated typessimonpj@microsoft.com2007-01-111-80/+167
| | | | | | | | | | | | | | | | | | | | | | | | Consider this FC program: data family AT a :: * data instance AT Int = T1 Int Int f :: AT Int -> Int f t = case t of DEFAULT -> <body> We'd like to replace the DEFAULT by a use of T1, so that if we scrutinise t inside <body> we share the evaluation: f t = case (t `cast` co) of T1 x y -> <body> I decided to do this as part of the liberate-case transformation, which is already trying to avoid redundant evals. The new transformation requires knowledge of the family instance environment, so I had to extend ModGuts to carry the fam_inst_env, and put that envt into the liberate-case environment. Otherwise it's all pretty straightforward.
* Record-ise the liberate-case envt, in preparation for new stuffsimonpj@microsoft.com2007-01-031-32/+42
|
* Improve liberate-case to take account of coercionssimonpj@microsoft.com2006-10-041-4/+13
| | | | | | | | | | | | | | Note [Scrutinee with cast] ~~~~~~~~~~~~~~~~~~~~~~~~~~ Consider this: f = \ t -> case (v `cast` co) of V a b -> a : f t Exactly the same optimistaion (unrolling one call to f) will work here, despite the cast. See mk_alt_env in the Case branch of libCase. This patch does the job. For a change, it was really easy.
* Add missing Cast cases to libCase and scExprkevind@bu.edu2006-08-011-0/+1
|
* Reorganisation of the source treeSimon Marlow2006-04-071-0/+317
Most of the other users of the fptools build system have migrated to Cabal, and with the move to darcs we can now flatten the source tree without losing history, so here goes. The main change is that the ghc/ subdir is gone, and most of what it contained is now at the top level. The build system now makes no pretense at being multi-project, it is just the GHC build system. No doubt this will break many things, and there will be a period of instability while we fix the dependencies. A straightforward build should work, but I haven't yet fixed binary/source distributions. Changes to the Building Guide will follow, too.