summaryrefslogtreecommitdiff
path: root/compiler/GHC
Commit message (Collapse)AuthorAgeFilesLines
* Loader: Implement gnu-style -l:$path syntaxGHC GitLab CI2022-05-231-11/+31
| | | | | | Gnu ld allows `-l` to be passed an absolute file path, signalled by a `:` prefix. Implement this in the GHC's loader search logic.
* Enable eventlog support in all ways by defaultBen Gamari2022-05-184-29/+8
| | | | | | | | | | | | | | | | | | | Here we deprecate the eventlogging RTS ways and instead enable eventlog support in the remaining ways. This simplifies packaging and reduces GHC compilation times (as we can eliminate two whole compilations of the RTS) while simplifying the end-user story. The trade-off is a small increase in binary sizes in the case that the user does not want eventlogging support, but we think that this is a fine trade-off. This also revealed a latent RTS bug: some files which included `Cmm.h` also assumed that it defined various macros which were in fact defined by `Config.h`, which `Cmm.h` did not include. Fixing this in turn revealed that `StgMiscClosures.cmm` failed to import various spinlock statistics counters, as evidenced by the failed unregisterised build. Closes #18948. (cherry picked from commit ee11d04363ed8aa1d73a0cda16076a39e668d163)
* Basic response file supportBen Gamari2022-05-182-40/+93
| | | | | | | | | | Here we introduce support into our command-line parsing infrastructure and driver for handling gnu-style response file arguments, typically used to work around platform command-line length limitations. Fixes #16476. (cherry picked from commit ba3d4e1c43e6772f11f9a7105ef4bf3be8efb2df)
* driver: Introduce pgmcxxBen Gamari2022-05-184-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 (cherry picked from commit fb579e15c56994bc6c4cc266535024f20a81f830)
* hadrian: Clean up handling of libffi dependenciesBen Gamari2022-05-181-0/+9
| | | | (cherry picked from commit c556cbf3144f2c209cb41b4524f36247de974d41)
* Revert "Make the specialiser handle polymorphic specialisation"Matthew Pickering2022-05-151-164/+40
| | | | | | | | | | | | | | | This reverts commit ef0135934fe32da5b5bb730dbce74262e23e72e8. See ticket #21229 ------------------------- Metric Decrease: T15164 Metric Increase: T13056 ------------------------- (cherry picked from commit a8b47caddb41a970e9ac4c358127523daa1ff101)
* Add arity to the INLINE pragmas for pattern synonymsSimon Peyton Jones2022-05-152-34/+77
| | | | | | | The lack of INLNE arity was exposed by #21531. The fix is simple enough, if a bit clumsy. (cherry picked from commit cebf31ff2af7647805d05ffa99cb99a7761f3831)
* runTcPluginSolvers: call getTcEvBindsVar only once - before loopsheaf2022-05-131-4/+4
|
* fix: pass global ev_binds_var to tcplugin solverPavol Vargovcik2022-05-133-7/+8
|
* TcPlugin can read and resolve irreducible givensPavol Vargovcik2022-05-131-2/+8
|
* Provide efficient unionMG function for combining two module graphs.Matthew Pickering2022-04-281-4/+25
| | | | | | | | This function is used by API clients (hls). This supercedes !6922 (cherry picked from commit 4443573b986014cb45c8e39f5867e6fc187a81db)
* Fix unification of ConcreteTvs, removing IsRefl#sheaf2022-04-2737-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 ------------------------- (cherry picked from commit 47ccaa0d17e8150ef09770e3b774e43ee63d3983)
* Relax "suppressing errors" assert in reportWantedssheaf2022-04-271-4/+9
| | | | | | | | | | | | | The assertion in reportWanteds that we aren't suppressing all the Wanted constraints was too strong: it might be the case that we are inside an implication, and have already reported an unsolved Wanted from outside the implication. It is possible that all Wanteds inside the implication have been rewritten by the outer Wanted, so we shouldn't throw an assertion failure in that case. Fixes #21405 (cherry picked from commit 93c16b94ebff03c81c2285eb2b622dc62f9bca16)
* decideMonoTyVars: account for CoVars in candidatessheaf2022-04-272-3/+5
| | | | | | | | | | | | | | The "candidates" passed to decideMonoTyVars can contain coercion holes. This is because we might well decide to quantify over some unsolved equality constraints, as long as they are not definitely insoluble. In that situation, decideMonoTyVars was passing a set of type variables that was not closed over kinds to closeWrtFunDeps, which was tripping up an assertion failure. Fixes #21404 (cherry picked from commit 1e4dcf230a50b00350e084ca43e9d098ff865b22)
* Ensure that wired-in exception closures aren't GC'dBen Gamari2022-04-251-40/+79
| | | | | | | | | | | | | | | | | As described in Note [Wired-in exceptions are not CAFfy], a small set of built-in exception closures get special treatment in the code generator, being declared as non-CAFfy despite potentially containing CAF references. The original intent of this treatment for the RTS to then add StablePtrs for each of the closures, ensuring that they are not GC'd. However, this logic was not applied consistently and eventually removed entirely in 951c1fb0. This lead to #21141. Here we fix this bug by reintroducing the StablePtrs and document the status quo. Closes #21141. (cherry picked from commit e8e0955f7f330dbad5da8d669a4c24fc2953b0bd)
* Fix a shadowing issue in StgUnarise.Andreas Klebinger2022-04-251-1/+23
| | | | | | | | | | | | | | | | | | | For I assume performance reasons we don't record no-op replacements during unarise. This lead to problems with code like this: f = \(Eta_B0 :: VoidType) x1 x2 -> ... let foo = \(Eta_B0 :: LiftedType) -> g x y Eta_B0 in ... Here we would record the outer Eta_B0 as void rep, but would not shadow Eta_B0 inside `foo` because this arg is single-rep and so doesn't need to replaced. But this means when looking at occurence sites we would check the env and assume it's void rep based on the entry we made for the (no longer in scope) outer `Eta_B0`. Fixes #21396 and the ticket has a few more details. (cherry picked from commit 77b51d1ed4555359759c81b7b60c19ff8bc2c5e2)
* Fix missing SymCo in pushCoercionIntoLambdasheaf2022-04-131-1/+5
| | | | | | | | | There was a missing SymCo in pushCoercionIntoLambda. Currently this codepath is only used with rewrite rules, so this bug managed to slip by, but trying to use pushCoercionIntoLambda in other contexts revealed the bug. (cherry picked from commit 5f8d6e65f3d8268c70d6a8434ba9df03087a22eb)
* Revert "Rename [] to List (#21294)"GHC GitLab CI2022-04-138-61/+23
| | | | This reverts commit 02279a9c37deb34556834f706dbedc09258df753.
* Revert "HsUniToken for :: in GADT constructors (#19623)"GHC GitLab CI2022-04-135-10/+6
| | | | This reverts commit 3415981c36631115bc1d7fb5b51abfcc2932a12f.
* Tiny documentation wibbleSimon Peyton Jones2022-04-081-2/+2
| | | | | | | | | | | | This commit commit 83363c8b04837ee871a304cf85207cf79b299fb0 Author: Simon Peyton Jones <simon.peytonjones@gmail.com> Date: Fri Mar 11 16:55:38 2022 +0000 Use prepareBinding in tryCastWorkerWrapper refactored completeNonRecX away, but left a Note referring to it. This MR fixes that Note.
* Disallow (->) as a data constructor name (#16999)Vladislav Zavialov2022-04-081-3/+2
| | | | | | | | | | | | | | The code was misusing isLexCon, which was never meant for validation. In fact, its documentation states the following: Use these functions to figure what kind of name a 'FastString' represents; these functions do /not/ check that the identifier is valid. Ha! This sign can't stop me because I can't read. The fix is to use okConOcc instead. The other checks (isTcOcc or isDataOcc) seem superfluous, so I also removed those.
* Docs: datacon eta-expansion, rep-poly checkssheaf2022-04-085-37/+91
| | | | | | | | | | | | | | | | | | | The existing notes weren't very clear on how the eta-expansion of data constructors that occurs in tcInferDataCon/dsConLike interacts with the representation polymorphism invariants. So we explain with a few more details how we ensure that the representation-polymorphic lambdas introduced by tcInferDataCon/dsConLike don't end up causing problems, by checking they are properly instantiated and then relying on the simple optimiser to perform beta reduction. A few additional changes: - ConLikeTc just take type variables instead of binders, as we never actually used the binders. - Removed the FRRApp constructor of FRROrigin; it was no longer used now that we use ExpectedFunTyOrigin. - Adds a bit of documentation to the constructors of ExpectedFunTyOrigin.
* HsUniToken for :: in GADT constructors (#19623)Vladislav Zavialov2022-04-085-6/+10
| | | | | | One more step towards the new design of EPA. Updates the haddock submodule.
* Add flag -fprof-manual which controls if GHC should honour manual cost centres.Andreas Klebinger2022-04-083-1/+4
| | | | | | | This allows disabling of manual control centres in code a user doesn't control like libraries. Fixes #18867
* driver: Introduce HomeModInfoCache abstractionMatthew Pickering2022-04-082-20/+109
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The HomeModInfoCache is a mutable cache which is updated incrementally as the driver completes, this makes it robust to exceptions including (SIGINT) The interface for the cache is described by the `HomeMOdInfoCache` data type: ``` data HomeModInfoCache = HomeModInfoCache { hmi_clearCache :: IO [HomeModInfo] , hmi_addToCache :: HomeModInfo -> IO () } ``` The first operation clears the cache and returns its contents. This is designed so it's harder to end up in situations where the cache is retained throughout the execution of upsweep. The second operation allows a module to be added to the cache. The one slightly nasty part is in `interpretBuildPlan` where we have to be careful to ensure that the cache writes happen: 1. In parralel 2. Before the executation continues after upsweep. This requires some simple, localised MVar wrangling. Fixes #20780
* Merge remote-tracking branch 'origin/master'Ben Gamari2022-04-0821-259/+355
|\
| * Reject illegal quote mark in data con declarations (#17865)Vladislav Zavialov2022-04-083-2/+20
| | | | | | | | | | | | * Non-fatal (i.e. recoverable) parse error * Checking infix constructors * Extended the regression test
| * Correctly report SrcLoc of redundant constraintssheaf2022-04-083-9/+21
| | | | | | | | | | | | | | | | | | We were accidentally dropping the source location information in certain circumstances when reporting redundant constraints. This patch makes sure that we set the TcLclEnv correctly before reporting the warning. Fixes #21315
| * Improve seq[D]VarSetSimon Jakobi2022-04-081-2/+2
| | | | | | | | | | | | Previously, the use of size[D]VarSet would involve a traversal of the entire underlying IntMap. Since IntMaps are already spine-strict, this is unnecessary.
| * Fix the free-var test in validDerivPredSimon Peyton Jones2022-04-071-57/+42
| | | | | | | | | | | | | | | | | | | | The free-var test (now documented as (VD3)) was too narrow, affecting only class predicates. #21302 demonstrated that this wasn't enough! Fixes #21302. Co-authored-by: Ryan Scott <ryan.gl.scott@gmail.com>
| * Rename [] to List (#21294)Vladislav Zavialov2022-04-078-23/+61
| | | | | | | | | | | | | | | | | | | | | | | | | | This patch implements a small part of GHC Proposal #475. The key change is in GHC.Types: - data [] a = [] | a : [a] + data List a = [] | a : List a And the rest of the patch makes sure that List is pretty-printed as [] in various contexts. Updates the haddock submodule.
| * Use prepareBinding in tryCastWorkerWrapperSimon Peyton Jones2022-04-074-164/+206
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As #21144 showed, tryCastWorkerWrapper was calling prepareRhs, and then unconditionally floating the bindings, without the checks of doFloatFromRhs. That led to floating an unlifted binding into a Rec group. This patch refactors prepareBinding to make these checks, and do them uniformly across all calls. A nice improvement. Other changes * Instead of passing around a RecFlag and a TopLevelFlag; and sometimes a (Maybe SimplCont) for join points, define a new Simplifier-specific data type BindContext: data BindContext = BC_Let TopLevelFlag RecFlag | BC_Join SimplCont and use it consistently. * Kill off completeNonRecX by inlining it. It was only called in one place. * Add a wrapper simplImpRules for simplRules. Compile time on T9630 drops by 4.7%; little else changes. Metric Decrease: T9630
| * EPA: handling of con_bndrs in mkGadtDeclAlan Zimmerman2022-04-071-2/+1
| | | | | | | | | | | | Get rid of unnnecessary case clause that always matched. Closes #20558
| * Remove Fun pattern from Typeable COMPLETE setsheaf2022-04-071-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | GHC merge request !963 improved warnings in the presence of COMPLETE annotations. This allows the removal of the Fun pattern from the complete set. Doing so expectedly causes some redundant pattern match warnings, in particular in GHC.Utils.Binary.Typeable and Data.Binary.Class from the binary library; this commit addresses that. Updates binary submodule Fixes #20230
| |
| \
*-. \ Merge branches 'wip/windows-high-codegen', 'wip/windows-high-linker', ↵Ben Gamari2022-04-073-45/+8
|\ \ \ | | |/ | |/| | | | 'wip/windows-clang-2' and 'wip/lint-rts-includes' into wip/windows-clang-join
| | * Drop -static-libgccBen Gamari2022-04-061-28/+2
| | | | | | | | | | | | This flag is not applicable when Clang is used.
| | * Windows/Clang: Build system adaptationBen Gamari2022-04-061-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Bump win32-tarballs to 0.7 * Move Windows toolchain autoconf logic into separate file * Use clang and LLVM utilities as described in #21019 * Disable object merging as lld doesn't support -r * Drop --oformat=pe-bigobj-x86-64 arguments from ld flags as LLD detects that the output is large on its own. * Drop gcc wrapper since Clang finds its root fine on its own.
| | * driver: Drop hacks surrounding windres invocationBen Gamari2022-04-061-16/+2
| |/ | | | | | | | | Drop hack for #1828, among others as they appear to be unnecessary when using `llvm-windres`.
* | nativeGen: Note signed-extended nature of MOVwip/windows-high-codegenBen Gamari2022-04-061-0/+4
| |
* | Don't assume that labels are 32-bit on WindowsBen Gamari2022-04-061-10/+17
| |
* | Refactor is32BitLit to take Platform rather than BoolBen Gamari2022-04-061-37/+33
| |
* | Generate LEA for label expressionsBen Gamari2022-04-061-0/+16
| |
* | nativeGen/x86: Use %rip-relative addressingBen Gamari2022-04-061-8/+49
|/ | | | | | | On Windows with high-entropy ASLR we must use %rip-relative addressing to avoid overflowing the signed 32-bit immediate size of x86-64. Since %rip-relative addressing comes essentially for free and can make linking significantly easier, we use it on all platforms.
* Refactor OutputableBndrFlag instancesVladislav Zavialov2022-04-061-36/+7
| | | | | The matching on GhcPass introduced by 95275a5f25a is not necessary. This patch reverts it to make the code simpler.
* gitlab-ci: Bump bootstrap compiler to 9.2.2Ben Gamari2022-04-061-1/+1
| | | | | | This is necessary to build recent `text` commits. Bumps Hackage index state for a hashable which builds with GHC 9.2.
* Fix a few new warnings when booting with GHC 9.2.2Ben Gamari2022-04-061-3/+8
| | | | | -Wuni-incomplete-patterns and apparent improvements in the pattern match checker surfaced these.
* Add warnings for file header pragmas that appear in the body of a module ↵Zubin Duggal2022-04-0611-21/+73
| | | | | | | | | | | | | | | (#20385) Once we are done parsing the header of a module to obtain the options, we look through the rest of the tokens in order to determine if they contain any misplaced file header pragmas that would usually be ignored, potentially resulting in bad error messages. The warnings are reported immediately so that later errors don't shadow over potentially helpful warnings. Metric Increase: T13719
* Build ar archives with -L when "joining" objectsBen Gamari2022-04-063-1/+9
| | | | Since there may be .o files which are in fact archives.
* Add a Note describing lack of object merging on WindowsBen Gamari2022-04-063-8/+37
| | | | See #21068.
* driver: Make object merging optionalBen Gamari2022-04-065-7/+18
| | | | | | | On Windows we don't have a linker which supports object joining (i.e. the `-r` flag). Consequently, `-pgmlm` is now a `Maybe`. See #21068.