summaryrefslogtreecommitdiff
path: root/compiler
Commit message (Collapse)AuthorAgeFilesLines
* EPA: Tidy up some GHC.Parser.Annotation commentswip/az/exactprint-tweak-parser-state-commentGHC GitLab CI2021-03-251-14/+33
| | | | | | This is a follow up from !2418 / #19579 [skip ci]
* EPA : Remove ApiAnn from ParsedModuleGHC GitLab CI2021-03-259-37/+20
| | | | | All the comments are now captured in the AST, there is no need for a side-channel structure for them.
* Add compiler linting to CIHécate2021-03-2529-135/+107
| | | | | This commit adds the `lint:compiler` Hadrian target to the CI runner. It does also fixes hints in the compiler/ and libraries/base/ codebases.
* Fix the binder-swap transformation in OccurAnalSimon Peyton Jones2021-03-242-53/+116
| | | | | | | | | | The binder-swap transformation needs to be iterated, as shown by #19581. The fix is pretty simple, and is explained in point (BS2) of Note [The binder-swap substitution]. Net effect: - sometimes, fewer simplifier iterations - sometimes, more case merging
* STG AST - Make ConstructorNumber always a field.Andreas Klebinger2021-03-243-11/+5
| | | | | | | | It's used by all passes and already used as a regular field. So I figured it would be both more consistent and performant to make it a regular field for all constructors. I also added a few bangs in the process.
* CmmToAsm.Reg.Linear: oneShot-ify RegMwip/ncg-perfBen Gamari2021-03-241-16/+22
| | | | | | | | | | | | | ------------------------- Metric Decrease: T783 T4801 T12707 T13379 T3294 T4801 T5321FD -------------------------
* CmmToAsm.Reg.Linear: Use concat rather than repeated (++)Ben Gamari2021-03-241-2/+1
|
* Move loader state into InterpSylvain Henry2021-03-2318-558/+627
| | | | | | | | | | | | | | | | | | The loader state was stored into HscEnv. As we need to have two interpreters and one loader state per interpreter in #14335, it's natural to make the loader state a field of the Interp type. As a side effect, many functions now only require a Interp parameter instead of HscEnv. Sadly we can't fully free GHC.Linker.Loader of HscEnv yet because the loader is initialised lazily from the HscEnv the first time it is used. This is left as future work. HscEnv may not contain an Interp value (i.e. hsc_interp :: Maybe Interp). So a side effect of the previous side effect is that callers of the modified functions now have to provide an Interp. It is satisfying as it pushes upstream the handling of the case where HscEnv doesn't contain an Interpreter. It is better than raising a panic (less partial functions, "parse, don't validate", etc.).
* PPC NCG: Fix int to float conversionPeter Trommler2021-03-231-6/+26
| | | | | | | | In commit 540fa6b2 integer to float conversions were changed to round to the nearest even. Implement a special case for 64 bit integer to single precision floating point numbers. Fixes #19563.
* UniqSM: oneShot-ifyBen Gamari2021-03-221-10/+21
| | | | | | | | | | Part of #18202 ------------------------- Metric Decrease: T12707 T3294 -------------------------
* Short-circuit warning generation for partial type signaturesSimon Peyton Jones2021-03-221-2/+28
| | | | | | | | | | | | | | | | | | | | | | | | This Note says it all: Note [Skip type holes rapidly] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Suppose we have module with a /lot/ of partial type signatures, and we compile it while suppressing partial-type-signature warnings. Then we don't want to spend ages constructing error messages and lists of relevant bindings that we never display! This happened in #14766, in which partial type signatures in a Happy-generated parser cause a huge increase in compile time. The function ignoreThisHole short-circuits the error/warning generation machinery, in cases where it is definitely going to be a no-op. It makes a pretty big difference on the Sigs.hs example in #14766: Compile-time allocation GHC 8.10 5.6G Before this patch 937G With this patch 4.7G Yes, that's more than two orders of magnitude!
* compiler: Introduce mutableByteArrayContents# primopBen Gamari2021-03-222-0/+8
| | | | | As noted in #19540, a number of users within and outside of GHC rely on unsafeCoerceUnlifted to work around the fact that this was missing
* Remove unnecessary extendTyVarEnvFVRn functionRyan Scott2021-03-213-11/+6
| | | | | | | | | | | The `extendTyVarEnvFVRn` function does the exact same thing as `bindLocalNamesFV`. I see no meaningful distinction between the two functions, so let's just remove the former (which is only used in a handful of places) in favor of the latter. Historical note: `extendTyVarEnvFVRn` and `bindLocalNamesFV` used to be distinct functions, but their implementations were synchronized in 2004 as a part of commit 20e39e0e07e4a8e9395894b2785d6675e4e3e3b3.
* Bump template-haskell version to 2.18.0.0wip/T19083Ryan Scott2021-03-201-1/+1
| | | | | | | This requires bumping the `exceptions` and `text` submodules to bring in commits that bump their respective upper version bounds on `template-haskell`. Fixes #19083.
* Fix literals for unregisterized backend of small typesJohn Ericson2021-03-201-5/+16
| | | | | | | | | | | | | | | | | | | | | | All credit to @hsyl20, who in https://gitlab.haskell.org/ghc/ghc/-/merge_requests/4717#note_338560 figured out this was a problem. To fix this, we use casts in addition to the shrinking and suffixing that is already done. It might make for more verbose code, I don't think that matters too much. In the future, perhaps some of the shrinking and suffixing can be removed for being redundant. That proved less trivial than it sounds, so this wasn't done at this time. Progress towards #19026 Metric Increase: T12707 T13379 Co-authored-by: Sylvain Henry <hsyl20@gmail.com>
* Fix an levity-polymorphism errorSimon Peyton Jones2021-03-202-89/+95
| | | | | | | | As #19522 points out, we did not account for visible type application when trying to reject naked levity-polymorphic functions that have no binding. This patch tidies up the code, and fixes the bug too.
* Nested CPR light (#19398)Sebastian Graf2021-03-206-477/+635
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | While fixing #19232, it became increasingly clear that the vestigial hack described in `Note [Optimistic field binder CPR]` is complicated and causes reboxing. Rather than make the hack worse, this patch gets rid of it completely in favor of giving deeply unboxed parameters the Nested CPR property. Example: ```hs f :: (Int, Int) -> Int f p = case p of (x, y) | x == y = x | otherwise = y ``` Based on `p`'s `idDemandInfo` `1P(1P(L),1P(L))`, we can see that both fields of `p` will be available unboxed. As a result, we give `p` the nested CPR property `1(1,1)`. When analysing the `case`, the field CPRs are transferred to the binders `x` and `y`, respectively, so that we ultimately give `f` the CPR property. I took the liberty to do a bit of refactoring: - I renamed `CprResult` ("Constructed product result result") to plain `Cpr`. - I Introduced `FlatConCpr` in addition to (now nested) `ConCpr` and and according pattern synonym that rewrites flat `ConCpr` to `FlatConCpr`s, purely for compiler perf reasons. - Similarly for performance reasons, we now store binders with a Top signature in a separate `IntSet`, see `Note [Efficient Top sigs in SigEnv]`. - I moved a bit of stuff around in `GHC.Core.Opt.WorkWrap.Utils` and introduced `UnboxingDecision` to replace the `Maybe DataConPatContext` type we used to return from `wantToUnbox`. - Since the `Outputable Cpr` instance changed anyway, I removed the leading `m` which we used to emit for `ConCpr`. It's just noise, especially now that we may output nested CPRs. Fixes #19398.
* Make the simplifier slightly stricter.Andreas Klebinger2021-03-205-49/+133
| | | | | | | | | | | | | | | | | | | | | | | | | | | This commit reduces allocations by the simplifier by 3% for the Cabal test at -O2. We do this by making a few select fields, bindings and arguments strict which reduces allocations for the simplifier by around 3% in total for the Cabal test. Which is about 2% fewer allocations in total at -O2. ------------------------- Metric Decrease: T18698a T18698b T9233 T9675 T9872a T9872b T9872c T9872d T10421 T12425 T13253 T5321FD T9961 -------------------------
* Generate GHCi bytecode from STG instead of Core and support unboxedLuite Stegeman2021-03-2016-608/+989
| | | | | | tuples and sums. fixes #1257
* Transfer tickish things to GHC.Types.TickishLuite Stegeman2021-03-2050-338/+423
| | | | | Metric Increase: MultiLayerModules
* rename Tickish to CoreTickishLuite Stegeman2021-03-2026-59/+66
|
* remove superfluous 'id' type parameter from GenTickishLuite Stegeman2021-03-2030-80/+99
| | | | | The 'id' type is now determined by the pass, using the XTickishId type family.
* Save the type of breakpoints in the Breakpoint tick in STGLuite Stegeman2021-03-2023-55/+97
| | | | | | | | GHCi needs to know the types of all breakpoints, but it's not possible to get the exprType of any expression in STG. This is preparation for the upcoming change to make GHCi bytecode from STG instead of Core.
* GHC Exactprint main commitAlan Zimmerman2021-03-20103-4762/+6694
| | | | | | | | Metric Increase: T10370 parsing001 Updates haddock submodule
* Add the main types to be used for exactprint in the GHC ASTAlan Zimmerman2021-03-201-64/+964
| | | | | | | | | | | | | | | The MR introducing the API Annotations, !2418 is huge. Conceptually it is two parts, the one deals with introducing the new types to be used for annotations, and outlining how they will be used. This is a small change, localised to compiler/GHC/Parser/Annotation.hs and is contained in this commit. The follow-up, larger commit deals with mechanically working this through the entire AST and updating all the parts affected by it. It is being split so the part that needs good review feedback can be seen in isolation, prior to the rest coming in.
* Built-in type families: CharToNat, NatToChar (#19535)Vladislav Zavialov2021-03-172-31/+123
| | | | | Co-authored-by: Daniel Rogozin <daniel.rogozin@serokell.io> Co-authored-by: Rinat Stryungis <rinat.stryungis@serokell.io>
* Disable bogus assertion (#19489)Sylvain Henry2021-03-171-2/+15
|
* CmmtoAsm.Reg.Linear: Rewrite processBen Gamari2021-03-171-33/+29
| | | | | | CmmToAsm.Reg.Linear: More strictness More strictness
* CmmToAsm.Reg.Linear: Make linearRA body a join pointBen Gamari2021-03-171-19/+17
| | | | Avoid top-level recursion.
* Eliminate selector thunk allocationsBen Gamari2021-03-171-1/+1
|
* IfaceToType: Ensure that IfaceTyConInfo is sharedBen Gamari2021-03-173-9/+18
| | | | | | | | | | | | | | | | In #19194 mpickering detailed that there are a LOT of allocations of IfaceTyConInfo: There are just two main cases: IfaceTyConInfo IsPromoted IfaceNormalTyCon and IfaceTyConInfo NotPromoted IfaceNormalTyCon. These should be made into CAFs and shared. From my analysis, the most common case is IfaceTyConInfo NotPromoted IfaceNormalTyCon (53 000) then IfaceTyConInfo IsPromoted IfaceNormalTyCon (28 000). This patch makes it so these are properly shared by using a smart constructor. Fixes #19194.
* Enhance pass result forcingSylvain Henry2021-03-172-4/+13
| | | | | | | | When we use `withTiming` we need to force the results of each timed pass to better represent the time spent in each phase. This patch forces some results that weren't before. It also retrieve timings for the CoreToStg and WriteIface passes.
* llvmGen: Accept range of LLVM versionsBen Gamari2021-03-173-9/+22
| | | | | | | Previously we would support only one LLVM major version. Here we generalize this to accept a range, taking this range to be LLVM 10 to 11, as 11 is necessary for Apple M1 support. We also accept 12, as that is what apple ships with BigSur on the M1.
* fromInteger :: Integer -> {Float,Double} now always round to nearest evenARATA Mizuki2021-03-171-11/+9
| | | | | | | | integerToFloat# and integerToDouble# were moved from ghc-bignum to base. GHC.Integer.floatFromInteger and doubleFromInteger were removed. Fixes #15926, #17231, #17782
* Fix record dot precedence (#19521)Vladislav Zavialov2021-03-152-21/+7
| | | | | By moving the handling of TIGHT_INFIX_PROJ to the correct place, we can remove the isGetField hack and fix a bug at the same time.
* Compute length only once in foldBalSylvain Henry2021-03-141-4/+11
|
* Write explicit IOEnv's Functor and MonadIO instances (#18202)Sylvain Henry2021-03-141-2/+8
|
* Pmc: Consider Required Constraints when guessing PatSyn arg types (#19475)Sebastian Graf2021-03-144-128/+210
| | | | | | | | | | | | | | | | | | | | | | This patch makes `guessConLikeUnivTyArgsFromResTy` consider required Thetas of PatSynCons, by treating them as Wanted constraints to be discharged with the constraints from the Nabla's TyState and saying "does not match the match type" if the Wanted constraints are unsoluble. It calls out into a new function `GHC.Tc.Solver.tcCheckWanteds` to do so. In pushing the failure logic around call sites of `initTcDsForSolver` inside it by panicking, I realised that there was a bunch of dead code surrounding `pmTopMoraliseType`: I was successfully able to delete the `NoChange` data constructor of `TopNormaliseTypeResult`. The details are in `Note [Matching against a ConLike result type]` and `Note [Instantiating a ConLike]. The regression test is in `T19475`. It's pretty much a fork of `T14422` at the moment. Co-authored-by: Cale Gibbard <cgibbard@gmail.com>
* Implement the UnliftedDatatypes extensionSebastian Graf2021-03-1413-158/+328
| | | | | | | | | | | | | | | | | | GHC Proposal: 0265-unlifted-datatypes.rst Discussion: https://github.com/ghc-proposals/ghc-proposals/pull/265 Issues: https://gitlab.haskell.org/ghc/ghc/-/issues/19523 Implementation Details: Note [Implementation of UnliftedDatatypes] This patch introduces the `UnliftedDatatypes` extension. When this extension is enabled, GHC relaxes the restrictions around what result kinds are allowed in data declarations. This allows data types for which an unlifted or levity-polymorphic result kind is inferred. The most significant changes are in `GHC.Tc.TyCl`, where `Note [Implementation of UnliftedDatatypes]` describes the details of the implementation. Fixes #19523.
* Ignore breakpoint for a specified number of iterations. (#19157)Roland Senn2021-03-103-7/+25
| | | | | | | | | | | | | | | | * Implement new debugger command `:ignore` to set an `ignore count` for a specified breakpoint. * Allow new optional parameter on `:continue` command to set an `ignore count` for the current breakpoint. * In the Interpreter replace the current `Word8` BreakArray with an `Int` array. * Change semantics of values in `BreakArray` to: n < 0 : Breakpoint is disabled. n == 0 : Breakpoint is enabled. n > 0 : Breakpoint is enabled, but ignore next `n` iterations. * Rewrite `:enable`/`:disable` processing as a special case of `:ignore`. * Remove references to `BreakArray` from `ghc/UI.hs`.
* Use GHC2021 as default languageJoachim Breitner2021-03-101-9/+3
|
* Introduce GHC2021 languageJoachim Breitner2021-03-102-2/+53
| | | | | | This adds support for -XGHC2021, as described in Proposal 0380 [1]. [1] https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0380-ghc2021.rst
* template-haskell: Add putDoc, getDoc, withDecDoc and friendsLuke Lau2021-03-1010-49/+323
| | | | | | | | | | | | | | | | | | | | | | | This adds two new methods to the Quasi class, putDoc and getDoc. They allow Haddock documentation to be added to declarations, module headers, function arguments and class/type family instances, as well as looked up. It works by building up a map of names to attach pieces of documentation to, which are then added in the extractDocs function in GHC.HsToCore.Docs. However because these template haskell names need to be resolved to GHC names at the time they are added, putDoc cannot directly add documentation to declarations that are currently being spliced. To remedy this, withDecDoc/withDecsDoc wraps the operation with addModFinalizer, and provides a more ergonomic interface for doing so. Similarly, the funD_doc, dataD_doc etc. combinators provide a more ergonomic interface for documenting functions and their arguments simultaneously. This also changes ArgDocMap to use an IntMap rather than an Map Int, for efficiency. Part of the work towards #5467
* Bump bytestring submodule to 0.11.1.0Ben Gamari2021-03-102-1/+3
|
* FastString: Use FastMutInt instead of IORef IntBen Gamari2021-03-101-12/+13
| | | | This saves at least one I# allocation per FastString.
* FastMutInt: Introduce atomicFetchAddFastMutIntBen Gamari2021-03-101-7/+13
| | | | This will be needed by FastString.
* FastMutInt: Ensure that newFastMutInt initializes valueBen Gamari2021-03-106-38/+31
| | | | Updates haddock submodule.
* FastMutInt: Drop FastMutPtrBen Gamari2021-03-101-25/+1
| | | | This appears to be unused.
* Simplify shadowing of DuplicateRecordFields in GHCi (fixes #19314)Adam Gundry2021-03-104-18/+18
| | | | | | | Previously, defining fields with DuplicateRecordFields in GHCi lead to strange shadowing behaviour, whereby fields would (accidentally) not shadow other fields. This simplifies things so that fields are shadowed in the same way whether or not DuplicateRecordFields is enabled.
* Do not remove shadowed record selectors from interactive context (fixes #19322)Adam Gundry2021-03-101-1/+4
|