summaryrefslogtreecommitdiff
path: root/compiler
Commit message (Collapse)AuthorAgeFilesLines
...
* Make non-streaming LLVM and C backends streamingÖmer Sinan Ağacan2019-08-234-20/+19
| | | | | | | | | This adds a Stream.consume function, uses it in LLVM and C code generators, and removes the use of Stream.collect function which was used to collect streaming Cmm generation results into a list. LLVM and C backends now properly use streamed Cmm generation, instead of collecting Cmm groups into a list before generating LLVM/C code.
* Remove special case in SRT generation with -split-sectionsÖmer Sinan Ağacan2019-08-221-26/+5
| | | | | | | | | Previously we were using an empty ModuleSRTInfo for each Cmm group with -split-section. As far as I can see this has no benefits, and simplifying this makes another patch simpler (!1304). We also remove some outdated comments: we no longer generate one module-level SRT.
* Doc: add Haddocks for quotRemWord2 primopSylvain Henry2019-08-221-2/+2
|
* Remove Bag fold specialisations (#16969)Richard Lupton2019-08-1922-75/+50
|
* Use Foldable instance of Bag for specialised Bag folds (#16969)Richard Lupton2019-08-191-19/+26
|
* Re-export foldlM and foldrM from Data.Foldable in MonadUtils (#16969)Richard Lupton2019-08-191-9/+1
|
* Generalized MonadUtils folds to Foldable (#16969)Richard Lupton2019-08-191-6/+5
|
* expose ModuleInfo.minf_rdr_env for tooling authorsSam Halliday2019-08-181-0/+4
|
* Fix #17067 by making data family type constructors actually injectiveRyan Scott2019-08-181-2/+3
| | | | | | | | `TcTyClsDecls.tcFamDecl1` was using `NotInjective` when creating data family type constructors, which is just plain wrong. This tweaks it to use `Injective` instead. Fixes #17067.
* Typo fix in CoreToStgÖmer Sinan Ağacan2019-08-181-5/+5
|
* Faster exactLog2Sylvain Henry2019-08-181-14/+8
| | | | | | Make `exactLog2` faster (use `countLeadingZeros` and Int32 bit-ops). On my Core i7-9700k Criterion reports ~50% speedup (from 16 to 8ns).
* Document types of LitNumbers, minor refactoring in Literal.hsÖmer Sinan Ağacan2019-08-151-10/+28
|
* Cmm: constant folding `quotRem x 2^N`Sylvain Henry2019-08-151-11/+39
| | | | | | `quot` and `rem` are implemented efficiently when the second argument is a constant power of 2. This patch uses the same implementations for `quotRem` primop.
* Make add_info attach unfoldings (#16615)Tobias Dammers2019-08-152-28/+93
|
* Remove unused imports of the form 'import foo ()' (Fixes #17065)James Foster2019-08-1532-37/+13
| | | | | | | | | | | These kinds of imports are necessary in some cases such as importing instances of typeclasses or intentionally creating dependencies in the build system, but '-Wunused-imports' can't detect when they are no longer needed. This commit removes the unused ones currently in the code base (not including test files or submodules), with the hope that doing so may increase parallelism in the build system by removing unnecessary dependencies.
* GHCi supports not-necessarily-lifted join pointsRichard Eisenberg2019-08-145-33/+128
| | | | | | | | | | | | | | | | Fixes #16509. See Note [Not-necessarily-lifted join points] in ByteCodeGen, which tells the full story. This commit also adds some comments and cleans some code in the byte-code generator, as I was exploring around trying to understand it. (This commit removes an old test -- this is really a GHCi problem, not a pattern-synonym problem.) test case: ghci/scripts/T16509
* Rework the Binary Integer instance.Andreas Klebinger2019-08-141-22/+74
| | | | | | | | | | | | We used to serialise large integers as strings. Now they are serialized as a list of Bytes. This changes the size for a Integer in the higher 64bit range from 77 to 9 bytes when written to disk. The impact on the general case is small (<1% for interface files) as we don't use many Integers. But for code that uses many this should be a nice benefit.
* Add Foldable, Traversable instances for Uniq(D)FMSebastian Graf2019-08-132-4/+38
| | | | | The `UniqDFM` is deterministic, of course, while we provide an unsafe `NonDetUniqFM` wrapper for `UniqFM` to opt into nondeterministic instances.
* Reformat comments in StgSynÖmer Sinan Ağacan2019-08-101-158/+141
| | | | | | | This does not make any changes in the contents -- formatting only. Previously the comments were too noisy and I've always found it very hard to read. Hopefully it's easier to read now.
* Add timing on loadInterfaceBen Gamari2019-08-101-1/+2
| | | | | AndreasK recently mentioned that he thought that interface file loading may be a non-trivial cost. Let's measure.
* Consolidate `TablesNextToCode` and `GhcUnreigsterised` in configure (#15548)Joachim Breitner2019-08-102-11/+5
| | | | | | | | | | | | | | | | | | | | `TablesNextToCode` is now a substituted by configure, where it has the correct defaults and error handling. Nowhere else needs to duplicate that, though we may want the compiler to to guard against bogus settings files. I renamed it from `GhcEnableTablesNextToCode` to `TablesNextToCode` to: - Help me guard against any unfixed usages - Remove any lingering connotation that this flag needs to be combined with `GhcUnreigsterised`. Original reviewers: Original subscribers: TerrorJack, rwbarton, carter Original Differential Revision: https://phabricator.haskell.org/D5082
* Fix bug preventing information about patterns from being serialized in .hie ↵Zubin Duggal2019-08-074-18/+72
| | | | files
* Explicitly number equations when printing axiom incompatibilitiesmniip2019-08-071-18/+24
|
* Add a -fprint-axiom-incomps option (#15546)mniip2019-08-073-25/+52
| | | | | | | | | | | | | | | | | | | | | | | | | | Supply branch incomps when building an IfaceClosedSynFamilyTyCon `pprTyThing` now has access to incomps. This also causes them to be written out to .hi files, but that doesn't pose an issue other than a more faithful bijection between `tyThingToIfaceDecl` and `tcIfaceDecl`. The machinery for displaying axiom incomps was already present but not in use. Since this is now a thing that pops up in ghci's :info the format was modified to look like a haskell comment. Documentation and a test for the new feature included. Test Plan: T15546 Reviewers: simonpj, bgamari, goldfire Reviewed By: simonpj Subscribers: rwbarton, carter GHC Trac Issues: #15546 Differential Revision: https://phabricator.haskell.org/D5097
* Introduce a type for "platform word size", use it instead of IntÖmer Sinan Ağacan2019-08-0610-57/+51
| | | | | | | | We introduce a PlatformWordSize type and use it in platformWordSize field. This removes to panic/error calls called when platform word size is not 32 or 64. We now check for this when reading the platform config.
* Remove dead parameter from coreToStgAppSimon Peyton Jones2019-08-061-15/+8
|
* Don't float unlifted join points to top levelSimon Peyton Jones2019-08-041-2/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Ticket #16978 showed that we were floating a recursive, unlifted join point to top level. It's very much a corner case: joinrec j :: Int# j = jump j in ... But somehow it showed up in a real program. For non-recursive bindings in SetLevels.lvlBind we were already (correctly) checking for unlifted bindings, but when I wrote that code I didn't think that a /recursive/ binding could be unlifted but /join-points/ can be! Actually I don't think that SetLevels should be floating join points at all. SetLevels really floats things to move stuff out of loops and save allocation; but none of that applies to join points. The only reason to float join points is in cases like join j1 x = join j2 y = ... in ... which we might want to swizzle to join j2 x y = ... in join j1 x = ... in ... because now j1 looks small and might be inlined away altogether. But this is a very local float perhaps better done in the simplifier. Still: this patch fixes the crash, and does so in a way that is harmless if/when we change our strategy for floating join points.
* Packages: Add timing for package database initializationBen Gamari2019-08-021-2/+7
|
* Add Note [withTiming] in compiler/main/ErrUtils.hsAlp Mestanogullari2019-08-021-0/+95
|
* compiler: emit finer grained codegen events to eventlogAlp Mestanogullari2019-08-025-48/+64
|
* Use injectiveVarsOfType to catch dodgy type family instance binders (#17008)Ryan Scott2019-08-023-90/+155
| | | | | | | | | | | | | | | | Previously, we detected dodgy type family instances binders by expanding type synonyms (via `exactTyCoVarsOfType`) and looking for type variables on the RHS that weren't mentioned on the (expanded) LHS. But this doesn't account for type families (like the example in #17008), so we instead use `injectiveVarsOfType` to only count LHS type variables that are in injective positions. That way, the `a` in `type instance F (x :: T a) = a` will not count if `T` is a type synonym _or_ a type family. Along the way, I moved `exactTyCoVarsOfType` to `TyCoFVs` to live alongside its sibling functions that also compute free variables. Fixes #17008.
* Rip out 9-year-old pattern variable hack (#17007)Ryan Scott2019-08-021-28/+0
| | | | | | | | | | | | | | | | | | GHC had an ad hoc validity check in place to rule out pattern variables bound by type synonyms, such as in the following example: ```hs type ItemColID a b = Int -- Discards a,b get :: ItemColID a b -> ItemColID a b get (x :: ItemColID a b) = x :: ItemColID a b ``` This hack is wholly unnecessary nowadays, since OutsideIn(X) is more than capable of instantiating `a` and `b` to `Any`. In light of this, let's rip out this validity check. Fixes #17007.
* Work around redundant import issueBen Gamari2019-07-311-1/+1
| | | | | | | As mentioned in #16997, GHC currently complains about this import. In general I'm reluctant to paper over things like this but in the case of an hs-boot file I think adding an import list is the right thing to do regardless of the bug.
* Move tyConAppNeedsKindSig to TypeBen Gamari2019-07-314-276/+270
| | | | | Previously it was awkwardly in TyCoFVs (and before that in TyCoRep). Type seems like a sensible place for it to live.
* Break up TyCoRepBen Gamari2019-07-3129-2522/+2658
| | | | | | | | | | | | | | | | | | | | | | | | | | This breaks up the monstrous TyCoReps module into several new modules by topic: * TyCoRep: Contains the `Coercion`, `Type`, and related type definitions and a few simple predicates but nothing further * TyCoPpr: Contains the the pretty-printer logic * TyCoFVs: Contains the free variable computations (and `tyConAppNeedsKindSig`, although I suspect this should change) * TyCoSubst: Contains the substitution logic for types and coercions * TyCoTidy: Contains the tidying logic for types While we are able to eliminate a good number of `SOURCE` imports (and make a few others smaller) with this change, we must introduce one new `hs-boot` file for `TyCoPpr` so that `TyCoRep` can define `Outputable` instances for the types it defines. Metric Increase: haddock.Cabal haddock.compiler
* Apply a missing substitution in mkEtaWW (#16979)Simon Peyton Jones2019-07-301-8/+21
| | | | | | | | | | The `mkEtaWW` case for newtypes forgot to apply the substitution to the newtype coercion, resulting in the Core Lint errors observed in #16979. Easily fixed. Fixes #16979. Co-authored-by: Ryan Scott <ryan.gl.scott@gmail.com>
* Add Note [RuntimeRep and PrimRep] in RepTypeRichard Eisenberg2019-07-294-3/+175
| | | | | | | | | | Also adds Note [Getting from RuntimeRep to PrimRep], which deocuments a related thorny process. This Note addresses #16964, which correctly observes that documentation for this thorny design is lacking. Documentation only.
* reifyTypeOfThing: panic on impossible casesVladislav Zavialov2019-07-261-1/+4
|
* TemplateHaskell: reifyType (#16976)Vladislav Zavialov2019-07-261-0/+16
|
* Change behaviour of -ddump-cmm-verbose to dump each Cmm pass output to a ↵nineonine2019-07-263-9/+15
| | | | separate file and add -ddump-cmm-verbose-by-proc to keep old behaviour (#16930)
* Banish reportFloatingViaTvs to the shadow realm (#15831, #16181)Ryan Scott2019-07-263-140/+168
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | GHC used to reject programs of this form: ``` newtype Age = MkAge Int deriving Eq via Const Int a ``` That's because an earlier implementation of `DerivingVia` would generate the following instance: ``` instance Eq Age where (==) = coerce @(Const Int a -> Const Int a -> Bool) @(Age -> Age -> Bool) (==) ``` Note that the `a` in `Const Int a` is not bound anywhere, which causes all sorts of issues. I figured that no one would ever want to write code like this anyway, so I simply banned "floating" `via` type variables like `a`, checking for their presence in the aptly named `reportFloatingViaTvs` function. `reportFloatingViaTvs` ended up being implemented in a subtly incorrect way, as #15831 demonstrates. Following counsel with the sage of gold fire, I decided to abandon `reportFloatingViaTvs` entirely and opt for a different approach that would _accept_ the instance above. This is because GHC now generates this instance instead: ``` instance forall a. Eq Age where (==) = coerce @(Const Int a -> Const Int a -> Bool) @(Age -> Age -> Bool) (==) ``` Notice that we now explicitly quantify the `a` in `instance forall a. Eq Age`, so everything is peachy scoping-wise. See `Note [Floating `via` type variables]` in `TcDeriv` for the full scoop. A pleasant benefit of this refactoring is that it made it much easier to catch the problem observed in #16181, so this patch fixes that issue too. Fixes #15831. Fixes #16181.
* Printer: add an empty line between bindings in Rec STG binding groupsÖmer Sinan Ağacan2019-07-251-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | Before: Rec { x2_r10T :: Lib.Bar [GblId, Unf=OtherCon []] = CCS_DONT_CARE Lib.Bar! [x3_r10U]; x3_r10U :: Lib.Foo [GblId, Unf=OtherCon []] = CCS_DONT_CARE Lib.Foo! [x1_r10p x2_r10T]; end Rec } After: Rec { x2_r10T :: Lib.Bar [GblId, Unf=OtherCon []] = CCS_DONT_CARE Lib.Bar! [x3_r10U]; x3_r10U :: Lib.Foo [GblId, Unf=OtherCon []] = CCS_DONT_CARE Lib.Foo! [x1_r10p x2_r10T]; end Rec }
* Make DefUses = OrdList DefUseRyan Scott2019-07-253-7/+10
| | | | | | | | | Before, `type DefUses = [DefUse]`. But lists are a terrible choice of data structure here, as we frequently append to the right of a `DefUses`, which yields some displeasing asymptotics. Let's instead use `OrdList`, which has constant-time appending to the right. This is one step on the way to #10347.
* Drop unused helpers 'mkTyClGroup' and 'emptyTyClGroup'Vladislav Zavialov2019-07-241-13/+1
|
* ASSERT(vis_flag==ForallInvis) in hsScopedTvsVladislav Zavialov2019-07-241-8/+53
|
* Make stage 1 GHC target independentJohn Ericson2019-07-241-15/+1
| | | | | Now that the target macros are not being used, we remove them. This prevents target hardcoding regressions.
* Make sure to load interfaces when running :instancesXavier Denis2019-07-231-1/+3
|
* Fix #8487: Debugger confuses variablesRoland Senn2019-07-213-13/+60
| | | | | | | | | | To display the free variables for a single breakpoint, GHCi pulls out the information from the fields `modBreaks_breakInfo` and `modBreaks_vars` of the `ModBreaks` data structure. For a specific breakpoint this gives 2 lists of types 'Id` (`Var`) and `OccName`. They are used to create the Id's for the free variables and must be kept in sync: If we remove an element from the Names list, then we also must remove the corresponding element from the OccNames list.
* Expose the GhcPrelude module.Andreas Klebinger2019-07-211-3/+1
| | | | | | | | | | This makes it simpler to load Modules importing it when using ghc-the-package. ------------------------- Metric Decrease: haddock.compiler -------------------------
* Line wrap when pp long expressions (fixes #16874)Alfredo Di Napoli2019-07-202-2/+2
| | | | | This commit fixes #16874 by using `fsep` rather than `sep` when pretty printing long patterns and expressions.