summaryrefslogtreecommitdiff
path: root/compiler
Commit message (Collapse)AuthorAgeFilesLines
...
* codeGen: Ensure that static datacon apps are included in SRTsBen Gamari2022-05-171-43/+86
| | | | | | | | | | | | | | | | When generating an SRT for a recursive group, GHC.Cmm.Info.Build.oneSRT filters out recursive references, as described in Note [recursive SRTs]. However, doing so for static functions would be unsound, for the reason described in Note [Invalid optimisation: shortcutting]. However, the same argument applies to static data constructor applications, as we discovered in #20959. Fix this by ensuring that static data constructor applications are included in recursive SRTs. The approach here is not entirely satisfactory, but it is a starting point. Fixes #20959.
* CafAnal: Improve code clarityBen Gamari2022-05-172-100/+131
| | | | | | | | | | Here we implement a few measures to improve the clarity of the CAF analysis implementation. Specifically: * Use CafInfo instead of Bool since the former is more descriptive * Rename CAFLabel to CAFfyLabel, since not all CAFfyLabels are in fact CAFs * Add numerous comments
* Fix bad interaction between withDict and the SpecialiserSimon Peyton Jones2022-05-173-51/+83
| | | | | | | | | | | | This MR fixes a bad bug, where the withDict was inlined too vigorously, which in turn made the type-class Specialiser generate a bogus specialisation, because it saw the same overloaded function applied to two /different/ dictionaries. Solution: inline `withDict` later. See (WD8) of Note [withDict] in GHC.HsToCore.Expr See #21575, which is fixed by this change.
* Adjust flags for pprTraceSimon Peyton Jones2022-05-172-4/+18
| | | | | | | | | | | | | | | | We were using defaultSDocContext for pprTrace, which suppresses lots of useful infomation. This small MR adds GHC.Utils.Outputable.traceSDocContext and uses it for pprTrace and pprTraceUserWarning. traceSDocContext is a global, and hence not influenced by flags, but that seems unavoidable. But I made the sdocPprDebug bit controlled by unsafeHasPprDebug, since we have the latter for exactly this purpose. Fixes #21569
* OverloadedRecordFields: mention parent name in 'ambiguous occurrence' error ↵nineonine2022-05-171-2/+5
| | | | for better disambiguation (#17420)
* driver: Introduce pgmcxxBen Gamari2022-05-174-14/+31
| | | | | | | | | | Here we introduce proper support for compilation of C++ objects. This includes: * logic in `configure` to detect the C++ toolchain and propagating this information into the `settings` file * logic in the driver to use the C++ toolchain when compiling C++ sources
* TcPlugin: access to irreducible givens + fix passed ev_binds_varPavol Vargovcik2022-05-164-12/+19
|
* Misc cleanupKrzysztof Gogolewski2022-05-1618-66/+50
| | | | | | | | - Remove groupWithName (unused) - Use the RuntimeRepType synonym where possible - Replace getUniqueM + mkSysLocalOrCoVar with mkSysLocalOrCoVarM No functional changes.
* Add arity to the INLINE pragmas for pattern synonymsSimon Peyton Jones2022-05-162-34/+77
| | | | | The lack of INLNE arity was exposed by #21531. The fix is simple enough, if a bit clumsy.
* Comments only around HsWrapperSimon Peyton Jones2022-05-132-7/+27
|
* Fix printing of brackets in multiplicities (#20315)jackohughes2022-05-135-10/+16
| | | | | | | | | Change mulArrow to allow for printing of correct application precedence where necessary and update callers of mulArrow to reflect this. As part of this, move mulArrow from GHC/Utils/Outputtable to GHC/Iface/Type. Fixes #20315
* Decouple dynflags in GHC.Core.Opt.Arity (related to #17957)Andre Marianiello2022-05-122-24/+31
| | | | | Metric Decrease: T16875
* Move CmmParserConfig and PDConfig into GHC.Cmm.Parser.ConfigAndre Marianiello2022-05-125-13/+29
|
* Remove Module argument from initCmmParserConfigAndre Marianiello2022-05-122-7/+5
|
* Decouple dynflags in Cmm parser (related to #17957)Andre Marianiello2022-05-125-25/+62
|
* Add a missing guard in GHC.HsToCore.Utils.is_flat_prod_patSimon Peyton Jones2022-05-112-1/+13
| | | | This missing guard gave rise to #21519.
* Specialiser: saturate DFuns correctlySimon Peyton Jones2022-05-111-4/+7
| | | | | | | | | | | Ticket #21489 showed that the saturation mechanism for DFuns (see Note Specialising DFuns) should use both UnspecType and UnspecArg. We weren't doing that; but this MR fixes that problem. No test case because it's hard to tickle, but it showed up in Gergo's work with GHC-as-a-library.
* EPA: do statement with leading semicolon has wrong anchorAlan Zimmerman2022-05-112-3/+16
| | | | | | | | | | | | | The code do; a <- doAsync; b Generated an incorrect Anchor for the statement list that starts after the first semicolon. This commit fixes it. Closes #20256
* Make floating-point abs IEEE 754 compliantARATA Mizuki2022-05-113-42/+2
| | | | | | The old code used by via-C backend didn't handle the sign bit of NaN. See #21043.
* Use the wrapper for an unlifted bindingSimon Peyton Jones2022-05-101-3/+3
| | | | | | | We assumed the wrapper for an unlifted binding is the identity, but as #21516 showed, that is no always true. Solution is simple: use it.
* Check for uninferrable variables in tcInferPatSynDeclSimon Peyton Jones2022-05-104-38/+64
| | | | | | | | | | This fixes #21479 See Note [Unquantified tyvars in a pattern synonym] While doing this, I found that some error messages pointed at the pattern synonym /name/, rather than the /declaration/ so I widened the SrcSpan to encompass the declaration.
* driver: Make -no-keep-o-files -no-keep-hi-files work in --make modeMatthew Pickering2022-05-101-7/+6
| | | | | | | | | | | | It seems like it was just an oversight to use the incorrect DynFlags (global rather than local) when implementing these two options. Using the local flags allows users to request these intermediate files get cleaned up, which works fine in --make mode because 1. Interface files are stored in memory 2. Object files are only cleaned at the end of session (after link) Fixes #21349
* Improve "Glomming" noteGergo ERDI2022-05-101-0/+6
| | | | | | Add a paragraph that clarifies that `occurAnalysePgm` finding out-of-order references, and thus needing to glom, is not a cause for concern when its root cause is rewrite rules.
* STG: only print cost-center if asked toSylvain Henry2022-05-091-1/+1
|
* Tweak GHC.CmmToAsm.CFG.delEdgeSimon Jakobi2022-05-081-4/+1
| | | | mapAdjust is more efficient than mapAlter.
* Change Specialise to use OrdList.Rob2022-05-081-23/+23
| | | | | | | Fixes #21362 Metric Decrease: T16875
* Comments only: Note [AppCtxt]Simon Peyton Jones2022-05-061-2/+36
|
* template-haskell: Fix representation of OPAQUE pragmasMatthew Pickering2022-05-062-8/+22
| | | | | | | | | | There is a mis-match between the TH representation of OPAQUE pragmas and GHC's internal representation due to how OPAQUE pragmas disallow phase annotations. It seemed most in keeping to just fix the wired in name issue by adding a special case to the desugaring of INLINE pragmas rather than making TH/GHC agree with how the representation should look. Fixes #21463
* Allow `let` just before pure/return in ApplicativeDoZiyang Liu2022-05-061-7/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The following is currently rejected: ```haskell -- F is an Applicative but not a Monad x :: F (Int, Int) x = do a <- pure 0 let b = 1 pure (a, b) ``` This has bitten me multiple times. This MR contains a simple fix: only allow a "let only" segment to be merged with the next (and not the previous) segment. As a result, when the last one or more statements before pure/return are `LetStmt`s, there will be one more segment containing only those `LetStmt`s. Note that if the `let` statement mentions a name bound previously, then the program is still rejected, for example ```haskell x = do a <- pure 0 let b = a + 1 pure (a, b) ``` or the example in #18559. To support this would require a more complex approach, but this is IME much less common than the previous case.
* rts: Ensure that XMM registers are preserved on Win64Ben Gamari2022-05-051-3/+3
| | | | | | | | Previously we only preserved the bottom 64-bits of the callee-saved 128-bit XMM registers, in violation of the Win64 calling convention. Fix this. Fixes #21465.
* SpecConstr: Properly create rules for call patterns representing partial ↵Andreas Klebinger2022-05-052-19/+65
| | | | | | | | | | | | | applications The main fix is that in addVoidWorkerArg we now add the argument to the front. This fixes #21448. ------------------------- Metric Decrease: T16875 -------------------------
* Remove two uses of IntMap.sizeSimon Jakobi2022-05-052-2/+2
| | | | | | | | | | | IntMap.size is O(n). The new code should be slightly more efficient. The transformation of GHC.CmmToAsm.CFG.calcFreqs.nodeCount can be described formally as the transformation: (\sum_{0}^{n-1} \sum_{0}^{k-1} i_nk) + n ==> (\sum_{0}^{n-1} 1 + \sum_{0}^{k-1} i_nk)
* Fix several note references, part 2Krzysztof Gogolewski2022-05-0525-46/+38
|
* Ensure Any is not levity-polymorphic in FFIsheaf2022-05-042-13/+20
| | | | | | | | The previous patch forgot to account for a type such as Any @(TYPE (BoxedRep l)) for a quantified levity variable l.
* Improve error reporting in generated codeSimon Peyton Jones2022-05-046-61/+100
| | | | | | Our error reporting in generated code (via desugaring before typechecking) only worked when the generated code was just a simple call. This commit makes it work in nested cases.
* genprimopcode: Replace LaTeX documentation syntax with HaddockAlexis King2022-05-042-240/+235
| | | | | | | | | | | The LaTeX documentation generator does not seem to have been used for quite some time, so the LaTeX-to-Haddock preprocessing step has become a pointless complication that makes documenting the contents of GHC.Prim needlessly difficult. This commit replaces the LaTeX syntax with the Haddock it would have been converted into, anyway, though with an additional distinction: it uses single quotes in places to instruct Haddock to generate hyperlinks to bindings. This improves the quality of the generated output.
* CoreLint - When checking for levity polymorphism look through more ticks.Andreas Klebinger2022-05-044-13/+45
| | | | | | | | | | | For expressions like `(scc<cc_name> primOp#) arg1` we should also look at arg1 to determine if we call primOp# at a fixed runtime rep. This is what corePrep already does but CoreLint didn't yet. This patch will bring them in sync in this regard. It also uses tickishFloatable in CorePrep instead of CorePrep having it's own slightly differing definition of when a tick is floatable.
* Assume at least one evaluation for nested SubDemands (#21081, #21133)wip/T21081Sebastian Graf2022-05-038-157/+393
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | See the new `Note [SubDemand denotes at least one evaluation]`. A demand `n :* sd` on a let binder `x=e` now means > "`x` was evaluated `n` times and in any program trace it is evaluated, `e` is > evaluated deeply in sub-demand `sd`." The "any time it is evaluated" premise is what this patch adds. As a result, we get better nested strictness. For example (T21081) ```hs f :: (Bool, Bool) -> (Bool, Bool) f pr = (case pr of (a,b) -> a /= b, True) -- before: <MP(L,L)> -- after: <MP(SL,SL)> g :: Int -> (Bool, Bool) g x = let y = let z = odd x in (z,z) in f y ``` The change in demand signature "before" to "after" allows us to case-bind `z` here. Similarly good things happen for the `sd` in call sub-demands `Cn(sd)`, which allows for more eta-reduction (which is only sound with `-fno-pedantic-bottoms`, albeit). We also fix #21085, a surprising inconsistency with `Poly` to `Call` sub-demand expansion. In an attempt to fix a regression caused by less inlining due to eta-reduction in T15426, I eta-expanded the definition of `elemIndex` and `elemIndices`, thus fixing #21345 on the go. The main point of this patch is that it fixes #21081 and #21133. Annoyingly, I discovered that more precise demand signatures for join points can transform a program into a lazier program if that join point gets floated to the top-level, see #21392. There is no simple fix at the moment, but !5349 might. Thus, we accept a ~5% regression in `MultiLayerModulesTH_OneShot`, where #21392 bites us in `addListToUniqDSet`. T21392 reliably reproduces the issue. Surprisingly, ghc/alloc perf on Windows improves much more than on other jobs, by 0.4% in the geometric mean and by 2% in T16875. Metric Increase: MultiLayerModulesTH_OneShot Metric Decrease: T16875
* Fix several note referencesKrzysztof Gogolewski2022-05-0224-44/+40
|
* Remove obsolete code in CoreToStgKrzysztof Gogolewski2022-05-021-10/+0
| | | | | Note [Nullary unboxed tuple] was removed in e9e61f18a548b70693f4. This codepath is tested by T15696_3.
* exprIsDeadEnd: Use isDeadEndAppSig to check if a function appliction is ↵Andreas Klebinger2022-05-013-7/+7
| | | | | | | | | | | | bottoming. We used to check the divergence and that the number of arguments > arity. But arity zero represents unknown arity so this was subtly broken for a long time! We would check if the saturated function diverges, and if we applied >=arity arguments. But for unknown arity functions any number of arguments is >=idArity. This fixes #21440.
* Add documentation to the ByteArray# primetype.Hécate Moonlight2022-05-011-5/+44
| | | | close #21417
* StgLint: Check that functions are applied to compatible runtime repsAndreas Klebinger2022-05-014-24/+179
| | | | | We use compatibleRep to compare reps, and avoid checking functions with levity polymorphic types because of #21399.
* Revert "Make the specialiser handle polymorphic specialisation"Matthew Pickering2022-04-301-171/+40
| | | | | | | | | | | | | This reverts commit ef0135934fe32da5b5bb730dbce74262e23e72e8. See ticket #21229 ------------------------- Metric Decrease: T15164 Metric Increase: T13056 -------------------------
* Convert More Diagnostics (#20116)Ben Gamari2022-04-308-174/+490
| | | | | Replaces uses of `TcRnUnknownMessage` with proper diagnostics constructors.
* Make mkFunCo take AnonArgFlags into accountRyan Scott2022-04-301-2/+3
| | | | | | | | | | | | | | | | | | | | | | Previously, whenever `mkFunCo` would produce reflexive coercions, it would use `mkVisFunTy` to produce the kind of the coercion. However, `mkFunCo` is also used to produce coercions between types of the form `ty1 => ty2` in certain places. This has the unfortunate side effect of causing the type of the coercion to appear as `ty1 -> ty2` in certain error messages, as spotted in #21328. This patch address this by changing replacing the use of `mkVisFunTy` with `mkFunctionType` in `mkFunCo`. `mkFunctionType` checks the kind of `ty1` and makes the function arrow `=>` instead of `->` if `ty1` has kind `Constraint`, so this should always produce the correct `AnonArgFlag`. As a result, this patch fixes part (2) of #21328. This is not the only possible way to fix #21328, as the discussion on that issue lists some possible alternatives. Ultimately, it was concluded that the alternatives would be difficult to maintain, and since we already use `mkFunctionType` in `coercionLKind` and `coercionRKind`, using `mkFunctionType` in `mkFunCo` is consistent with this choice. Moreover, using `mkFunctionType` does not regress the performance of any test case we have in GHC's test suite.
* Provide efficient unionMG function for combining two module graphs.Matthew Pickering2022-04-291-4/+25
| | | | | | This function is used by API clients (hls). This supercedes !6922
* winio: add support to iserv.Tamar Christina2022-04-281-1/+29
|
* Add INLINE pragmas for Enum helper methodsSimon Peyton Jones2022-04-281-1/+59
| | | | | | | | | | | | | | | | | | | | | | | As #21343 showed, we need to be super-certain that the "helper methods" for Enum instances are actually inlined or specialised. I also tripped over this when I discovered that numericEnumFromTo and friends had no pragmas at all, so their performance was very fragile. If they weren't inlined, all bets were off. So I've added INLINE pragmas for them too. See new Note [Inline Enum method helpers] in GHC.Enum. I also expanded Note [Checking for INLINE loop breakers] in GHC.Core.Lint to explain why an INLINE function might temporarily be a loop breaker -- this was the initial bug report in #21343. Strangely we get a 16% runtime allocation decrease in perf/should_run/T15185, but only on i386. Since it moves in the right direction I'm disinclined to investigate, so I'll accept it. Metric Decrease: T15185
* Fix unification of ConcreteTvs, removing IsRefl#sheaf2022-04-2837-934/+1474
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch fixes the unification of concrete type variables. The subtlety was that unifying concrete metavariables is more subtle than other metavariables, as decomposition is possible. See the Note [Unifying concrete metavariables], which explains how we unify a concrete type variable with a type 'ty' by concretising 'ty', using the function 'GHC.Tc.Utils.Concrete.concretise'. This can be used to perform an eager syntactic check for concreteness, allowing us to remove the IsRefl# special predicate. Instead of emitting two constraints `rr ~# concrete_tv` and `IsRefl# rr concrete_tv`, we instead concretise 'rr'. If this succeeds we can fill 'concrete_tv', and otherwise we directly emit an error message to the typechecker environment instead of deferring. We still need the error message to be passed on (instead of directly thrown), as we might benefit from further unification in which case we will need to zonk the stored types. To achieve this, we change the 'wc_holes' field of 'WantedConstraints' to 'wc_errors', which stores general delayed errors. For the moement, a delayed error is either a hole, or a syntactic equality error. hasFixedRuntimeRep_MustBeRefl is now hasFixedRuntimeRep_syntactic, and hasFixedRuntimeRep has been refactored to directly return the most useful coercion for PHASE 2 of FixedRuntimeRep. This patch also adds a field ir_frr to the InferResult datatype, holding a value of type Maybe FRROrigin. When this value is not Nothing, this means that we must fill the ir_ref field with a type which has a fixed RuntimeRep. When it comes time to fill such an ExpType, we ensure that the type has a fixed RuntimeRep by performing a representation-polymorphism check with the given FRROrigin This is similar to what we already do to ensure we fill an Infer ExpType with a type of the correct TcLevel. This allows us to properly perform representation-polymorphism checks on 'Infer' 'ExpTypes'. The fillInferResult function had to be moved to GHC.Tc.Utils.Unify to avoid a cyclic import now that it calls hasFixedRuntimeRep. This patch also changes the code in matchExpectedFunTys to make use of the coercions, which is now possible thanks to the previous change. This implements PHASE 2 of FixedRuntimeRep in some situations. For example, the test cases T13105 and T17536b are now both accepted. Fixes #21239 and #21325 ------------------------- Metric Decrease: T18223 T5631 -------------------------