summaryrefslogtreecommitdiff
path: root/compiler/GHC
Commit message (Collapse)AuthorAgeFilesLines
* JS: fix implementation of forceBool to use JS backend syntaxwip/js-forceBoolJosh Meredith2023-03-131-1/+1
|
* Simplify: Move `wantEtaExpansion` before expensive `do_eta_expand` checkSebastian Graf2023-03-101-5/+6
| | | | | | | | There is no need to run arity analysis and what not if we are not in a Simplifier phase that eta-expands or if we don't want to eta-expand the expression in the first place. Purely a refactoring with the goal of improving compiler perf.
* JS: Fix implementation of MK_JSVALJosh Meredith2023-03-101-2/+2
|
* DmdAnal: Fix a panic on OPAQUE and trivial/PAP RHS (#22997)Sebastian Graf2023-03-101-10/+12
| | | | | | | We should not panic in `add_demands` (now `set_lam_dmds`), because that code path is legimitely taken for OPAQUE PAP bindings, as in T22997. Fixes #22997.
* Fixes #19627.Apoorv Ingle2023-03-091-2/+2
| | | | | | | | | Previously the solver failed with an unhelpful "solver reached too may iterations" error. With the fix for #21909 in place we no longer have the possibility of generating such an error if we have `-fconstraint-solver-iteration` > `-fgivens-fuel > `-fwanteds-fuel`. This is true by default, and the said fix also gives programmers a knob to control how hard the solver should try before giving up. This commit adds: * Reference to ticket #19627 in the Note [Expanding Recursive Superclasses and ExpansionFuel] * Test `typecheck/should_fail/T19627.hs` for regression purposes
* Delete created temporary subdirectories at end of session.Luite Stegeman2023-03-092-71/+117
| | | | | | | | This patch adds temporary subdirectories to the list of paths do clean up at the end of the GHC session. This fixes warnings about non-empty temporary directories. Fixes #22952
* bytecode: Fix bitmaps for BCOs used to tag tuples and prim call argsAlexis King2023-03-082-36/+61
| | | | fixes #23068
* Constraint simplification loop now depends on `ExpansionFuel`Apoorv Ingle2023-03-067-98/+290
| | | | | | | | | | | | | | instead of a boolean flag for `CDictCan.cc_pend_sc`. Pending givens get a fuel of 3 while Wanted and quantified constraints get a fuel of 1. This helps pending given constraints to keep up with pending wanted constraints in case of `UndecidableSuperClasses` and superclass expansions while simplifying the infered type. Adds 3 dynamic flags for controlling the fuels for each type of constraints `-fgivens-expansion-fuel` for givens `-fwanteds-expansion-fuel` for wanteds and `-fqcs-expansion-fuel` for quantified constraints Fixes #21909 Added Tests T21909, T21909b Added Note [Expanding Recursive Superclasses and ExpansionFuel]
* Convert diagnostics in GHC.Rename.Module to proper TcRnMessage (#20115)Andrei Borzenkov2023-03-064-139/+414
| | | | | | | | | | | | | | | | | | | | | | | | | I've turned almost all occurrences of TcRnUnknownMessage in GHC.Rename.Module module into a proper TcRnMessage. Instead, these TcRnMessage messages were introduced: TcRnIllegalInstanceHeadDecl TcRnUnexpectedStandaloneDerivingDecl TcRnUnusedVariableInRuleDecl TcRnUnexpectedStandaloneKindSig TcRnIllegalRuleLhs TcRnBadAssocRhs TcRnDuplicateRoleAnnot TcRnDuplicateKindSig TcRnIllegalDerivStrategy TcRnIllegalMultipleDerivClauses TcRnNoDerivStratSpecified TcRnStupidThetaInGadt TcRnBadImplicitSplice TcRnShadowedTyVarNameInFamResult TcRnIncorrectTyVarOnLhsOfInjCond TcRnUnknownTyVarsOnRhsOfInjCond Was introduced one helper type: RuleLhsErrReason
* Enable response files for linker if supportedGabriella Gonzalez2023-03-063-4/+7
|
* More fixes for `type data` declarationsSimon Peyton Jones2023-03-037-62/+111
| | | | | | | | | | | | | | | | | | | | | | This MR fixes #23022 and #23023. Specifically * Beef up Note [Type data declarations] in GHC.Rename.Module, to make invariant (I1) explicit, and to name the several wrinkles. And add references to these specific wrinkles. * Add a Lint check for invariant (I1) above. See GHC.Core.Lint.checkTypeDataConOcc * Disable the `caseRules` for dataToTag# for `type data` values. See Wrinkle (W2c) in the Note above. Fixes #23023. * Refine the assertion in dataConRepArgTys, so that it does not complain about the absence of a wrapper for a `type data` constructor Fixes #23022. Acked-by: Simon Peyton Jones <simon.peytonjones@gmail.com>
* Get the right in-scope set in etaBodyForJoinPointSimon Peyton Jones2023-03-021-4/+11
| | | | Fixes #23026
* ncg/aarch64: Handle MULTILINE_COMMENT identically as COMMENTsZubin Duggal2023-03-021-5/+7
| | | | | | | | Commit 7566fd9de38c67360c090f828923d41587af519c with the fix for #22798 was incomplete as it failed to handle MULTILINE_COMMENT pseudo-instructions, and didn't completly fix the compiler panics when compiling with `-fregs-graph`. Fixes #23002
* constant folding: Correct type of decodeDouble_Int64 ruleMatthew Pickering2023-03-021-5/+1
| | | | | | | | The first argument is Int64# unconditionally, so we better produce something of that type. This fixes a core lint error found in the ad package. Fixes #23019
* Check for platform support for JavaScript foreign importsLuite Stegeman2023-03-021-1/+2
| | | | | | | | | GHC was accepting `foreign import javascript` declarations on non-JavaScript platforms. This adds a check so that these are only supported on an platform that supports the JavaScript calling convention. Fixes #22774
* Don't suppress *all* WantedsRichard Eisenberg2023-03-022-17/+24
| | | | | | | | | | | | | | Code in GHC.Tc.Errors.reportWanteds suppresses a Wanted if its rewriters have unfilled coercion holes; see Note [Wanteds rewrite Wanteds] in GHC.Tc.Types.Constraint. But if we thereby suppress *all* errors that's really confusing, and as #22707 shows, GHC goes on without even realising that the program is broken. Disaster. This MR arranges to un-suppress them all if they all get suppressed. Close #22707
* fix: Consider strictness annotation in rep_bindromes2023-03-011-3/+9
| | | | Fixes #23036
* Refine the test for naughty record selectorsSimon Peyton Jones2023-03-011-36/+51
| | | | | | | The test for naughtiness in record selectors is surprisingly subtle. See the revised Note [Naughty record selectors] in GHC.Tc.TyCl.Utils. Fixes #23038.
* Account for TYPE vs CONSTRAINT in mkSelCoSimon Peyton Jones2023-02-283-7/+46
| | | | | | | As #23018 showed, in mkRuntimeRepCo we need to account for coercions between TYPE and COERCION. See Note [mkRuntimeRepCo] in GHC.Core.Coercion.
* Take more care with unlifted bindings in the specialiserSimon Peyton Jones2023-02-282-53/+89
| | | | | | | | As #22998 showed, we were floating an unlifted binding to top level, which breaks a Core invariant. The fix is easy, albeit a little bit conservative. See Note [Care with unlifted bindings] in GHC.Core.Opt.Specialise
* JS: fix for overlap with copyMutableByteArray# (#23033)Sylvain Henry2023-02-281-9/+2
| | | | | | The code wasn't taking into account some kind of overlap. cgrun070 has been extended to test the missing case.
* Account for local rules in specImportsSimon Peyton Jones2023-02-283-46/+65
| | | | | | | | | | | As #23024 showed, in GHC.Core.Opt.Specialise.specImports, we were generating specialisations (a locally-define function) for imported functions; and then generating specialisations for those locally-defined functions. The RULE for the latter should be attached to the local Id, not put in the rules-for-imported-ids set. Fix is easy; similar to what happens in GHC.HsToCore.addExportFlagsAndRules
* Don't specialise incoherent instance applicationsGergő Érdi2023-02-2720-279/+553
| | | | | | | | | | | | | | Using incoherent instances, there can be situations where two occurrences of the same overloaded function at the same type use two different instances (see #22448). For incoherently resolved instances, we must mark them with `nospec` to avoid the specialiser rewriting one to the other. This marking is done during the desugaring of the `WpEvApp` wrapper. Fixes #22448 Metric Increase: T15304
* Fix shadowing bug in prepareAltsSimon Peyton Jones2023-02-242-13/+26
| | | | | | | | As #23012 showed, GHC.Core.Opt.Simplify.Utils.prepareAlts was using an OutType to construct an InAlt. When shadowing is in play, this is outright wrong. See Note [Shadowing in prepareAlts].
* Fix ParallelListComp out of scope suggestionAaron Allen2023-02-241-7/+30
| | | | | | | | | This patch makes it so vars from one block of a parallel list comprehension are not in scope in a subsequent block during type checking. This was causing GHC to emit a faulty suggestion when an out of scope variable shared the occ name of a var from a different block. Fixes #22940
* JS: make some arithmetic primops faster (#22835)Sylvain Henry2023-02-241-2/+2
| | | | | | Don't use BigInt for wordAdd2, mulWord32, and timesInt32. Co-authored-by: Matthew Craven <5086-clyring@users.noreply.gitlab.haskell.org>
* Explicit migration timeline for loopy SC solvingsheaf2023-02-231-1/+1
| | | | | | | | | This patch updates the warning message introduced in commit 9fb4ca89bff9873e5f6a6849fa22a349c94deaae to specify an explicit migration timeline: GHC will no longer support this constraint solving mechanism starting from GHC 9.10. Fixes #22912
* fix: Update documentation linksromes2023-02-212-4/+4
| | | | | | | Closes #23008 Additionally batches some fixes to pointers to the Note [Wired-in units], and a typo in said note.
* GHC proposal 496 - Nullary record wildcardsGeorgi Lyubenov2023-02-2110-69/+213
| | | | | | | | | | | | | | | | | | | This patch implements GHC proposal 496, which allows record wildcards to be used for nullary constructors, e.g. data A = MkA1 | MkA2 { fld1 :: Int } f :: A -> Int f (MkA1 {..}) = 0 f (MkA2 {..}) = fld1 To achieve this, we add arity information to the record field environment, so that we can accept a constructor which has no fields while continuing to reject non-record constructors with more than 1 field. See Note [Nullary constructors and empty record wildcards], as well as the more general overview in Note [Local constructor info in the renamer], both in the newly introduced GHC.Types.ConInfo module. Fixes #22161
* Disallow `tagToEnum#` on `type data` typeswip/T22948Ryan Scott2023-02-205-0/+36
| | | | | We don't want to allow users to conjure up values of a `type data` type using `tagToEnum#`, as these simply don't exist at the value level.
* Treat type data declarations as empty when checking pattern-matching coverageRyan Scott2023-02-202-5/+32
| | | | | | | The data constructors for a `type data` declaration don't exist at the value level, so we don't want GHC to warn users to match on them. Fixes #22964.
* Don't generate datacon wrappers for `type data` declarationsRyan Scott2023-02-203-6/+73
| | | | | | | | | | | | | | | | | | Data constructor wrappers only make sense for _value_-level data constructors, but data constructors for `type data` declarations only exist at the _type_ level. This patch does the following: * The criteria in `GHC.Types.Id.Make.mkDataConRep` for whether a data constructor receives a wrapper now consider whether or not its parent data type was declared with `type data`, omitting a wrapper if this is the case. * Now that `type data` data constructors no longer receive wrappers, there is a spot of code in `refineDefaultAlt` that panics when it encounters a value headed by a `type data` type constructor. I've fixed this with a special case in `refineDefaultAlt` and expanded `Note [Refine DEFAULT case alternatives]` to explain why we do this. Fixes #22948.
* Handle top-level Addr# literals in the bytecode compilerAlexis King2023-02-207-143/+222
| | | | Fixes #22376.
* compiler: fix cost centre profiling breakage in wasm NCG due to incorrect ↵Cheng Shao2023-02-201-2/+1
| | | | | | | | | | | | | | | | | register mapping The wasm NCG used to map CCCS to a wasm global, based on the observation that CCCS is a transient register that's already handled by thread state load/store logic, so it doesn't need to be backed by the rCCCS field in the register table. Unfortunately, this is wrong, since even when Cmm execution hasn't yielded back to the scheduler, the Cmm code may call enterFunCCS, which does use rCCCS. This breaks cost centre profiling in a subtle way, resulting in inaccurate stack traces in some test cases. The fix is simple though: just remove the CCCS mapping.
* Improve GHC.Tc.Gen.App.tcInstFunwip/T22908Simon Peyton Jones2023-02-201-16/+12
| | | | | | | | | | | | | | It wasn't behaving right when inst_final=False, and the function had no type variables f :: Foo => Int Rather a corner case, but we might as well do it right. Fixes #22908 Unexpectedly, three test cases (all using :type in GHCi) got slightly better output as a result: T17403, T14796, T12447
* Expand synonyms in RoughMapsheaf2023-02-161-1/+5
| | | | | | | | | | | We were failing to expand type synonyms in the function GHC.Core.RoughMap.typeToRoughMatchLookupTc, even though the RoughMap infrastructure crucially relies on type synonym expansion to work. This patch adds the missing type-synonym expansion. Fixes #22985
* Narrow the dont-decompose-newtype testSimon Peyton Jones2023-02-164-166/+153
| | | | | | | | | | | | | | | | | | | | | | | | | | Following #22924 this patch narrows the test that stops us decomposing newtypes. The key change is the use of noGivenNewtypeReprEqs in GHC.Tc.Solver.Canonical.canTyConApp. We went to and fro on the solution, as you can see in #22924. The result is carefully documented in Note [Decomoposing newtype equalities] On the way I had revert most of commit 3e827c3f74ef76d90d79ab6c4e71aa954a1a6b90 Author: Richard Eisenberg <rae@cs.brynmawr.edu> Date: Mon Dec 5 10:14:02 2022 -0500 Do newtype unwrapping in the canonicaliser and rewriter See Note [Unwrap newtypes first], which has the details. It turns out that (a) 3e827c3f makes GHC behave worse on some recursive newtypes (see one of the tests on this commit) (b) the finer-grained test (namely noGivenNewtypeReprEqs) renders 3e827c3f unnecessary
* Factor JS Rts generation for h$c{_,0,1,2} into h$c{n} and improve name cachingJosh Meredith2023-02-165-121/+107
|
* JS: disable debugging info for heap objectsSylvain Henry2023-02-161-1/+3
|
* Add -single-threaded flag to force single threaded rtsOleg Grenrus2023-02-151-3/+4
| | | | | This is the small part of implementing https://github.com/ghc-proposals/ghc-proposals/pull/240
* compiler: fix generateCgIPEStub for no-tables-next-to-code buildsCheng Shao2023-02-141-14/+14
| | | | | | | | | generateCgIPEStub already correctly implements the CmmTick finding logic for when tables-next-to-code is on/off, but it used the wrong predicate to decide when to switch between the two. Previously it switches based on whether the codegen is unregisterised, but there do exist registerised builds that disable tables-next-to-code! This patch corrects that problem. Fixes #22896.
* Update outdated references to notesSimon Hengel2023-02-148-19/+19
|
* Introduce warning for loopy superclass solvesheaf2023-02-1411-54/+167
| | | | | | | | | | | | | | | | | Commit aed1974e completely re-engineered the treatment of loopy superclass dictionaries in instance declarations. Unfortunately, it has the potential to break (albeit in a rather minor way) user code. To alleviate migration concerns, this commit re-introduces the old behaviour. Any reliance on this old behaviour triggers a warning, controlled by `-Wloopy-superclass-solve`. The warning text explains that GHC might produce bottoming evidence, and provides a migration strategy. This allows us to provide a graceful migration period, alerting users when they are relying on this unsound behaviour. Fixes #22912 #22891 #20666 #22894 #22905
* Fix some correctness issues around tag inference when targeting the bytecode ↵Andreas Klebinger2023-02-144-27/+74
| | | | | | | | | generator. * Let binders are now always assumed untagged for bytecode. * Imported referenced are now always assumed to be untagged for bytecode. Fixes #22840
* nativeGen/AArch64: Emit Atomic{Read,Write} inlineBen Gamari2023-02-143-2/+37
| | | | | | | | | Previously the AtomicRead and AtomicWrite operations were emitted as out-of-line calls. However, these tend to be very important for performance, especially the RELAXED case (which only exists for ThreadSanitizer checking). Fixes #22115.
* compiler: Use NamedFieldPuns for `ModIface_` and `ModIfaceBackend` `NFData`Zubin Duggal2023-02-101-11/+50
| | | | | | | | | | instances This is a minor refactor that makes it easy to add and remove fields from `ModIface_` and `ModIfaceBackend`. Also change the formatting to make it clear exactly which fields are fully forced with `rnf`
* Detect the `mold` linkerRebecca Turner2023-02-102-0/+6
| | | | Enables support for the `mold` linker by rui314.
* Refactor the simplifier a bit to fix #22761Simon Peyton Jones2023-02-109-183/+269
| | | | | | | | | | | | | | | | | | | | | The core change in this commit, which fixes #22761, is that * In a Core rule, ru_rhs is always occ-analysed. This means adding a couple of calls to occurAnalyseExpr when building a Rule, in * GHC.Core.Rules.mkRule * GHC.Core.Opt.Simplify.Iteration.simplRules But diagosing the bug made me stare carefully at the code of the Simplifier, and I ended up doing some only-loosely-related refactoring. * I think that RULES could be lost because not every code path did addBndrRules * The code around lambdas was very convoluted It's mainly moving deck chairs around, but I like it more now.
* EPA: Comment between module and where should be in header commentsAlan Zimmerman2023-02-081-2/+4
| | | | | | | Do not apply the heuristic to associate a comment with a prior declaration for the first declaration in the file. Closes #22919
* Revert "Don't keep exit join points so much"Matthew Pickering2023-02-086-137/+71
| | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit caced75765472a1a94453f2e5a439dba0d04a265. It seems the patch "Don't keep exit join points so much" is causing wide-spread regressions in the bytestring library benchmarks. If I revert it then the 9.6 numbers are better on average than 9.4. See https://gitlab.haskell.org/ghc/ghc/-/issues/22893#note_479525 ------------------------- Metric Decrease: MultiComponentModules MultiComponentModulesRecomp MultiLayerModules MultiLayerModulesRecomp MultiLayerModulesTH_Make T12150 T13386 T13719 T21839c T3294 parsing001 -------------------------