summaryrefslogtreecommitdiff
path: root/compiler
Commit message (Collapse)AuthorAgeFilesLines
* CmmParse: Emit source notes for assignmentsBen Gamari2017-07-031-2/+2
| | | | | | | Currently the line information for bare source C-- is rather spartan. These add notes for assignments, which tend to be useful to identify. Unfortunately, we had to settle for approximate source locations as none of the parsers in CmmParse return located things. However, I don't think it's worth changing this.
* Fix -fno-code for modules that use -XQuasiQuotesDouglas Wilson2017-07-033-11/+20
| | | | | | | | | | | | | | | | | | | | | | In commit 53c78be0aab76a3107c4dacbb1d177afacdd37fa object code is generated for modules depended on by modules that use -XTemplateHaskell. This turns the same logic on for modules that use -XQuasiQuotes. A test is added. Note that I've based this of D3646, as it has a function I want to use. Test Plan: ./validate Reviewers: austin, bgamari, alexbiehl Reviewed By: alexbiehl Subscribers: alexbiehl, rwbarton, thomie GHC Trac Issues: #13863 Differential Revision: https://phabricator.haskell.org/D3677
* Fix #13311 by using tcSplitNestedSigmaTys in the right placeRyan Scott2017-07-032-6/+49
| | | | | | | | | | | | | | | | | | | Previously, we we only using `tcSplitSigmaTy` when determining if a function had been applied to too few arguments, so it wouldn't work for functions with nested `forall`s. Thankfully, this is easily fixed with a dash of `tcSplitNestedSigmaTys`. Test Plan: make test TEST=T13311 Reviewers: austin, bgamari, simonpj Reviewed By: bgamari Subscribers: goldfire, simonpj, rwbarton, thomie GHC Trac Issues: #13311 Differential Revision: https://phabricator.haskell.org/D3678
* Implement recompilation checking for -fignore-assertsÖmer Sinan Ağacan2017-07-031-1/+5
| | | | | | | | | | | | | | Test Plan: Added a test which was previously failing Reviewers: austin, bgamari, simonpj Reviewed By: simonpj Subscribers: simonpj, rwbarton, thomie GHC Trac Issues: #13914 Differential Revision: https://phabricator.haskell.org/D3698
* Allow per-argument documentation on pattern synonym signaturesalexbiehl2017-07-031-1/+1
| | | | | | | | | | | | | haddock-2.18 supports user defined pattern synonym signatures so this seems like a welcomed addition. Reviewers: austin, bgamari, mpickering Reviewed By: bgamari, mpickering Subscribers: rwbarton, thomie, mpickering Differential Revision: https://phabricator.haskell.org/D3699
* rename tcInstBinder(s)X to tcInstBinder(s)Gabor Greif2017-07-033-14/+14
| | | | | | | | | | | | Summary: Simplify naming scheme of tcInstBinder(s)X Test Plan: Eyeball and compile Reviewers: austin, goldfire, bgamari Subscribers: goldfire, rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D3690
* Prevent ApplicativeDo from applying to strict pattern matches (#13875)Simon Marlow2017-06-291-6/+56
| | | | | | | | | | | | | | | | Test Plan: * New unit tests * validate Reviewers: dfeuer, simonpj, niteria, bgamari, austin, erikd Reviewed By: dfeuer Subscribers: rwbarton, thomie GHC Trac Issues: #13875 Differential Revision: https://phabricator.haskell.org/D3681
* Allow optional instance keyword in associated type family instancesTibor Erdesz2017-06-291-7/+27
| | | | | | | | | | | | | | | Add the missing branch for parsing the optional 'instance' keyword in associated type family instance declarations. Fixes #13747 Reviewers: austin, bgamari Reviewed By: bgamari Subscribers: simonpj, RyanGlScott, rwbarton, thomie, mpickering Differential Revision: https://phabricator.haskell.org/D3673
* Typos in commentsRyan Scott2017-06-294-5/+5
| | | | [ci skip]
* Revert "Remove the Windows GCC driver."Simon Peyton Jones2017-06-291-25/+13
| | | | | | | | | | | | | | | | | | This reverts commit d6cecde585b0980ed8e0050c5a1d315789fb6356. The patch broke Simon PJ's Windows build, becuase he didn't have (and should not need) a separate msys2 gcc. Following an exchange on the ghc-devs list, Tamar wrote Oops, sorry, didn’t notice it because both mine and harbormaster’s msys2 have separate GCCs installed as well. I don’t see an easy fix that would also work for end user Configure based cabal installs. So I think I’ll have to go back to the drawing board for this one. You can just leave it reverted.
* Fix lexically-scoped type variablesSimon Peyton Jones2017-06-293-28/+60
| | | | | | | | | | Trac #13881 showed that our handling of lexically scoped type variables was way off when we bring into scope a name 'y' for a pre-existing type variable 'a', perhaps with an entirely different name. This patch fixes it; see TcHsType Note [Pattern signature binders]
* remove dead function 'tcInstBinders'Gabor Greif2017-06-291-6/+1
|
* Remove unneeded importGabor Greif2017-06-281-2/+2
| | | | | | | | | This fails in stage 2 when bootstrapping HEAD with HEAD due to -Werror. Turns out that tcInstBinders is now dead, and I'll remove it if nobody protests. I'd like to hear opinions whether tcInstBindersX then should be renamed to tcInstBinders.
* More typos in comments [ci skip]Gabor Greif2017-06-285-5/+5
|
* Typos in comments and manual [ci skip]Gabor Greif2017-06-284-5/+5
|
* Zap stable unfoldings in worker/wrapperSimon Peyton Jones2017-06-283-6/+13
| | | | This patch fixes the buglet described in Trac #13890.
* Fix constraint solving for forall-typesSimon Peyton Jones2017-06-282-72/+121
| | | | | | | | | | | | Trac #13879 showed that when we were trying to solve (forall z1 (y1::z1). ty1) ~ (forall z2 (y2:z2). ty2) we'd end up spitting out z1~z2 with no binding site for them. Those kind equalities need to be inside the implication. I ended up re-factoring the code for solving forall-equalities. It's quite nice now.
* Do zonking in tcLHsKindSigSimon Peyton Jones2017-06-282-11/+19
| | | | | | | Trac #13879 showed that there was a missing zonk in tcLHsKind. I also renamed it to tcLHsKindSig, for consistency with type signatures There's a commment to explain why the zonk is needed.
* Fix the in-scope set in TcHsType.instantiateTyNSimon Peyton Jones2017-06-281-1/+6
| | | | See Trac #13879
* Revert "Make module membership on ModuleGraph faster"Ben Gamari2017-06-277-174/+54
| | | | | | I had not intended on merging this. This reverts commit b0708588e87554899c2efc80a2d3eba353dbe926.
* Make module membership on ModuleGraph fasterBartosz Nitka2017-06-277-54/+174
| | | | | | | | | | | | | | | | | | | When loading/reloading with a large number of modules (>5000) the cost of linear lookups becomes significant. The changes here made `:reload` go from 6s to 1s on my test case. The bottlenecks were `needsLinker` in `DriverPipeline` and `getModLoop` in `GhcMake`. Test Plan: ./validate Reviewers: simonmar, austin, bgamari Subscribers: rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D3646
* Treat banged bindings as FunBindsBen Gamari2017-06-2711-53/+157
| | | | | | | | | | | | | | | This is another attempt at resolving #13594 by treating strict variable binds as FunBinds instead of PatBinds (as suggested in comment:1). Test Plan: Validate Reviewers: austin, alanz Subscribers: rwbarton, thomie, mpickering GHC Trac Issues: #13594 Differential Revision: https://phabricator.haskell.org/D3670
* typecheck: Consider types containing coercions non-TypeableBen Gamari2017-06-271-1/+1
| | | | | | | | | | | | | | | This was previously a panic and caused #13871. I believe just saying these types simply aren't Typeable should be correct. Test Plan: Validate, check `T13871` Reviewers: goldfire, austin Subscribers: rwbarton, thomie, RyanGlScott GHC Trac Issues: #13871 Differential Revision: https://phabricator.haskell.org/D3672
* Allow bytecode interpreter to make unsafe foreign callsBen Gamari2017-06-272-7/+16
| | | | | | | | | | | | Reviewers: austin, hvr, erikd, simonmar Reviewed By: simonmar Subscribers: rwbarton, thomie GHC Trac Issues: #8281, #13730. Differential Revision: https://phabricator.haskell.org/D3619
* DWARF: Use .short to render half-machine-wordsBen Gamari2017-06-261-8/+1
| | | | | | | | | | | | | | | | | | | | | | | | | The binutils documentation states that .short is a synonym for .word, which I assumed to mean "machine word", leading me to believe that we needed to use .hword to render half-machine-words. However, Darwin's toolchain doesn't understand .hword, so there we instead used .short. However, as it turns out the binutils documentation confusingly uses "word" to refer to a 16-bit word, so .short should work fine. Moreover, LLVM's internal assembler also doesn't understand .hword, so using .short consistently simplies things remarkably. Test Plan: Validate using binutils and LLVM internal assembler, validate on Darwin Reviewers: niteria, austin Reviewed By: niteria Subscribers: rwbarton, thomie GHC Trac Issues: #13866 Differential Revision: https://phabricator.haskell.org/D3667
* Hoopl: remove dependency on Hoopl packageMichal Terepeta2017-06-2352-91/+947
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This copies the subset of Hoopl's functionality needed by GHC to `cmm/Hoopl` and removes the dependency on the Hoopl package. The main motivation for this change is the confusing/noisy interface between GHC and Hoopl: - Hoopl has `Label` which is GHC's `BlockId` but different than GHC's `CLabel` - Hoopl has `Unique` which is different than GHC's `Unique` - Hoopl has `Unique{Map,Set}` which are different than GHC's `Uniq{FM,Set}` - GHC has its own specialized copy of `Dataflow`, so `cmm/Hoopl` is needed just to filter the exposed functions (filter out some of the Hoopl's and add the GHC ones) With this change, we'll be able to simplify this significantly. It'll also be much easier to do invasive changes (Hoopl is a public package on Hackage with users that depend on the current behavior) This should introduce no changes in functionality - it merely copies the relevant code. Signed-off-by: Michal Terepeta <michal.terepeta@gmail.com> Test Plan: ./validate Reviewers: austin, bgamari, simonmar Reviewed By: bgamari, simonmar Subscribers: simonpj, kavon, rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D3616
* Use actual universal tvs in check for naughty record selectorsMatthew Pickering2017-06-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The naughty record selector check means to limit selectors which would lead to existential tyvars escaping their scope. With record pattern synonyms, there are situations where universal tyvars don't appear in the result type, for example: ``` pattern ReadP :: Read a => a -> String pattern ReadP{readp} <- (read -> readp) ``` This is a similar issue to #11224 where we assumed that we can decide which variables are universal and which are existential by the syntactic check of seeing which appear in the result type. The fix is to use `univ_tvs` from `conLikeFullSig` rather than the previous approximation. But we must also remember to apply `EqSpec`s so we use the free variables from `inst_tys` which is precisely `univ_tvs` with `EqSpecs` applied. Reviewers: austin, bgamari Reviewed By: bgamari Subscribers: rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D3649
* Fix pretty-printing of zero-argument lambda expressionsRyan Scott2017-06-231-0/+4
| | | | | | | | | | | | | | | | | | Using Template Haskell, one can construct lambda expressions with no arguments. The pretty-printer isn't aware of this fact, however. This changes that. Test Plan: make test TEST=T13856 Reviewers: bgamari, austin, goldfire Reviewed By: bgamari Subscribers: rwbarton, thomie GHC Trac Issues: #13856 Differential Revision: https://phabricator.haskell.org/D3664
* compiler: Eliminate pprTrace in SPT entry addition codepathBen Gamari2017-06-231-2/+1
| | | | | | | | | | | | | Test Plan: Load program with StaticPointers into GHCi, ensure no tracing output makes it in. Reviewers: austin Subscribers: rwbarton, thomie, RyanGlScott GHC Trac Issues: #12356 Differential Revision: https://phabricator.haskell.org/D3663
* change filtering of variables in extract_hs_tv_bndrs (fixes #13782)Carlos Tomé2017-06-211-79/+28
| | | | | | | | | | | | Reviewers: austin, bgamari, goldfire Reviewed By: bgamari Subscribers: rwbarton, thomie GHC Trac Issues: #13782 Differential Revision: https://phabricator.haskell.org/D3641
* Fix note reference [ci skip]Gabor Greif2017-06-201-1/+1
|
* Improve comments on AbsBindsSimon Peyton Jones2017-06-191-36/+55
| | | | See Trac #13827.
* Reword documentation region overlap documentation for copying mutable arraysAndrew Martin2017-06-191-6/+14
|
* cmm/CmmLayoutStack: avoid generating unnecessary reloadsMichal Terepeta2017-06-192-32/+240
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This tries to be more precise when generating reloads of local registers in proc points. Previously we'd reload all local registers that were live. But we used liveness information that assumed local registers survive native calls. For the purpose of reloading registers this is an overapproximation and might lead to generating huge amounts of unnecessary reloads (in case there's another proc point before the register is used). This change takes the approach of moving the generation of reloads to a second pass over the Cmm, which allows to recompute the liveness and can use the knowledge that local registers do *not* survive calls. This leads to generating only useful reloads. For an extreme example where this helps a lot please see T3294. This should also fix #7198 Finally, this re-introduces the code to do Cmm rewriting using in `Dataflow` module (with the difference that we know operate on a whole block at a time). Signed-off-by: Michal Terepeta <michal.terepeta@gmail.com> Reviewers: austin, bgamari, simonmar Reviewed By: simonmar Subscribers: kavon, rwbarton, thomie GHC Trac Issues: #7198 Differential Revision: https://phabricator.haskell.org/D3586
* Look through type synonyms in existential contexts when deriving FunctorRyan Scott2017-06-181-2/+16
| | | | | | | | | | | | | | | | | | | | Summary: This amounts to using `exactTyCoVarsOfType` instead of `tyCoVarsOfType` in the right place. I also fixed a similar issue for `-XDatatypeContexts` while I was in town (but couldn't be bothered to add a test for it). Test Plan: make test TEST=T13813 Reviewers: austin, bgamari, simonpj Reviewed By: simonpj Subscribers: simonpj, rwbarton, thomie GHC Trac Issues: #13813 Differential Revision: https://phabricator.haskell.org/D3635
* Fix out-of-date comments in TyCoRepRyan Scott2017-06-181-3/+3
| | | | s/tyVarsOfType/tyCoFVsOfType/g
* Remove the Windows GCC driver.Tamar Christina2017-06-171-13/+25
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: This patch drops the GCC driver and instead moves the only remaining path that we need to keep for backwards compatibility to the settings file. It also generalizes the code that expands `$TopDir` so it can expand it within any location in the string and also changes it so `$TopDir` is expanded only after the words call because `$TopDir` can contains spaces which would be horribly broken. Test Plan: ./validate Reviewers: austin, hvr, bgamari Reviewed By: bgamari Subscribers: rwbarton, thomie, erikd GHC Trac Issues: #13709 Differential Revision: https://phabricator.haskell.org/D3592
* Fix the treatment of 'closed' definitionsSimon Peyton Jones2017-06-165-178/+249
| | | | | | | | | | | | | | | | | | | | | | | | | | | The IdBindingInfo field of ATcId serves two purposes - to control generalisation when we have -XMonoLocalBinds - to check for floatability when dealing with (static e) These are related, but not the same, and they'd becomme confused. Trac #13804 showed this up via an example like this: f periph = let sr :: forall a. [a] -> [a] sr = if periph then reverse else id sr2 = sr -- The question: is sr2 generalised? -- It should be, because sr has a type sig -- even though it has periph free in (sr2 [True], sr2 "c") Here sr2 should be generalised, despite the free var 'periph' in 'sr' because 'sr' has a closed type signature. I documented all this very carefully this time, in TcRnTypes: Note [Meaning of IdBindingInfo] Note [Bindings with closed types: ClosedTypeId]
* Add mapMG to allow making ModuleGraph abstractBartosz Nitka2017-06-142-3/+7
| | | | | | | | | | | | | | | | | | | | | Currently GHC exposes the internal details of `ModuleGraph` which inhibits making `ModuleGraph` support faster lookups. Haddock relies on the internal representation by using `map` on `ModuleGraph`. See also https://github.com/haskell/haddock/issues/635 Adding `mapMG` should allow us to make `ModuleGraph` abstract. Test Plan: ./validate Reviewers: simonmar, austin, bgamari, alexbiehl Reviewed By: bgamari, alexbiehl Subscribers: alexbiehl, rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D3645
* Typos [ci skip]Gabor Greif2017-06-132-2/+2
|
* Make -w less aggressive (Trac #12056)Sean Gillespie2017-06-124-36/+82
| | | | | | | | | | | | | | | Previously -w combined with -Wunrecognised-warning-flags would not report unrecognized flags. Reviewers: austin, bgamari, dfeuer Reviewed By: bgamari Subscribers: dfeuer, rwbarton, thomie GHC Trac Issues: #12056 Differential Revision: https://phabricator.haskell.org/D3581
* Stop forcing everything in coreBindsSizeDavid Feuer2017-06-121-18/+12
| | | | | | | | | | | | | | | | | | | | `coreBindsSize` forced a ton of structure to stop space leaks. Reid Barton has done some work recently to try to stop the leaks at their source instead. Memory residency remains well below the numbers Herbert posted on #13426 originally, but in some cases a ways above the ones from 8.0. I need to figure out how to get the numbers matched up to individual modules and do some profiling. Relates to #13426 Reviewers: austin, bgamari Reviewed By: bgamari Subscribers: rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D3606
* Support signatures at the kind level in Template HaskellRyan Scott2017-06-122-13/+32
| | | | | | | | | | | | | | | | | `repNonArrowKind` was missing a case for `HsKindSig`, which this commit adds. Fixes #13781. Test Plan: make test TEST=T13781 Reviewers: goldfire, austin, bgamari Reviewed By: goldfire Subscribers: rwbarton, thomie GHC Trac Issues: #13781 Differential Revision: https://phabricator.haskell.org/D3627
* Fix #13807 - foreign import nondeterminismBartosz Nitka2017-06-121-8/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The problem was that the generated label included a freshly assigned Unique value. Test Plan: Added a new test and looked at the generated stub: ``` #include "HsFFI.h" #ifdef __cplusplus extern "C" { #endif extern HsInt zdmainzdAzdAzuzzlzzgzzg(StgStablePtr the_stableptr); extern HsInt zdmainzdAzdAzumkStringWriter(StgStablePtr the_stableptr); #ifdef __cplusplus } #endif ``` ./validate Reviewers: simonmar, austin, bgamari Reviewed By: simonmar Subscribers: rwbarton, thomie GHC Trac Issues: #13807 Differential Revision: https://phabricator.haskell.org/D3633
* Improve getNameToInstancesIndexDouglas Wilson2017-06-122-8/+18
| | | | | | | | | | | | | | Put it in a GhcMonad. Stop accidentally reversing the list of instances. Add a comment noting the code is mostly copied from tcRnGetInfo. Reviewers: austin, bgamari Reviewed By: bgamari Subscribers: mpickering, rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D3636
* Fix a bug in -foptimal-applicative-doSimon Marlow2017-06-121-1/+1
| | | | | | | | | | | | Test Plan: validate Reviewers: bgamari, niteria, austin, erikd Reviewed By: bgamari Subscribers: rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D3640
* Add tcRnGetNameToInstancesIndexDouglas Wilson2017-06-082-0/+42
| | | | | | | | | | | | | | | | | | | This function in tcRnDriver, retrieves an index by name of all Class and Family instances in the current environment. This is to be used by haddock which currently looks up instances for each name, which looks at every instance for every lookup. Using this function instead of tcRnGetInfo, the haddock.base performance test improves by 10% Reviewers: austin, bgamari Reviewed By: bgamari Subscribers: alexbiehl, rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D3624
* Refactor temp files cleanupDouglas Wilson2017-06-0815-304/+401
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Remove filesToNotIntermediateClean from DynFlags, create a data type FilesToClean, and change filesToClean in DynFlags to be a FilesToClean. Modify SysTools.newTempName and the Temporary constructor of PipelineMonad.PipelineOutput to take a TempFileLifetime, which specifies whether a temp file should live until the end of GhcMonad.withSession, or until the next time cleanIntermediateTempFiles is called. These changes allow the cleaning of intermediate files in GhcMake to be much more efficient. HscTypes.hptObjs is removed as it is no longer used. A new performance test T13701 is added, which passes both with and without -keep-tmp-files. The test fails by 25% without the patch, and passes when -keep-tmp-files is added. Note that there are still at two hotspots caused by algorithms quadratic in the number of modules, however neither of them allocate. They are: * DriverPipeline.compileOne'.needsLinker * GhcMake.getModLoop DriverPipeline.compileOne'.needsLinker is changed slightly to improve the situation. I don't like adding these Types to DynFlags, but they need to be seen by Dynflags, SysTools and PipelineMonad. The alternative seems to be to create a new module. Reviewers: austin, hvr, bgamari, dfeuer, niteria, simonmar, erikd Reviewed By: simonmar Subscribers: rwbarton, thomie GHC Trac Issues: #13701 Differential Revision: https://phabricator.haskell.org/D3620
* Revert "Make LLVM output robust to -dead_strip on mach-o platforms"Ben Gamari2017-06-082-72/+12
| | | | This reverts commit 667abf17dced8b4a4cd2dc6a291a6f244ffa031f.
* Stop the specialiser generating loopy codeSimon Peyton Jones2017-06-071-173/+240
| | | | | | | | | | | | | | | | | | | | This patch fixes a bad bug in the specialiser, which showed up as Trac #13429. When specialising an imported DFun, the specialiser could generate a recusive loop where none existed in the original program. It's all rather tricky, and I've documented it at some length in Note [Avoiding loops] We'd encoutered exactly this before (Trac #3591) but I had failed to realise that the very same thing could happen for /imported/ DFuns. I did quite a bit of refactoring. The compiler seems to get a tiny bit faster on deriving/perf/T10858 but almost all the gain had occurred before now; this patch just pushed it over the line.