summaryrefslogtreecommitdiff
path: root/compiler/simplCore/SimplMonad.hs
Commit message (Collapse)AuthorAgeFilesLines
* Modules: Core operations (#13009)Sylvain Henry2020-03-181-252/+0
|
* Modules: Core (#13009)Sylvain Henry2020-03-161-3/+3
| | | | Update submodule: haddock
* Modules: Core (#13009)Sylvain Henry2020-02-261-2/+2
| | | | Update haddock submodule
* Modules: Driver (#13009)Sylvain Henry2020-02-211-1/+1
| | | | submodule updates: nofib, haddock
* Add GHC-API logging hooksSylvain Henry2019-12-181-0/+1
| | | | | | | | | | | | | | | | | | | | | | | * Add 'dumpAction' hook to DynFlags. It allows GHC API users to catch dumped intermediate codes and information. The format of the dump (Core, Stg, raw text, etc.) is now reported allowing easier automatic handling. * Add 'traceAction' hook to DynFlags. Some dumps go through the trace mechanism (for instance unfoldings that have been considered for inlining). This is problematic because: 1) dumps aren't written into files even with -ddump-to-file on 2) dumps are written on stdout even with GHC API 3) in this specific case, dumping depends on unsafe globally stored DynFlags which is bad for GHC API users We introduce 'traceAction' hook which allows GHC API to catch those traces and to avoid using globally stored DynFlags. * Avoid dumping empty logs via dumpAction/traceAction (but still write empty files to keep the existing behavior)
* Better arity for join pointsSimon Peyton Jones2019-10-281-3/+4
| | | | | | A join point was getting too large an arity, leading to #17294. I've tightened up the invariant: see CoreSyn, Note [Invariants on join points], invariant 2b
* Use DeriveFunctor throughout the codebase (#15654)Krzysztof Gogolewski2019-06-121-4/+3
|
* Compute demand signatures assuming idAritySebastian Graf2019-04-301-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This does four things: 1. Look at `idArity` instead of manifest lambdas to decide whether to use LetUp 2. Compute the strictness signature in LetDown assuming at least `idArity` incoming arguments 3. Remove the special case for trivial RHSs, which is subsumed by 2 4. Don't perform the W/W split when doing so would eta expand a binding. Otherwise we would eta expand PAPs, causing unnecessary churn in the Simplifier. NoFib Results -------------------------------------------------------------------------------- Program Allocs Instrs -------------------------------------------------------------------------------- fannkuch-redux +0.3% 0.0% gg -0.0% -0.1% maillist +0.2% +0.2% minimax 0.0% +0.8% pretty 0.0% -0.1% reptile -0.0% -1.2% -------------------------------------------------------------------------------- Min -0.0% -1.2% Max +0.3% +0.8% Geometric Mean +0.0% -0.0%
* Update Trac ticket URLs to point to GitLabRyan Scott2019-03-151-1/+1
| | | | | This moves all URL references to Trac tickets to their corresponding GitLab counterparts.
* Fix #15953 by consistently using dumpIfSet_dyn to print debug outputChaitanya Koparkar2018-11-291-5/+4
| | | | | | | | | | | | | | | | | | | | | | | | Summary: In some modules we directly dump the debugging output to STDOUT via 'putLogMsg', 'printInfoForUser' etc. However, if `-ddump-to-file` is enabled, that output should be written to a file. Easily fixed. Certain tests (T3017, Roles3, T12763 etc.) expect part of the output generated by `-ddump-types` to be in 'PprUser' style. However, generally we want all other debugging output to use 'PprDump' style. `traceTcRn` and `traceTcRnForUser` help us accomplish this. This patch also documents some missing flags in the users guide. Reviewers: RyanGlScott, bgamari, hvr Reviewed By: RyanGlScott Subscribers: rwbarton, carter GHC Trac Issues: #15953 Differential Revision: https://phabricator.haskell.org/D5382
* compiler: introduce custom "GhcPrelude" PreludeHerbert Valerio Riedel2017-09-191-0/+2
| | | | | | | | | | | | | | | | | | This switches the compiler/ component to get compiled with -XNoImplicitPrelude and a `import GhcPrelude` is inserted in all modules. This is motivated by the upcoming "Prelude" re-export of `Semigroup((<>))` which would cause lots of name clashes in every modulewhich imports also `Outputable` Reviewers: austin, goldfire, bgamari, alanz, simonmar Reviewed By: bgamari Subscribers: goldfire, rwbarton, thomie, mpickering, bgamari Differential Revision: https://phabricator.haskell.org/D3989
* Improve error msg for simplifier tick exhaustionDavid Feuer2017-05-191-9/+24
| | | | | | | | | | | | | | | Simplifier tick exhaustion is not necessarily "impossible", and isn't even always a GHC bug, per se. Improve the error message. Furthermore, the simplifier code has access to `IO`, so we can throw a proper `IO` exception instead of panicking. Reviewers: austin, bgamari, angerman Reviewed By: angerman Subscribers: angerman, rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D3597
* Join-point refactoringSimon Peyton Jones2017-05-021-2/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit has a raft of refactorings that improve the treatment of join points. I wasn't aiming so much as to gain performance as to make the code simpler. The two big things are these: * Make mkDupableCont work for SimplBind as well. This is simpler than I thought and quite neat. (Luke had aready done StrictArg.) That's a win in its own right. But also now /all/ continuations can be made dup-able * Now that all continuations can be made dup-able, I could simplify mkDupableCont to return just one SimplCont, instead of two. That really is a worthwhile simlification! Much easier to think about. Plus a bunch of smaller things: * Remove the join-arity that had been added to seIdSubst. It can be done more simply by putting it in DoneEx, which is the only constructor that actually needs it, and now we don't need the unsavoury isJoinIdInEnv_maybe. * Re-order the handling of join points in Simplify, so that we don't need the horrible resultTypeOfDupableCont * Add field names for StrictBind, StrictArg; and use them * Define simplMonad.newJoinId, and use it * Rename the seFloats field of SimplEnv to seLetFloats Binary sizes seem to go up slightly, but allocations generally improve, sometimes significantly. I don't believe the runtime numbers are reliable enough to draw any conclusions about -------------------------------------------------------------------------------- Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- event +1.1% -12.0% -0.2% -0.2% -8.7% fulsom +1.9% -11.8% -10.0% -10.0% +5.3% last-piece +2.3% -1.2% -1.2% -1.2% +0.0% mate +0.9% -1.4% -0.6% -0.7% +0.0% multiplier +1.5% -8.3% 0.17 0.17 +0.0% parser +2.0% +1.0% 0.04 0.04 +0.0% parstof +1.5% +0.7% 0.01 0.01 +0.0% sched +1.3% -6.1% 0.03 0.03 +0.0% simple +1.8% +1.0% +9.7% +9.6% +0.0% -------------------------------------------------------------------------------- Min +0.5% -12.0% -10.0% -10.0% -8.7% Max +3.0% +1.0% +14.2% +14.2% +50.0% Geometric Mean +1.4% -0.4% +0.3% +0.4% +0.5% There's also a tests/perf/compiler improvement of 20% allocation in T6048. I think it's because we now generate smaller code.
* Replace calls to `ptext . sLit` with `text`Jan Stolarek2016-01-181-4/+4
| | | | | | | | | | | | | | | | | | | | Summary: In the past the canonical way for constructing an SDoc string literal was the composition `ptext . sLit`. But for some time now we have function `text` that does the same. Plus it has some rules that optimize its runtime behaviour. This patch takes all uses of `ptext . sLit` in the compiler and replaces them with calls to `text`. The main benefits of this patch are clener (shorter) code and less dependencies between module, because many modules now do not need to import `FastString`. I don't expect any performance benefits - we mostly use SDocs to report errors and it seems there is little to be gained here. Test Plan: ./validate Reviewers: bgamari, austin, goldfire, hvr, alanz Subscribers: goldfire, thomie, mpickering Differential Revision: https://phabricator.haskell.org/D1784
* Remove some redundant definitions/constraintsHerbert Valerio Riedel2015-12-311-1/+0
| | | | | | Starting with GHC 7.10 and base-4.8, `Monad` implies `Applicative`, which allows to simplify some definitions to exploit the superclass relationship. This a first refactoring to that end.
* Add kind equalities to GHC.Richard Eisenberg2015-12-111-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This implements the ideas originally put forward in "System FC with Explicit Kind Equality" (ICFP'13). There are several noteworthy changes with this patch: * We now have casts in types. These change the kind of a type. See new constructor `CastTy`. * All types and all constructors can be promoted. This includes GADT constructors. GADT pattern matches take place in type family equations. In Core, types can now be applied to coercions via the `CoercionTy` constructor. * Coercions can now be heterogeneous, relating types of different kinds. A coercion proving `t1 :: k1 ~ t2 :: k2` proves both that `t1` and `t2` are the same and also that `k1` and `k2` are the same. * The `Coercion` type has been significantly enhanced. The documentation in `docs/core-spec/core-spec.pdf` reflects the new reality. * The type of `*` is now `*`. No more `BOX`. * Users can write explicit kind variables in their code, anywhere they can write type variables. For backward compatibility, automatic inference of kind-variable binding is still permitted. * The new extension `TypeInType` turns on the new user-facing features. * Type families and synonyms are now promoted to kinds. This causes trouble with parsing `*`, leading to the somewhat awkward new `HsAppsTy` constructor for `HsType`. This is dispatched with in the renamer, where the kind `*` can be told apart from a type-level multiplication operator. Without `-XTypeInType` the old behavior persists. With `-XTypeInType`, you need to import `Data.Kind` to get `*`, also known as `Type`. * The kind-checking algorithms in TcHsType have been significantly rewritten to allow for enhanced kinds. * The new features are still quite experimental and may be in flux. * TODO: Several open tickets: #11195, #11196, #11197, #11198, #11203. * TODO: Update user manual. Tickets addressed: #9017, #9173, #7961, #10524, #8566, #11142. Updates Haddock submodule.
* Make Monad/Applicative instances MRP-friendlyHerbert Valerio Riedel2015-10-171-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | This patch refactors pure/(*>) and return/(>>) in MRP-friendly way, i.e. such that the explicit definitions for `return` and `(>>)` match the MRP-style default-implementation, i.e. return = pure and (>>) = (*>) This way, e.g. all `return = pure` definitions can easily be grepped and removed in GHC 8.1; Test Plan: Harbormaster Reviewers: goldfire, alanz, bgamari, quchen, austin Reviewed By: quchen, austin Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1312
* Filter orphan rules based on imports, fixes #10294 and #10420.Edward Z. Yang2015-06-201-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: If we have an orphan rule in our database, don't apply it unless the defining module is transitively imported by the module we are processing. We do this by defining a new RuleEnv data type which includes both the RuleBase as well as the set of visible orphan modules, and threading this through the relevant environments (CoreReader, RuleCheckEnv and ScEnv). This is analogous to the instances fix we applied in #2182 4c834fdddf4d44d12039da4d6a2c63a660975b95, but done for RULES. An important knock-on effect is that we can remove some buggy code in LoadInterface which tried to avoid loading interfaces that were loaded by plugins (which sometimes caused instances and rules to NEVER become visible). One note about tests: I renamed the old plugins07 test to T10420 and replaced plugins07 with a test to ensure that a plugin import did not cause new rules to be loaded in. Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu> Test Plan: validate Reviewers: simonpj, austin, goldfire Subscribers: bgamari, thomie Differential Revision: https://phabricator.haskell.org/D950 GHC Trac Issues: #10420
* Comments only, mostly typosThomas Miedema2015-04-031-1/+1
| | | | [skip ci]
* Do proper depth checking in the flattener to avoid looping.Richard Eisenberg2015-03-231-8/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This implements (roughly) the plan put forward in comment:14:ticket:7788, fixing #7788, #8550, #9554, #10139, and addressing concerns raised in #10079. There are some regressions w.r.t. GHC 7.8, but only with pathological type families (like F a = F a). This also (hopefully -- don't have a test case) fixes #10158. Unsolved problems include #10184 and #10185, which are both known deficiencies of the approach used here. As part of this change, the plumbing around detecting infinite loops has changed. Instead of -fcontext-stack and -ftype-function-depth, we now have one combined -freduction-depth parameter. Setting it to 0 disbales the check, which is now the recommended way to get (terminating) code to typecheck in releases. (The number of reduction steps may well change between minor GHC releases!) This commit also introduces a new IntWithInf type in BasicTypes that represents an integer+infinity. This type is used in a few places throughout the code. Tests in indexed-types/should_fail/T7788 indexed-types/should_fail/T8550 indexed-types/should_fail/T9554 indexed-types/should_compile/T10079 indexed-types/should_compile/T10139 typecheck/should_compile/T10184 (expected broken) typecheck/should_compile/T10185 (expected broken) This commit also changes performance testsuite numbers, for the better.
* Move declaration of Rulebase from Rules to CoreSynSimon Peyton Jones2015-03-171-1/+1
| | | | | | | | | This allow HscTypes to import CoreSyn rather than Rules, which makes module loops easier to avoid. At one point in my recent travels this was important; I'm not sure it's so important now, but it's a good thing anyway. In any case CoreRule is defined in CoreSyn, so this move make sense.
* Make -ddump-splices output to stdout (fixes #8796)Alexander Vershilov2015-02-051-1/+1
| | | | | | | | | | | | | | | | | | | Summary: Fixes debug output so all info messages will use stdout. Fixes #8796. Make -ddump-splices output to stdout (fixes #8796) Make -dverbose-core2core use stdout (fixes #8796) Reviewers: simonpj, austin Reviewed By: austin Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D627 GHC Trac Issues: #8796
* compiler: de-lhs simplCore/Austin Seipp2014-12-031-0/+218
Signed-off-by: Austin Seipp <austin@well-typed.com>