summaryrefslogtreecommitdiff
path: root/compiler/simplCore/SimplCore.lhs
Commit message (Collapse)AuthorAgeFilesLines
* compiler: de-lhs simplCore/Austin Seipp2014-12-031-923/+0
| | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
* Implement typechecker pluginsAdam Gundry2014-11-201-45/+7
| | | | | | | | | | | | | | | | | | | | Summary: See https://ghc.haskell.org/trac/ghc/wiki/Plugins/TypeChecker This is based on work by Iavor Diatchki and Eric Seidel. Test Plan: validate Reviewers: simonpj, austin Reviewed By: austin Subscribers: gridaphobe, yav, thomie, carter Differential Revision: https://phabricator.haskell.org/D489 Conflicts: docs/users_guide/7.10.1-notes.xml
* Remove -ddump-core-pipeline flagJan Stolarek2014-11-061-4/+0
|
* Remove -ddump-simpl-phases flagJan Stolarek2014-11-061-4/+5
|
* Some refactoring around endPass and debug dumpingSimon Peyton Jones2014-11-041-16/+17
| | | | | I forget all the details, but I spent some time trying to understand the current setup, and tried to simplify it a bit
* Run float-inwards immediately before the strictness analyser.Simon Peyton Jones2014-08-281-2/+7
| | | | | | | | | | | | | | | | | | | | | | | | Doing so pushes bindings nearer their use site and hence makes them more likely to be strict. These bindings might only show up after the inlining from simplification. Example in fulsom, Csg.calc, where an arg of timesDouble thereby becomes strict. Very few programs are affected, but it's basically good news. Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- fft -0.2% +1.3% 0.06 0.06 -10.0% fulsom -0.0% -2.6% -4.3% -4.7% -6.7% simple +0.0% -0.8% 0.0% 0.0% 0.0% -------------------------------------------------------------------------------- Min -0.5% -2.6% -4.5% -4.7% -10.0% Max +0.1% +1.3% +3.3% +3.4% +2.6% Geometric Mean -0.0% -0.0% -0.6% -0.6% -0.2% The lossage in fft is the loss of detecting a common sub-expression, and can be fixed by doing earlier CSE. But that is in any case a bit of a fluke so I don't mind losing it in exchange for this more reliable gain.
* Don't float out (classop dict e1 e2)Simon Peyton Jones2014-08-281-5/+5
| | | | | | | | | | | A class op applied to a dictionary doesn't do much work, so it's not a great idea to float it out (except possibly to the top level. See Note [Floating over-saturated applications] in SetLevels I also renamed "floatOutPartialApplications" to "floatOutOverSatApps"; the former is deeply confusing, since there is no partial application involved -- quite the reverse, it is *over* saturated.
* Add LANGUAGE pragmas to compiler/ source filesHerbert Valerio Riedel2014-05-151-0/+2
| | | | | | | | | | | | | | | | | | 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.
* Implement CallArity analysisJoachim Breitner2014-02-101-0/+10
| | | | | | | | | | | | | This analysis finds out if a let-bound expression with lower manifest arity than type arity is always called with more arguments, as in that case eta-expansion is allowed and often viable. The analysis is very much tailored towards the code generated when foldl is implemented via foldr; without this analysis doing so would be a very bad idea! There are other ways to improve foldr/builder-fusion to cope with foldl, if any of these are implemented then this step can probably be moved to -O2 to save some compilation times. The current impact of adding this phase is just below +2% (measured running GHC's "make").
* Squash some spelling issuesGabor Greif2014-01-261-1/+1
|
* Simplify doCorePassJoachim Breitner2014-01-201-30/+30
|
* Make worker-wrapper unbox data familiesJoachim Breitner2014-01-201-6/+21
| | | | by passing the FamInstEnvs all the way down. This closes #7619.
* Clean up some outdated comments (#8418)Austin Seipp2013-10-091-2/+2
| | | | | Authored-by: Gergely Risko <gergely@risko.hu> Signed-off-by: Austin Seipp <austin@well-typed.com>
* Improve Linting in GHCi (fixes Trac #8215)Simon Peyton Jones2013-09-031-7/+8
| | | | | | | | | | | | | | | | | | | | | The original problem was that we weren't bringing varaibles bound in the interactive context into scope before Linting the result of a top-level declaration in GHCi. (We were doing this for expressions.) Moreover I found that we weren't Linting the result of desugaring a GHCi expression, which we really should be doing. It took me a bit of time to unravel all this, and I did some refactoring to make it easier next time. * CoreMonad contains the Lint wrappers that get the right environments into place. It always had endPass and lintPassResult (which Lints bindings), but now it has lintInteractiveExpr. * Both use a common function CoreMonad.interactiveInScope to find those in-scope variables. Quite a bit of knock-on effects from this, but nothing exciting.
* simplified the .hi format and added the -flate-dmd-anal flag (fixes #7782)Nicolas Frisby2013-08-291-1/+10
| | | | cf http://ghc.haskell.org/trac/ghc/wiki/LateDmd
* This reverts commit 163de25813d12764aa5ded1666af7c06fee0d67e and commit ↵Nicolas Frisby2013-07-161-2/+2
| | | | 279ac9f66a83203448b279ea478b2cc1dafbd35d.
* copy the plugin's FastStringTable changes back into the host compilerNicolas Frisby2013-07-041-2/+2
|
* Detab modules with tabs on 5 lines or fewerIan Lynagh2013-04-061-16/+9
|
* Another go at tidying VectInfoManuel M T Chakravarty2013-02-151-0/+6
| | | | * Test: dph/modules/ExportList
* Merge branch 'refs/heads/vect-avoid' into vect-avoid-mergeManuel M T Chakravarty2013-02-061-6/+16
|\ | | | | | | | | | | | | | | | | Conflicts: compiler/rename/RnSource.lhs compiler/simplCore/OccurAnal.lhs compiler/vectorise/Vectorise/Exp.hs NB: Merging instead of rebasing for a change. During rebase Git got confused due to the lack of the submodules in my quite old fork.
| * Fix tidying of vectorised codeManuel M T Chakravarty2013-02-041-6/+16
| | | | | | | | | | * We need to keep the vectorised version of a variable alive while the original is alive. * This implies that the vectorised version needs to get into the iface if the original appears in an unfolding.
* | Merge branch 'master' of darcs.haskell.org:/srv/darcs//ghcIan Lynagh2013-01-311-1/+1
|\ \
| * | typosGabor Greif2013-01-301-1/+1
| | |
* | | Change a few throwGhcException uses to throwGhcExceptionIOIan Lynagh2013-01-301-2/+4
|/ /
* | Major patch to implement the new Demand AnalyserSimon Peyton Jones2013-01-171-9/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch is the result of Ilya Sergey's internship at MSR. It constitutes a thorough overhaul and simplification of the demand analyser. It makes a solid foundation on which we can now build. Main changes are * Instead of having one combined type for Demand, a Demand is now a pair (JointDmd) of - a StrDmd and - an AbsDmd. This allows strictness and absence to be though about quite orthogonally, and greatly reduces brain melt-down. * Similarly in the DmdResult type, it's a pair of - a PureResult (indicating only divergence/non-divergence) - a CPRResult (which deals only with the CPR property * In IdInfo, the strictnessInfo field contains a StrictSig, not a Maybe StrictSig demandInfo field contains a Demand, not a Maybe Demand We don't need Nothing (to indicate no strictness/demand info) any more; topSig/topDmd will do. * Remove "boxity" analysis entirely. This was an attempt to avoid "reboxing", but it added complexity, is extremely ad-hoc, and makes very little difference in practice. * Remove the "unboxing strategy" computation. This was an an attempt to ensure that a worker didn't get zillions of arguments by unboxing big tuples. But in fact removing it DRAMATICALLY reduces allocation in an inner loop of the I/O library (where the threshold argument-count had been set just too low). It's exceptional to have a zillion arguments and I don't think it's worth the complexity, especially since it turned out to have a serious performance hit. * Remove quite a bit of ad-hoc cruft * Move worthSplittingFun, worthSplittingThunk from WorkWrap to Demand. This allows JointDmd to be fully abstract, examined only inside Demand. Everything else really follows from these changes. All of this is really just refactoring, so we don't expect big performance changes, but acutally the numbers look quite good. Here is a full nofib run with some highlights identified: Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- expert -2.6% -15.5% 0.00 0.00 +0.0% fluid -2.4% -7.1% 0.01 0.01 +0.0% gg -2.5% -28.9% 0.02 0.02 -33.3% integrate -2.6% +3.2% +2.6% +2.6% +0.0% mandel2 -2.6% +4.2% 0.01 0.01 +0.0% nucleic2 -2.0% -16.3% 0.11 0.11 +0.0% para -2.6% -20.0% -11.8% -11.7% +0.0% parser -2.5% -17.9% 0.05 0.05 +0.0% prolog -2.6% -13.0% 0.00 0.00 +0.0% puzzle -2.6% +2.2% +0.8% +0.8% +0.0% sorting -2.6% -35.9% 0.00 0.00 +0.0% treejoin -2.6% -52.2% -9.8% -9.9% +0.0% -------------------------------------------------------------------------------- Min -2.7% -52.2% -11.8% -11.7% -33.3% Max -1.8% +4.2% +10.5% +10.5% +7.7% Geometric Mean -2.5% -2.8% -0.4% -0.5% -0.4% Things to note * Binary sizes are smaller. I don't know why, but it's good. * Allocation is sometiemes a *lot* smaller. I believe that all the big numbers (I checked treejoin, gg, sorting) arise from one place, namely a function GHC.IO.Encoding.UTF8.utf8_decode, which is strict in two Buffers both of which have several arugments. Not w/w'ing both arguments (which is what we did before) has a big effect. So the big win in actually somewhat accidental, gained by removing the "unboxing strategy" code. * A couple of benchmarks allocate slightly more. This turns out to be due to reboxing (integrate). But the biggest increase is mandel2, and *that* turned out also to be a somewhat accidental loss of CSE, and pointed the way to doing better CSE: see Trac #7596. * Runtimes are never very reliable, but seem to improve very slightly. All in all, a good piece of work. Thank you Ilya!
* | Refactor the way dump flags are handledIan Lynagh2012-10-181-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | We were being inconsistent about how we tested whether dump flags were enabled; in particular, sometimes we also checked the verbosity, and sometimes we didn't. This lead to oddities such as "ghc -v4" printing an "Asm code" section which didn't contain any code, and "-v4" enabled some parts of "-ddump-deriv" but not others. Now all the tests use dopt, which also takes the verbosity into account as appropriate.
* | Some alpha renamingIan Lynagh2012-10-161-15/+15
| | | | | | | | | | Mostly d -> g (matching DynFlag -> GeneralFlag). Also renamed if* to when*, matching the Haskell if/when names
* | Move tARGET_* out of HaskellConstantsIan Lynagh2012-09-171-2/+2
|/
* typos in trace strings (which I observed in compile output)Gabor Greif2012-07-181-1/+1
|
* Add IO to the SimplM monad.Paolo Capriotti2012-07-131-14/+4
| | | | This is needed to turn the rule-firings traces into proper output.
* Pass DynFlags down to showSDocDebugIan Lynagh2012-06-121-2/+2
|
* Pass DynFlags down to showSDocIan Lynagh2012-06-121-2/+3
|
* Pass DynFlags down to showSDocDumpIan Lynagh2012-06-121-30/+30
| | | | | To help with this, we now also pass DynFlags around inside the SpecM monad.
* Pass DynFlags to the LogActionIan Lynagh2012-06-111-1/+1
| | | | | | | A side-effect is that we can no longer use the LogAction in defaultErrorHandler, as we don't have DynFlags at that point. But all that defaultErrorHandler did is to print Strings as SevFatal, so now it takes a 'FatalMessager' instead.
* Replace printDump with a new SeverityIan Lynagh2012-05-291-6/+9
| | | | | | We now use log_action with severity SevDump, rather than calling printDump. This means that what happens to dumped info is now under the control of the GHC API user, rather than always going to stdout.
* Allow cases with empty alterantivesSimon Peyton Jones2012-05-021-5/+5
| | | | | | | | | | | | | | | | | | | | | | This patch allows, for the first time, case expressions with an empty list of alternatives. Max suggested the idea, and Trac #6067 showed that it is really quite important. So I've implemented the idea, fixing #6067. Main changes * See Note [Empty case alternatives] in CoreSyn * Various foldr1's become foldrs * IfaceCase does not record the type of the alternatives. I added IfaceECase for empty-alternative cases. * Core Lint does not complain about empty cases * MkCore.castBottomExpr constructs an empty-alternative case expression (case e of ty {}) * CoreToStg converts '(case e of {})' to just 'e'
* Use coreBindsStats more than coreBindsSizeSimon Peyton Jones2012-04-261-2/+2
|
* Don't indirection-zap a function that has a stable unfoldingSimon Peyton Jones2011-11-271-0/+1
| | | | | This was responsible for Trac #5001, and it was a real bug; an inlining could be lost.
* Minor refactoringSimon Peyton Jones2011-11-111-3/+6
|
* 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)
* Print simplifier statistics in simplifyExpr as wellSimon Peyton Jones2011-10-211-5/+8
|
* Whitespace only in simplCore/SimplCore.lhs.Michal Terepeta2011-10-171-258/+258
|
* Make a new type synonym CoreProgram = [CoreBind]Simon Peyton Jones2011-09-231-12/+12
| | | | | | | | | | | 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.
* Add a transformation limit to the simplifier (Trac #5448)Simon Peyton Jones2011-09-231-4/+6
| | | | | | | | | | | | | | | | | | | This addresses the rare cases where the simplifier diverges (see the above ticket). We were already counting how many simplifier steps were taking place, but with no limit. This patch adds a limit; at which point we halt compilation, and print out useful stats. The stats show what is begin inlined, and how often, which points you directly to the problem. The limit is set based on the size of the program. Instead of halting compilation, we could instead just inhibit inlining, which would let compilation of the module complete. This is a bit harder to implement, and it's likely to mean that you unrolled the function 1143 times and then ran out of ticks; you probably don't want to complete parsing on this highly-unrolled program. Flags: -dsimpl-tick-factor=N. Default is 100 (percent). A bigger number increases the allowed maximum tick count.
* Eliminate the GlomBinds passSimon Peyton Jones2011-07-271-44/+0
| | | | | It is now done when necessary by OccurAnal (see Note [Glomming] in OccurAnal)
* Simplify the treatment of RULES in OccurAnalSimon Peyton Jones2011-07-211-3/+4
| | | | | | | | | | I realised that my recently-added cunning stuff about RULES for imported Ids was simply wrong, so this patch removes it. See Note [Rules for imported functions], which explains it all. This patch also does quite a bit of refactoring in the treatment of loop breakers.
* Improve debug printing for simplifier countsSimon Peyton Jones2011-07-211-6/+11
|
* Add dynamically-linked plugins (see Trac #3843)Simon Peyton Jones2011-06-161-14/+284
| | | | | | | | | | | | | | | | | | | | | | | | | | | This patch was originally developed by Max Bolingbroke, and worked on further by Austin Seipp. It allows you to write a Core-to-Core pass and have it dynamically linked into an otherwise-unmodified GHC, and run at a place you specify in the Core optimisation pipeline. Main components: - CoreMonad: new types Plugin, PluginPass plus a new constructor CoreDoPluginPass in CoreToDo - SimplCore: stuff to dynamically load any plugins, splice them into the core-to-core pipeline, and invoke them - Move "getCoreToDo :: DynFlags -> [CoreToDo]" which constructs the main core-to-core pipeline from CoreMonad to SimplCore SimplCore is the driver for the optimisation pipeline, and it makes more sense to have the pipeline construction in the driver not in the infrastructure module. - New module DynamicLoading: invoked by SimplCore to load any plugins Some consequential changes in Linker. - New module GhcPlugins: this should be imported by plugin modules; it it not used by GHC itself.
* Added a pragma {-# NOVECTORISE f #-} that suppresses vectorisation of ↵Manuel M T Chakravarty2011-06-131-6/+13
| | | | toplevel variable 'f'.