summaryrefslogtreecommitdiff
path: root/compiler
Commit message (Collapse)AuthorAgeFilesLines
* Fix void-arg-adding mechanism for worker/wrapperSimon Peyton Jones2023-01-114-77/+133
| | | | | | | | | | | | | As #22725 shows, in worker/wrapper we must add the void argument /last/, not first. See GHC.Core.Opt.WorkWrap.Utils Note [Worker/wrapper needs to add void arg last]. That led me to to study GHC.Core.Opt.SpecConstr Note [SpecConstr needs to add void args first] which suggests the opposite! And indeed I think it's the other way round for SpecConstr -- or more precisely the void arg must precede the "extra_bndrs". That led me to some refactoring of GHC.Core.Opt.SpecConstr.calcSpecInfo.
* Parse qualified terms in type signaturesHaskellMouse2023-01-117-9/+80
| | | | | | | | This commit allows qualified terms in type signatures to pass the parser and to be cathced by renamer with more informative error message. Adds a few tests. Fixes #21605
* Refactor the treatment of loopy superclass dictswip/T20666Richard Eisenberg2023-01-1121-690/+989
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch completely re-engineers how we deal with loopy superclass dictionaries in instance declarations. It fixes #20666 and #19690 The highlights are * Recognise that the loopy-superclass business should use precisely the Paterson conditions. This is much much nicer. See Note [Recursive superclasses] in GHC.Tc.TyCl.Instance * With that in mind, define "Paterson-smaller" in Note [Paterson conditions] in GHC.Tc.Validity, and the new data type `PatersonSize` in GHC.Tc.Utils.TcType, along with functions to compute and compare PatsonSizes * Use the new PatersonSize stuff when solving superclass constraints See Note [Solving superclass constraints] in GHC.Tc.TyCl.Instance * In GHC.Tc.Solver.Monad.lookupInInerts, add a missing call to prohibitedSuperClassSolve. This was the original cause of #20666. * Treat (TypeError "stuff") as having PatersonSize zero. See Note [Paterson size for type family applications] in GHC.Tc.Utils.TcType. * Treat the head of a Wanted quantified constraint in the same way as the superclass of an instance decl; this is what fixes #19690. See GHC.Tc.Solver.Canonical Note [Solving a Wanted forall-constraint] (Thanks to Matthew Craven for this insight.) This entailed refactoring the GivenSc constructor of CtOrigin a bit, to say whether it comes from an instance decl or quantified constraint. * Some refactoring way in which redundant constraints are reported; we don't want to complain about the extra, apparently-redundant constraints that we must add to an instance decl because of the loopy-superclass thing. I moved some work from GHC.Tc.Errors to GHC.Tc.Solver. * Add a new section to the user manual to describe the loopy superclass issue and what rules it follows.
* Misc cleanupKrzysztof Gogolewski2023-01-116-28/+15
| | | | | | | | - Remove unused mkWildEvBinder - Use typeTypeOrConstraint - more symmetric and asserts that that the type is Type or Constraint - Fix escape sequences in Python; they raise a deprecation warning with -Wdefault
* Introduce the TypeAbstractions language flagVladislav Zavialov2023-01-112-5/+8
| | | | | | | | | | | | | | | | | | | | | | | | | GHC Proposals #448 "Modern scoped type variables" and #425 "Invisible binders in type declarations" introduce a new language extension flag: TypeAbstractions. Part of the functionality guarded by this flag has already been implemented, namely type abstractions in constructor patterns, but it was guarded by a combination of TypeApplications and ScopedTypeVariables instead of a dedicated language extension flag. This patch does the following: * introduces a new language extension flag TypeAbstractions * requires TypeAbstractions for @a-syntax in constructor patterns instead of TypeApplications and ScopedTypeVariables * creates a User's Guide page for TypeAbstractions and moves the "Type Applications in Patterns" section there To avoid a breaking change, the new flag is implied by ScopedTypeVariables and is retroactively added to GHC2021. Metric Decrease: MultiLayerModulesTH_OneShot
* Added a new warning about compatibility with RequiredTypeArgumentsHaskellMouse2023-01-1111-4/+88
| | | | | | | | | This commit introduces a new warning that indicates code incompatible with future extension: RequiredTypeArguments. Enabling this extension may break some code and the warning will help to make it compatible in advance.
* fix missing haddock pipeJade Lovelace2023-01-111-1/+1
|
* Fix tcPluginRewrite exampleJade Lovelace2023-01-111-1/+1
|
* Revert "NCG(x86): Compile add+shift as lea if possible."Matthew Pickering2023-01-091-36/+0
| | | | | | This reverts commit 20457d775885d6c3df020d204da9a7acfb3c2e5a. See #22666 and #21777
* Fix outdated link to Happy section on sequencesGeorgi Lyubenov2023-01-091-2/+3
|
* Handle shadowing in DmdAnal (#22718)Sebastian Graf2023-01-091-7/+31
| | | | | | | | | | | | | | | | | | | | | | | | | Previously, when we had a shadowing situation like ```hs f x = ... -- demand signature <1L><1L> main = ... \f -> f 1 ... ``` we'd happily use the shadowed demand signature at the call site inside the lambda. Of course, that's wrong and solution is simply to remove the demand signature from the `AnalEnv` when we enter the lambda. This patch does so for all binding constructs Core. In #22718 the issue was caused by LetUp not shadowing away the existing demand signature for the let binder in the let body. The resulting absent error is fickle to reproduce; hence no reproduction test case. #17478 would help. Fixes #22718. It appears that TcPlugin_Rewrite regresses by ~40% on Darwin. It is likely that DmdAnal was exploiting ill-scoped analysis results. Metric increase ['bytes allocated'] (test_env=x86_64-darwin-validate): TcPlugin_Rewrite
* Make FloatIn robust to shadowingSimon Peyton Jones2023-01-071-103/+158
| | | | | | | | | | This MR fixes #22622. See the new Note [Shadowing and name capture] I did a bit of refactoring in sepBindsByDropPoint too. The bug doesn't manifest in HEAD, but it did show up in 9.4, so we should backport this patch to 9.4
* Only store Name in FunRhs rather than Id with knot-tied fieldsMatthew Pickering2023-01-0611-75/+52
| | | | | | | | | | | | | | | | | | | | | | | | | | All the issues here have been caused by #18758. The goal of the ticket is to be able to talk about things like `LTyClDecl GhcTc`. In the case of HsMatchContext, the correct "context" is whatever we want, and in fact storing just a `Name` is sufficient and correct context, even if the rest of the AST is storing typechecker Ids. So this reverts (#20415, !5579) which intended to get closed to #18758 but didn't really and introduced a few subtle bugs. Printing of an error message in #22695 would just hang, because we would attempt to print the `Id` in debug mode to assertain whether it was empty or not. Printing the Name is fine for the error message. Another consequence is that when `-dppr-debug` was enabled the compiler would hang because the debug printing of the Id would try and print fields which were not populated yet. This also led to 32070e6c2e1b4b7c32530a9566fe14543791f9a6 having to add a workaround for the `checkArgs` function which was probably a very similar bug to #22695. Fixes #22695
* Add support for sized literals in the bytecode interpreter.Luite Stegeman2023-01-064-10/+162
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The bytecode interpreter only has branching instructions for word-sized values. These are used for pattern matching. Branching instructions for other types (e.g. Int16# or Word8#) weren't needed, since unoptimized Core or STG never requires branching on types like this. It's now possible for optimized STG to reach the bytecode generator (e.g. fat interface files or certain compiler flag combinations), which requires dealing with various sized literals in branches. This patch improves support for generating bytecode from optimized STG by adding the following new bytecode instructions: TESTLT_I64 TESTEQ_I64 TESTLT_I32 TESTEQ_I32 TESTLT_I16 TESTEQ_I16 TESTLT_I8 TESTEQ_I8 TESTLT_W64 TESTEQ_W64 TESTLT_W32 TESTEQ_W32 TESTLT_W16 TESTEQ_W16 TESTLT_W8 TESTEQ_W8 Fixes #21945
* HsToken in TypeArg (#19623)Vladislav Zavialov2023-01-0514-50/+59
| | | | Updates the haddock submodule.
* EPA: Do not collect comments from end of fileAlan Zimmerman2023-01-051-2/+4
| | | | | | | | In Parser.y semis1 production triggers for the virtual semi at the end of the file. This is detected by it being zero length. In this case, do not extend the span being used to gather comments, so any final comments are allocated at the module level instead.
* Misc cleanupKrzysztof Gogolewski2023-01-0524-85/+53
| | | | | | | | | - Remove unused uniques and hs-boot declarations - Fix types of seq and unsafeCoerce# - Remove FastString/String roundtrip in JS - Use TTG to enforce totality - Remove enumeration in Heap/Inspect; the 'otherwise' clause serves the primitive types well.
* packaging: Build perf builds with -split-sectionswip/various-hadrian-fixesMatthew Pickering2023-01-041-1/+1
| | | | | | | | | | | In 8f71d958 the make build system was made to use split-sections on linux systems but it appears this logic never made it to hadrian. There is the split_sections flavour transformer but this doesn't appear to be used for perf builds on linux. This is disbled on deb9 and windows due to #21670 Closes #21135
* compiler: Add -f[no-]split-sections flagsMatthew Pickering2023-01-041-8/+12
| | | | | | | | Here we add a `-fsplit-sections` flag which may some day replace `-split-sections`. This has the advantage of automatically providing a `-fno-split-sections` flag, which is useful for our packaging because we enable `-split-sections` by default but want to disable it in certain configurations.
* Force the Docs structure to prevent leaks in GHCi with -haddock without ↵wip/force-docsZubin Duggal2023-01-0311-12/+76
| | | | | | | | | | -fwrite-interface Involves adding many new NFData instances. Without forcing Docs, references to the TcGblEnv for each module are retained by the Docs structure. Usually these are forced when the ModIface is serialised but not when we aren't writing the interface.
* Drop support for kind constraints.wip/p547Richard Eisenberg2022-12-2418-426/+114
| | | | | | | | | | | | | | | | | | | | | | | | This implements proposal 547 and closes ticket #22298. See the proposal and ticket for motivation. Compiler perf improves a bit Metrics: compile_time/bytes allocated ------------------------------------- CoOpt_Singletons(normal) -2.4% GOOD T12545(normal) +1.0% T13035(normal) -13.5% GOOD T18478(normal) +0.9% T9872d(normal) -2.2% GOOD geo. mean -0.2% minimum -13.5% maximum +1.0% Metric Decrease: CoOpt_Singletons T13035 T9872d
* Store RdrName rather than OccName in HolesMatthew Pickering2022-12-2413-52/+100
| | | | | | | | | | | | | | | | | In #20472 it was pointed out that you couldn't defer out of scope but the implementation collapsed a RdrName into an OccName to stuff it into a Hole. This leads to the error message for a deferred qualified name dropping the qualification which affects the quality of the error message. This commit adds a bit more structure to a hole, so a hole can replace a RdrName without losing information about what that RdrName was. This is important when printing error messages. I also added a test which checks the Template Haskell deferral of out of scope qualified names works properly. Fixes #22130
* llvmGen: Fix relaxed orderingBen Gamari2022-12-241-1/+1
| | | | | | | Previously I used LLVM's `unordered` ordering for the C11 `relaxed` ordering. However, this is wrong and should rather use the LLVM `monotonic` ordering. Fixes #22640
* compiler: Ensure that GHC toolchain is first in search pathBen Gamari2022-12-241-5/+5
| | | | | | | As noted in #22561, it is important that GHC's toolchain look first for its own headers and libraries to ensure that the system's are not found instead. If this happens things can break in surprising ways (e.g. see #22561).
* add GHC.Utils.Binary.foldGet' and use for Ifacedoyougnu2022-12-232-2/+19
| | | | | | | | | | A minor optimization to remove lazy IO and a lazy accumulator strictify foldGet' IFace.Binary: use strict foldGet' remove superfluous bang
* Fix unifier bug: failing to decompose over-saturated type familySimon Peyton Jones2022-12-221-13/+15
| | | | This simple patch fixes #22647
* Refactor mkRuntimeErrorSimon Peyton Jones2022-12-228-91/+154
| | | | | | | | | This patch fixes #22634. Because we don't have TYPE/CONSTRAINT polymorphism, we need two error functions rather than one. I took the opportunity to rname runtimeError to impossibleError, to line up with mkImpossibleExpr, and avoid confusion with the genuine runtime-error-constructing functions.
* JS: fix support for -outputdir (#22641)Sylvain Henry2022-12-224-62/+56
| | | | | | | The `-outputdir` option wasn't correctly handled with the JS backend because the same code path was used to handle both objects produced by the JS backend and foreign .js files. Now we clearly distinguish the two in the pipeline, fixing the bug.
* EPA: Make EOF position part of AnnsModuleAlan Zimmerman2022-12-224-47/+38
| | | | | Closes #20951 Closes #19697
* base: Bump version to 4.18Ben Gamari2022-12-211-1/+1
| | | | Requires various submodule bumps.
* Fix an assertion check in addToEqualCtListSimon Peyton Jones2022-12-211-9/+17
| | | | | | | The old assertion saw that a constraint ct could rewrite itself (of course it can) and complained (stupid). Fixes #22645
* Fix shadowing lacuna in OccurAnalSimon Peyton Jones2022-12-212-23/+34
| | | | | | | | | | | | Issue #22623 demonstrated another lacuna in the implementation of wrinkle (BS3) in Note [The binder-swap substitution] in the occurrence analyser. I was failing to add TyVar lambda binders using addInScope/addOneInScope and that led to a totally bogus binder-swap transformation. Very easy to fix.
* Abstract over the right free varsSimon Peyton Jones2022-12-213-53/+118
| | | | | | | | | | | | | | | | | Fix #22459, in two ways: (1) Make the Specialiser not create a bogus specialisation if it is presented by strangely polymorphic dictionary. See Note [Weird special case in SpecDict] in GHC.Core.Opt.Specialise (2) Be more careful in abstractFloats See Note [Which type variables to abstract over] in GHC.Core.Opt.Simplify.Utils. So (2) stops creating the excessively polymorphic dictionary in abstractFloats, while (1) stops crashing if some other pass should nevertheless create a weirdly polymorphic dictionary.
* Allow transformers-0.6 in ghc, ghci, ghc-bin and hadrianBodigrim2022-12-211-1/+1
|
* Make GHC.Driver.Main.hscTcRnLookupRdrName to return NonEmptyBodigrim2022-12-203-4/+11
|
* Scrub some partiality in `GHC.Cmm.Info.Build`: `doSRTs` takes a `[(CAFSet, ↵M Farkas-Dyck2022-12-204-9/+23
| | | | CmmDecl)]` but truly wants a `[(CAFSet, CmmStatics)]`.
* compiler: make .wasm the default executable extension on wasm32Cheng Shao2022-12-172-4/+5
| | | | Following convention as in other wasm toolchains. Fixes #22594.
* compiler: add optional tail-call support in wasm NCGCheng Shao2022-12-167-32/+87
| | | | | | | | | When the `-mtail-call` clang flag is passed at configure time, wasm tail-call extension is enabled, and the wasm NCG will emit `return_call`/`return_call_indirect` instructions to take advantage of it and avoid the `StgRun` trampoline overhead. Closes #22461.
* compiler: change fallback function signature to Cmm function signature in ↵Cheng Shao2022-12-161-2/+4
| | | | | | | | | | wasm NCG In the wasm NCG, when handling a `CLabel` of undefined function without knowing its function signature, we used to fallback to `() -> ()` which is accepted by `wasm-ld`. This patch changes it to the signature of Cmm functions, which equally works, but would be required when we emit tail call instructions.
* compiler: add missing export list of GHC.CmmToAsm.Wasm.FromCmmCheng Shao2022-12-161-63/+7
| | | | Also removes some unreachable code here.
* compiler: remove obsolete commented code in wasm NCGCheng Shao2022-12-161-1/+0
| | | | | It was just a temporary hack to workaround a bug in the relooper, that bug has been fixed long before the wasm backend is merged.
* compiler: Use release store in eager blackholingBen Gamari2022-12-161-2/+2
|
* ghc: Fix data race in dump file handlingBen Gamari2022-12-161-12/+21
| | | | | | | Previously the dump filename cache would use a non-atomic update which could potentially result in lost dump contents. Note that this is still a bit racy since the first writer may lag behind a later appending writer.
* checkValidInst: Don't expand synonyms when splitting sigma typesRyan Scott2022-12-151-2/+29
| | | | | | | | | | | | | | | Previously, the `checkValidInst` function (used when checking that an instance declaration is headed by an actual type class, not a type synonym) was using `tcSplitSigmaTy` to split apart the `forall`s and instance context. This is incorrect, however, as `tcSplitSigmaTy` expands type synonyms, which can cause instances headed by quantified constraint type synonyms to be accepted erroneously. This patch introduces `splitInstTyForValidity`, a variant of `tcSplitSigmaTy` specialized for validity checking that does _not_ expand type synonyms, and uses it in `checkValidInst`. Fixes #22570.
* Fix bogus test in LintSimon Peyton Jones2022-12-154-79/+55
| | | | | | | | | | | | The Lint check for branch compatiblity within an axiom, in GHC.Core.Lint.compatible_branches was subtly different to the check made when contructing an axiom, in GHC.Core.FamInstEnv.compatibleBranches. The latter is correct, so I killed the former and am now using the latter. On the way I did some improvements to pretty-printing and documentation.
* compiler: Ensure that MutVar operations have necessary barriersBen Gamari2022-12-151-4/+5
| | | | | | | Here we add acquire and release barriers in readMutVar# and writeMutVar#, which are necessary for soundness. Fixes #22468.
* Package Imports: Get candidate packages also from re-exported modulesMatthew Pickering2022-12-152-3/+15
| | | | | | | | Previously we were just looking at the direct imports to try and work out what a package qualifier could apply to but #22333 pointed out we also needed to look for reexported modules. Fixes #22333
* codeGen: Introduce ThreadSanitizer instrumentationBen Gamari2022-12-157-2/+302
| | | | | | This introduces a new Cmm pass which instruments the program with ThreadSanitizer annotations, allowing full tracking of mutator memory accesses via TSAN.
* cmm/Parser: Atomic load syntaxBen Gamari2022-12-151-3/+23
| | | | | | | Originally I had thought I would just use the `prim` call syntax instead of introducing new syntax for atomic loads. However, it turns out that `prim` call syntax tends to make things quite unreadable. This new syntax seems quite natural.
* cmm/Parser: Add syntax for ordered loads and storesBen Gamari2022-12-153-6/+55
|