summaryrefslogtreecommitdiff
path: root/compiler
Commit message (Collapse)AuthorAgeFilesLines
* Add Haddocks for `WwOpts`John Ericson2022-05-261-5/+8
|
* Desugar RecordUpd in `tcExpr`wip/T18802CarrieMY2022-05-2515-724/+657
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch typechecks record updates by desugaring them inside the typechecker using the HsExpansion mechanism, and then typechecking this desugared result. Example: data T p q = T1 { x :: Int, y :: Bool, z :: Char } | T2 { v :: Char } | T3 { x :: Int } | T4 { p :: Float, y :: Bool, x :: Int } | T5 The record update `e { x=e1, y=e2 }` desugars as follows e { x=e1, y=e2 } ===> let { x' = e1; y' = e2 } in case e of T1 _ _ z -> T1 x' y' z T4 p _ _ -> T4 p y' x' The desugared expression is put into an HsExpansion, and we typecheck that. The full details are given in Note [Record Updates] in GHC.Tc.Gen.Expr. Fixes #2595 #3632 #10808 #10856 #16501 #18311 #18802 #21158 #21289 Updates haddock submodule
* SimpleOpt: beta-reduce through castssheaf2022-05-251-21/+80
| | | | | | | | | | | | The simple optimiser would sometimes fail to beta-reduce a lambda when there were casts in between the lambda and its arguments. This can cause problems because we rely on representation-polymorphic lambdas getting beta-reduced away (for example, those that arise from newtype constructors with representation-polymorphic arguments, with UnliftedNewtypes).
* Remove HscEnv from GHC.HsToCore.Usage (related to #17957)Andre Marianiello2022-05-255-21/+54
| | | | | Metric Decrease: T16875
* Fix compilation with -haddock on GHC <= 8.10Zubin Duggal2022-05-241-2/+2
| | | | | | | | | | | -haddock on GHC < 9.0 is quite fragile and can result in obtuse parse errors when it encounters invalid haddock syntax. This has started to affect users since 297156e0b8053a28a860e7a18e1816207a59547b enabled -haddock by default on many flavours. Furthermore, since we don't test bootstrapping with 8.10 on CI, this problem managed to slip throught the cracks.
* Fix #21563 by using Word64 for 64bit shift code.Andreas Klebinger2022-05-241-3/+4
| | | | | | We use the 64bit shifts only on 64bit platforms. But we compile the code always so compiling it on 32bit caused a lint error. So use Word64 instead.
* Use UnionListsOrd instead of UnionLists in most places.Andreas Klebinger2022-05-243-9/+25
| | | | This should get rid of most, if not all "Overlong lists" errors and fix #20016
* EPA: Comment Order ReversedAlan Zimmerman2022-05-232-15/+11
| | | | | | | Make sure comments captured in the exact print annotations are in order of increasing location Closes #20718
* EPA : Remove duplicate comments in DataFamInstDAlan Zimmerman2022-05-234-9/+23
| | | | | | | | | | | | | | | | The code data instance Method PGMigration = MigrationQuery Query -- ^ Run a query against the database | MigrationCode (Connection -> IO (Either String ())) -- ^ Run any arbitrary IO code Resulted in two instances of the "-- ^ Run a query against the database" comment appearing in the Exact Print Annotations when it was parsed. Ensure only one is kept. Closes #20239
* Make debug a `Bool` not an `Int` in `StgToCmmConfig`John Ericson2022-05-233-6/+6
| | | | | | | We don't need any more resolution than this. Rename the field to `stgToCmmEmitDebugInfo` to indicate it is no longer conveying any "level" information.
* Improve FloatOut and SpecConstrwip/T21386Simon Peyton Jones2022-05-233-41/+75
| | | | | | | | | | | | | | | | | | | | | | | This patch addresses a relatively obscure situation that arose when chasing perf regressions in !7847, which itself is fixing It does two things: * SpecConstr can specialise on ($df d1 d2) dictionary arguments * FloatOut no longer checks argument strictness See Note [Specialising on dictionaries] in GHC.Core.Opt.SpecConstr. A test case is difficult to construct, but it makes a big difference in nofib/real/eff/VSM, at least when we have the patch for #21286 installed. (The latter stops worker/wrapper for dictionary arguments). There is a spectacular, but slightly illusory, improvement in runtime perf on T15426. I have documented the specifics in T15426 itself. Metric Decrease: T15426
* Modularize GHC.Core.Opt.LiberateCasewip/cmm-dominatorsDominik Peteler2022-05-224-16/+51
| | | | Progress towards #17957
* Consider the stage of typeable evidence when checking stage restrictionMatthew Pickering2022-05-223-21/+100
| | | | | | | | | | | | | | We were considering all Typeable evidence to be "BuiltinInstance"s which meant the stage restriction was going unchecked. In-fact, typeable has evidence and so we need to apply the stage restriction. This is complicated by the fact we don't generate typeable evidence and the corresponding DFunIds until after typechecking is concluded so we introcue a new `InstanceWhat` constructor, BuiltinTypeableInstance which records whether the evidence is going to be local or not. Fixes #21547
* Change `Backend` type and remove direct dependencieswip/backend-as-recordNorman Ramsey2022-05-2132-339/+1166
| | | | | | | | | | | | | | | | | | | With this change, `Backend` becomes an abstract type (there are no more exposed value constructors). Decisions that were formerly made by asking "is the current back end equal to (or different from) this named value constructor?" are now made by interrogating the back end about its properties, which are functions exported by `GHC.Driver.Backend`. There is a description of how to migrate code using `Backend` in the user guide. Clients using the GHC API can find a backdoor to access the Backend datatype in GHC.Driver.Backend.Internal. Bumps haddock submodule. Fixes #20927
* Remove pprTrace from pushCoercionIntoLambda (#21555)Matthew Pickering2022-05-201-1/+2
| | | | | | | | | | | | | This firstly caused spurious output to be emitted (as evidenced by #21555) but even worse caused a massive coercion to be attempted to be printed (> 200k terms) which would invariably eats up all the memory of your computer. The good news is that removing this trace allows the program to compile to completion, the bad news is that the program exhibits a core lint error (on 9.0.2) but not any other releases it seems. Fixes #21577 and #21555
* document fields of `DominatorSet`Andreas Klebinger2022-05-201-2/+2
|
* add HasDebugCallStack; remove unneeded extensionsNorman Ramsey2022-05-201-16/+19
|
* add dominator-tree functionNorman Ramsey2022-05-201-0/+12
|
* add dominator analysis of `CmmGraph`Norman Ramsey2022-05-202-0/+201
| | | | | | | | | | | | This commit adds module `GHC.Cmm.Dominators`, which provides a wrapper around two existing algorithms in GHC: the Lengauer-Tarjan dominator analysis from the X86 back end and the reverse postorder ordering from the Cmm Dataflow framework. Issue #20726 proposes that we evaluate some alternatives for dominator analysis, but for the time being, the best path forward is simply to use the existing analysis on `CmmGraph`s. This commit addresses a bullet in #21200.
* Don't store LlvmConfig into DynFlagsSylvain Henry2022-05-1716-228/+281
| | | | | | | | | | | | | | | | | | | | | LlvmConfig contains information read from llvm-passes and llvm-targets files in GHC's top directory. Reading these files is done only when needed (i.e. when the LLVM backend is used) and cached for the whole compiler session. This patch changes the way this is done: - Split LlvmConfig into LlvmConfig and LlvmConfigCache - Store LlvmConfigCache in HscEnv instead of DynFlags: there is no good reason to store it in DynFlags. As it is fixed per session, we store it in the session state instead (HscEnv). - Initializing LlvmConfigCache required some changes to driver functions such as newHscEnv. I've used the opportunity to untangle initHscEnv from initGhcMonad (in top-level GHC module) and to move it to GHC.Driver.Main, close to newHscEnv. - I've also made `cmmPipeline` independent of HscEnv in order to remove the call to newHscEnv in regalloc_unit_tests.
* 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.