summaryrefslogtreecommitdiff
path: root/compiler
Commit message (Collapse)AuthorAgeFilesLines
* CallArity: Use exprIsCheap to detect thunksJoachim Breitner2016-12-261-5/+16
| | | | | | | | | | | | | | | Originally, everything that is not in WHNF (`exprIsWHNF`) is considered a thunk, not eta-expanded, to avoid losing any sharing. This is also how the published papers on Call Arity describe it. In practice, there are thunks that do a just little work, such as pattern-matching on a variable, and the benefits of eta-expansion likely oughtweigh the cost of doing that repeatedly. Therefore, this implementation of Call Arity considers everything that is not cheap (`exprIsCheap`) as a thunk. Nofib reports -2.58% allocations for scs and -40.93% allocation for wheel-sieve1; the latter has - 2.92% runtime.
* rename: Add note describing #11216Ben Gamari2016-12-231-4/+22
|
* Add caret diagnosticsPhil Ruffwind2016-12-233-10/+104
| | | | | | | | | | | | | | | | | | | | | | | | | | This is controlled by -f[no-]diagnostics-show-caret. Example of what it looks like: ``` | 42 | x = 1 + () | ^^^^^^ ``` This is appended to each diagnostic message. Test Plan: testsuite/tests/warnings/should_fail/CaretDiagnostics1 testsuite/tests/warnings/should_fail/CaretDiagnostics2 Reviewers: simonpj, austin, bgamari Reviewed By: simonpj, bgamari Subscribers: joehillen, mpickering, Phyx, simonpj, alanz, thomie Differential Revision: https://phabricator.haskell.org/D2718 GHC Trac Issues: #8809
* rename: Don't require 'fail' in non-monadic contextsBen Gamari2016-12-232-3/+22
| | | | Fixes #11216.
* Push coercions in exprIsConApp_maybeSimon Peyton Jones2016-12-231-2/+48
| | | | | | | | | | Trac #13025 showed up the fact that exprIsConApp_maybe isn't clever enough: it didn't push coercions through applicatins, and that meant we weren't getting as much superclass selection as we should. It's easy to fix, happily. See Note [Push coercions in exprIsConApp_maybe]
* Removed dead code in DsCCall.mk_altSimon Peyton Jones2016-12-231-48/+41
| | | | Fixes Trac #13029 by deleting code and adding comments
* Propagate evaluated-ness a bit more faithfullySimon Peyton Jones2016-12-232-3/+23
| | | | | | | | | | This was provoked by Trac #13027. The fix in Simplify actually cures the reported bug; see Note [Case binder evaluated-ness] in Simplify. The fix in CoreTidy looks like an omission that I fixed while I was at it.
* Tiny refactor in CoreTidySimon Peyton Jones2016-12-231-10/+10
|
* Float unboxed expressions by boxingSimon Peyton Jones2016-12-233-118/+219
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch makes GHC's floating more robust, by allowing it to float unboxed expressions of at least some common types. See Note [Floating MFEs of unlifted type] in SetLevels. This was all provoked by Trac #12603 In working this through I also made a number of other corner-case changes in SetLevels: * Previously we inconsistently use exprIsBottom (which checks for bottom) instead of exprBotStrictness_maybe (which checks for bottoming functions). As well as being inconsistent it was simply less good. See Note [Bottoming floats] * I fixed a case where were were unprofitably floating an expression because we thought it escaped a value lambda (see Note [Escaping a value lambda]). The relevant code is float_me = (dest_lvl `ltMajLvl` (le_ctxt_lvl env) && not float_is_lam) -- NEW * I made lvlFloatRhs work properly in the case where abs_vars is non-empty. It wasn't wrong before, but it did some stupid extra floating.
* Ensure that even bottoming functions have an unfoldingSimon Peyton Jones2016-12-231-20/+26
| | | | | | | | | | | The payload of this change is to ensure that a bottoming function still has an unfolding, just one with an UnfoldingGuidance of UnfoldNever. Previously it was getting an unfolding of NoUnfolding. I don't think that was really /wrong/, but it was inconsistent with the general principle of giving everthing an unfoding if we know it. And it seems tideier this way.
* Comments onlySimon Peyton Jones2016-12-231-0/+2
|
* White space onlySimon Peyton Jones2016-12-231-4/+4
|
* Fix a bug in ABot handling in CoreAritySimon Peyton Jones2016-12-231-3/+10
| | | | | | | | | | | | | | | See Note [ABot branches: use max] in CoreArity. I stumbled on this when investigating something else, and opened Trac #13031 to track it. It's very hard to tickle the bug, which is why it has lurked so long, but the test stranal/should_compile/T13031 does so Oddly, the testsuite framework doesn't actually run the test; I have no idea why.
* Alpha-renaming and white space onlySimon Peyton Jones2016-12-231-10/+11
|
* Fix another forward reference to a NoteRyan Scott2016-12-211-2/+2
| | | | | | A continuation of ccc918cdc8b2d147c4dbc29bfc87c058862a97cd. [ci skip]
* Notes on parsing lists in Parser.yEdward Z. Yang2016-12-211-0/+44
| | | | | | | | | | | | | | | Summary: Maybe everyone knows this but I think it is worth mentioning Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu> Test Plan: none Reviewers: bgamari, austin Subscribers: thomie, mpickering Differential Revision: https://phabricator.haskell.org/D2890
* Support for abi-depends for computing shadowing.Edward Z. Yang2016-12-213-116/+211
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This is a complete fix based off of ed7af26606b3a605a4511065ca1a43b1c0f3b51d for handling shadowing and out-of-order -package-db flags simultaneously. The general strategy is we first put all databases together, overriding packages as necessary. Once this is done, we successfully prune out broken packages, including packages which depend on a package whose ABI differs from the ABI we need. Our check gracefully degrades in the absence of abi-depends, as we only check deps which are recorded in abi-depends. Contains time and Cabal submodule update. Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu> Test Plan: validate Reviewers: niteria, austin, bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2846 GHC Trac Issues: #12485
* Disambiguate two Notes with identical namesRyan Scott2016-12-211-2/+2
| | | | | | It turns out there were two Notes in the GHC codebase named [Pattern synonym signatures]. To avoid confusion, I gave one Note a slightly different name.
* Fix a forward reference to a NoteRyan Scott2016-12-211-2/+2
|
* Fix 'SPECIALISE instance'Simon Peyton Jones2016-12-218-98/+133
| | | | | | | | | | | | | | | | | | | | | Trac #12944 showed that the DsBinds code that implemented a SPECIALISE pragma was inadequate if the constraints solving added let-bindings for dictionaries. The result was that we ended up with an unbound dictionary in a DFunUnfolding -- and Lint didn't even check for that! Fixing this was not entirely straightforward * In DsBinds.dsSpec we use a new function TcEvidence.collectHsWrapBinders to pick off the lambda binders from the HsWapper * dsWrapper now returns a (CoreExpr -> CoreExpr) function * CoreUnfold.specUnfolding now takes a (CoreExpr -> CoreExpr) function it can use to specialise the unfolding. On the whole the code is simpler than before.
* Never apply worker/wrapper to DFunsSimon Peyton Jones2016-12-212-38/+46
| | | | | | | | | While fixing Trac #12444 I found an occasion on which we applied worker/wrapper to a DFunId. This is bad: it destroys the magic DFunUnfolding. This patch is a minor refactoring that stops this corner case happening, and tidies up the code a bit too.
* Move InId/OutId to CoreSynSimon Peyton Jones2016-12-218-84/+51
| | | | | | | | It turned out that many different modules defined the same type synonyms (InId, OutId, InType, OutType, etc) for the same purpose. This patch is refactoring only: it moves all those definitions to CoreSyn.
* Lint DFunUnfoldingsSimon Peyton Jones2016-12-211-2/+14
| | | | | Previously we simply failed to Lint these DFunUnfoldings, which led to a very delayed error message for Trac #12944
* Don't eta-expand in stable unfoldingsSimon Peyton Jones2016-12-212-13/+36
| | | | | See SimplUtils Note [No eta expansion in stable unfoldings], and Trac #9509 for an excellend diagnosis by Nick Frisby
* Move typeSize/coercionSize into TyCoRepSimon Peyton Jones2016-12-214-47/+59
| | | | | | | | | | | | | | | While investigating something else I found that 'typeSize' was allocating like crazy. Stupid becuase it should allocate precisely nothing!! Turned out that it was because typeSize and coercionSize were mutually recursive across module boundaries, and so could not benefit from the CPR property. To fix this I moved them both into TyCoRep. It's not critical (because typeSize is really only used in debug mode, but I tripped over and example (T5642) in which typeSize was one of the biggest single allocators in all of GHC. And it's easy to fix, so I did.
* Test Trac #12968, plus some commentsSimon Peyton Jones2016-12-212-0/+5
|
* Rewrite Note [Api annotations] for clarity.Edward Z. Yang2016-12-203-55/+88
| | | | | | | | | | | | | | | Summary: Based off my understanding of how the moving parts work. Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu> Test Plan: comments only Reviewers: alanz, mpickering, austin, bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2887
* Allow use of the external interpreter in stage1.Shea Levy2016-12-2027-322/+98
| | | | | | | | | | | | | | | | | | | Summary: Now that we have -fexternal-interpreter, we can lose most of the GHCI ifdefs. This was originally added in https://phabricator.haskell.org/D2826 but that led to a compatibility issue with ghc 7.10.x on Windows. That's fixed here and the revert reverted. Reviewers: goldfire, hvr, austin, bgamari, Phyx Reviewed By: Phyx Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2884 GHC Trac Issues: #13008
* Revert "Allow use of the external interpreter in stage1."Tamar Christina2016-12-1927-75/+322
| | | | This reverts commit 52ba9470a7e85d025dc84a6789aa809cdd68b566.
* Introduce unboxedSum{Data,Type}Name to template-haskellRyan Scott2016-12-182-3/+17
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: In D2448 (which introduced Template Haskell support for unboxed sums), I neglected to add `unboxedSumDataName` and `unboxedSumTypeName` functions, since there wasn't any way you could write unboxed sum data or type constructors in prefix form to begin with (see #12514). But even if you can't write these `Name`s directly in source code, it would still be nice to be able to use these `Name`s in Template Haskell (for instance, to be able to treat unboxed sum type constructors like any other type constructors). Along the way, this uncovered a minor bug in `isBuiltInOcc_maybe` in `TysWiredIn`, which was calculating the arity of unboxed sum data constructors incorrectly. Test Plan: make test TEST=T12478_5 Reviewers: osa1, goldfire, austin, bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2854 GHC Trac Issues: #12478, #12514
* Fix Haddock comment typo.Edward Z. Yang2016-12-181-1/+1
| | | | Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
* Check family instance consistency of hs-boot families later, fixes #11062.Edward Z. Yang2016-12-175-8/+81
| | | | | | | | | | | | | | | | | | | | | | Summary: With hs-boot files, some type families may be defined in the module we are typechecking. In this case, we are not allowed to poke these families until after we typecheck our local declarations. So we first check everything involving non-recursive families, and then check the recursive families as we finish kind-checking them. Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu> Test Plan: validate Reviewers: goldfire, austin, simonpj, bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2859 GHC Trac Issues: #11062
* Allow use of the external interpreter in stage1.Shea Levy2016-12-1727-322/+75
| | | | | | | | | | | | Now that we have -fexternal-interpreter, we can lose most of the GHCI ifdefs. Reviewers: simonmar, goldfire, austin, hvr, bgamari Reviewed By: simonmar Subscribers: RyanGlScott, mpickering, angerman, thomie Differential Revision: https://phabricator.haskell.org/D2826
* Improve StringBuffer and FastString docsPhil Ruffwind2016-12-172-4/+51
| | | | | | | | | | | | | | | This area of code contains a lot of unsafe functionality, so it might be worth documenting to reduce the risk of misuse. Test Plan: inspection Reviewers: austin, bgamari Reviewed By: bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2872
* Windows: Improve terminal detection mechanismPhil Ruffwind2016-12-174-98/+154
| | | | | | | | | | | | | | | | | | | | | The previous detection mechanism allowed environment variables (ANSICON, ConEmuANSI, TERM) to supersede the fact that the stderr is not a terminal, which is probably what led to color codes appearing in the stderr of the tests (see: 847d229346431483b99adcff12e46c7bf6af15da). This commit changes the detection mechanism to detect Cygwin/MSYS2 terminals in a more reliable manner, avoiding the use of environment variables entirely. Test Plan: validate Reviewers: Phyx, austin, erikd, bgamari Reviewed By: Phyx, bgamari Subscribers: RyanGlScott, thomie Differential Revision: https://phabricator.haskell.org/D2809
* Reshuffle levity polymorphism checks.Richard Eisenberg2016-12-174-21/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | Previously, GHC checked for bad levity polymorphism to the left of all arrows in data constructors. This was wrong, as reported in #12911 (where an example is also shown). The solution is to check each individual argument for bad levity polymorphism. Thus the check has been moved from TcValidity to TcTyClsDecls. A similar situation exists with pattern synonyms, also fixed here. This patch also nabs #12819 while I was in town. Test cases: typecheck/should_compile/T12911, patsyn/should_fail/T12819 Test Plan: ./validate Reviewers: simonpj, austin, bgamari Reviewed By: bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2783 GHC Trac Issues: #12819, #12911
* Revert "Do not init record accessors as exported"Ben Gamari2016-12-173-17/+2
| | | | | This reverts commit 3a00ff92a3ee66c096b85b180d247d1a471a6b6e due to #12993
* Fix string merging with -split-sectionsSimon Brenner2016-12-161-3/+14
| | | | | | | | | | | | | | | | | | The added flags for string literal merging ended up printed in the middle of the section name when -split-sections was enabled. Break it up to put the flags after the name. Test Plan: validate with SplitSections=YES Reviewers: austin, bgamari Reviewed By: bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2865 GHC Trac Issues: #9577
* Make up a module name for c-- filesBen Gamari2016-12-161-2/+5
| | | | | | | | | | | | | | | | | | | | | Summary: We used to pass a bottoming Module to the NCG, which resulted in panics when `-v` was used due to debug output (see #11784). Instead we make up a module name. This is a bit scary since `PIC.howToAccessLabel` might actually use the Module, but if it wasn't crashing before I suppose it's fine. Test Plan: `touch hi.cmm; ghc -v2 -c -dcmm-lint hi.cmm` Reviewers: austin, simonmar Reviewed By: simonmar Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2864 GHC Trac Issues: #11784
* CLabel: Kill redundant UnitId argument from labelDynamicBen Gamari2016-12-164-11/+22
| | | | | | | | | | | | | | | | | | | | | | | | | It already has access to the current package's UnitId via the Module. Edward Yang pointed out that there is one wrinkle, however: the following invariant isn't true at all stages of compilation, if I am compiling the module (this_mod :: Module), then thisPackage dflags == moduleUnitId this_mod. Specifically, this is only true after desugaring; it may be broken when typechecking an indefinite signature. However, it's safe to assume this in the native codegen. I've updated Note to state this invariant more directly. Test Plan: Validate Reviewers: austin, ezyang, simonmar Reviewed By: ezyang, simonmar Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2863
* Packages: Kill unused UnitId argument to isDllNameBen Gamari2016-12-164-19/+16
| | | | | | | | | | Test Plan: Validate Reviewers: austin, simonmar Subscribers: thomie, ezyang Differential Revision: https://phabricator.haskell.org/D2866
* DynFlags: Rip out remnants of WarnContextQuantificationBen Gamari2016-12-161-3/+0
| | | | | | | | | | | | Test Plan: Validate Reviewers: austin Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2862 GHC Trac Issues: #11221
* Typos in commentsGabor Greif2016-12-169-9/+9
|
* Verify that known-key uniques fit in interface fileBen Gamari2016-12-153-1/+18
| | | | | | | | | | | | | | Here we introduce a debug check asserting that all uniques in knownKeyNames will fit in the space allowed in the interface file's symbol encoding. Test Plan: Validate Reviewers: austin Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2845
* UniqSupply: Use full range of machine wordBen Gamari2016-12-154-10/+39
| | | | | | | | | | | | | | | | | | | | | | Currently uniques are 32-bits wide. 8 of these bits are for the unique class, leaving only 24 for the unique number itself. This seems dangerously small for a large project. Let's use the full range of the native machine word. We also add (now largely unnecessary) overflow check to ensure that the unique number doesn't overflow. Test Plan: Validate Reviewers: simonmar, austin, niteria Reviewed By: niteria Subscribers: mpickering, thomie Differential Revision: https://phabricator.haskell.org/D2844 GHC Trac Issues: #12944
* base: Bump version to 4.10.0.0Ben Gamari2016-12-151-1/+1
| | | | Updates a number of submodules.
* Warn about missing instance methods that start with an underscoreRyan Scott2016-12-151-4/+2
| | | | | | | | | | | | | | | | | | | Previously, GHC would not warn whenever there was a class instance that didn't implement a class method whose name begins with an underscore. Fixes #12959. Test Plan: make test TEST=WarnMinimal Reviewers: austin, bgamari, simonpj Reviewed By: bgamari, simonpj Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2849 GHC Trac Issues: #12959
* Fix pretty printing of MINIMAL signaturesMatthew Pickering2016-12-151-2/+3
| | | | | | | | | | Reviewers: austin, alanz, bgamari Reviewed By: alanz, bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2836
* Fix cost-centre-stacks bug (#5654)Simon Marlow2016-12-151-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This fixes some cases of wrong stacks being generated by the profiler. For background and details on the fix see `Note [Evaluating functions with profiling]` in `rts/Apply.cmm`. This does have an impact on allocations for some programs when profiling. nofib results: ``` k-nucleotide +0.0% +8.8% +11.0% +11.0% 0.0% puzzle +0.0% +12.5% 0.244 0.246 0.0% typecheck 0.0% +8.7% +16.1% +16.2% 0.0% ------------------------------------------------------------------------ -------- Min -0.0% -0.0% -34.4% -35.5% -25.0% Max +0.0% +12.5% +48.9% +49.4% +10.6% Geometric Mean +0.0% +0.6% +2.0% +1.8% -0.3% ``` But runtimes don't seem to be affected much, and the examples I looked at were completely legitimate. For example, in puzzle we have this: ``` position :: ItemType -> StateType -> BankType position Bono = bonoPos position Edge = edgePos position Larry = larryPos position Adam = adamPos ``` where the identifiers on the rhs are all record selectors. Previously the profiler gave a stack that looked like ``` position bonoPos ... ``` i.e. `bonoPos` was at the same level of the call stack as `position`, but now it looks like ``` position bonoPos ... ``` I used the normaliser from the testsuite to diff the profiling output from other nofib programs and they all looked better. Test Plan: * the broken test passes * validate * compiled and ran all of nofib, measured perf, diff'd several .prof files Reviewers: niteria, erikd, austin, scpmw, bgamari Reviewed By: bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2804 GHC Trac Issues: #5654, #10007
* Make unboxedTuple{Type,Data}Name support 0- and 1-tuplesRyan Scott2016-12-151-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | Previously, these functions were hardcoded so as to always `error` whenever given an argument of 0 or 1. This restriction can be lifted pretty easily, however. This requires a slight tweak to `isBuiltInOcc_maybe` in `TysWiredIn` to allow it to recognize `Unit#` (which is the hard-wired `OccName` for unboxed 1-tuples). Fixes #12977. Test Plan: make test TEST=12977 Reviewers: austin, goldfire, bgamari Reviewed By: bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2847 GHC Trac Issues: #12977