Skip to content
Snippets Groups Projects
  1. Nov 03, 2020
    • Sylvain Henry's avatar
      Bignum: make GMP's bignat_add not recursive · bff74de7
      Sylvain Henry authored and Marge Bot's avatar Marge Bot committed
      bignat_add was a loopbreaker with an INLINE pragma (spotted by
      @mpickering). This patch makes it non recursive to avoid the issue.
      bff74de7
    • Sylvain Henry's avatar
      Constant-folding: don't pass through GHC's Int/Word (fix #11704) · 37f0434d
      Sylvain Henry authored and Marge Bot's avatar Marge Bot committed
      Constant-folding rules for integerToWord/integerToInt were performing
      the following coercions at compilation time:
      
          integerToWord: target's Integer -> ghc's Word -> target's Word
          integerToInt : target's Integer -> ghc's Int -> target's Int
      
      1) It was wrong for cross-compilers when GHC's word size is smaller than
         the target one. This patch avoids passing through GHC's word-sized
         types:
      
          integerToWord: target's Integer -> ghc's Integer -> target's Word
          integerToInt : target's Integer -> ghc's Integer -> target's Int
      
      2) Additionally we didn't wrap the target word/int literal to make it
         fit into the target's range! This broke the invariant of literals
         only containing values in range.
      
         The existing code is wrong only with a 64-bit cross-compiling GHC,
         targeting a 32-bit platform, and performing constant folding on a
         literal that doesn't fit in a 32-bit word. If GHC was built with
         DEBUG, the assertion in GHC.Types.Literal.mkLitWord would fail.
         Otherwise the bad transformation would go unnoticed.
      37f0434d
    • Sylvain Henry's avatar
      Hadrian: don't fail if ghc-tarballs dir doesn't exist · 3486ebe6
      Sylvain Henry authored and Marge Bot's avatar Marge Bot committed
      3486ebe6
    • Alan Zimmerman's avatar
      Restrict Linear arrow %1 to exactly literal 1 only · 616bec0d
      Alan Zimmerman authored and Marge Bot's avatar Marge Bot committed
      This disallows `a %001 -> b`, and makes sure the type literal is
      printed from its SourceText so it is clear why.
      
      Closes #18888
      616bec0d
    • Sylvain Henry's avatar
      Linker: reorganize linker related code · 14ce454f
      Sylvain Henry authored and Marge Bot's avatar Marge Bot committed
      Move linker related code into GHC.Linker. Previously it was scattered
      into GHC.Unit.State, GHC.Driver.Pipeline, GHC.Runtime.Linker, etc.
      
      Add documentation in GHC.Linker
      14ce454f
    • Matthew Pickering's avatar
      Update inlining flags documentation · 78f2767d
      Matthew Pickering authored and Marge Bot's avatar Marge Bot committed
      78f2767d
    • Ben Gamari's avatar
      hadrian: Don't capture RunTest output · 1370eda7
      Ben Gamari authored and Marge Bot's avatar Marge Bot committed
      There are a few reasons why capturing the output of the RunTest builder
      is undesirable:
      
       * there is a large amount of output which then gets unnecessarily
         duplicated by Hadrian if the builder fails
      
       * the output may contain codepoints which are unrepresentable in the
         current codepage on Windows, causing Hadrian to crash
      
       * capturing the output causes the testsuite driver to disable
         its colorisation logic, making the output less legible.
      1370eda7
    • Simon Peyton Jones's avatar
      Expand type synonyms with :kind! · a9e5f52c
      Simon Peyton Jones authored and Marge Bot's avatar Marge Bot committed
      
      The User's Guide claims that `:kind!` should expand type synonyms,
      but GHCi wasn't doing this in practice. Let's just update the implementation
      to match the specification in the User's Guide.
      
      Fixes #13795. Fixes #18828.
      
      Co-authored-by: default avatarRyan Scott <ryan.gl.scott@gmail.com>
      a9e5f52c
    • Ryan Scott's avatar
      Display results of GHC.Core.Lint.lint* functions consistently · bfb1e272
      Ryan Scott authored and Marge Bot's avatar Marge Bot committed
      Previously, the functions in `GHC.Core.Lint` used a patchwork of
      different ways to display Core Lint errors:
      
      * `lintPassResult` (which is the source of most Core Lint errors) renders
        Core Lint errors with a distinctive banner (e.g.,
        `*** Core Lint errors : in result of ... ***`) that sets them apart
        from ordinary GHC error messages.
      * `lintAxioms`, in contrast, uses a completely different code path that
        displays Core Lint errors in a rather confusing manner. For example,
        the program in #18770 would give these results:
      
        ```
        Bug.hs:1:1: error:
            Bug.hs:12:1: warning:
                Non-*-like kind when *-like expected: RuntimeRep
                when checking the body of forall: 'TupleRep '[r]
                In the coercion axiom Bug.N:T :: []. Bug.T ~_R Any
                Substitution: [TCvSubst
                                 In scope: InScope {r}
                                 Type env: [axl :-> r]
                                 Co env: []]
          |
        1 | {-# LANGUAGE DataKinds #-}
          | ^
        ```
      * Further digging reveals that `GHC.IfaceToCore` displays Core Lint
        errors for iface unfoldings as though they were a GHC panic. See, for
        example, this excerpt from #17723:
      
        ```
        ghc: panic! (the 'impossible' happened)
          (GHC version 8.8.2 for x86_64-unknown-linux):
                Iface Lint failure
          In interface for Lib
          ...
        ```
      
      This patch makes all of these code paths display Core Lint errors and
      warnings consistently. I decided to adopt the conventions that
      `lintPassResult` currently uses, as they appear to have been around the
      longest (and look the best, in my subjective opinion). We now use the
      `displayLintResult` function for all three scenarios mentioned above.
      For example, here is what the Core Lint error for the program in #18770 looks
      like after this patch:
      
      ```
      [1 of 1] Compiling Bug              ( Bug.hs, Bug.o )
      *** Core Lint errors : in result of TcGblEnv axioms ***
      Bug.hs:12:1: warning:
          Non-*-like kind when *-like expected: RuntimeRep
          when checking the body of forall: 'TupleRep '[r_axn]
          In the coercion axiom N:T :: []. T ~_R Any
          Substitution: [TCvSubst
                           In scope: InScope {r_axn}
                           Type env: [axn :-> r_axn]
                           Co env: []]
      *** Offending Program ***
      axiom N:T :: T = Any -- Defined at Bug.hs:12:1
      *** End of Offense ***
      
      <no location info>: error:
      Compilation had errors
      ```
      
      Fixes #18770.
      bfb1e272
    • davide's avatar
      RtsAPI: pause and resume the RTS · 81006a06
      davide authored and Marge Bot's avatar Marge Bot committed
      
      The `rts_pause` and `rts_resume` functions have been added to `RtsAPI.h` and
      allow an external process to completely pause and resume the RTS.
      
      Co-authored-by: default avatarSven Tennie <sven.tennie@gmail.com>
      Co-authored-by: default avatarMatthew Pickering <matthewtpickering@gmail.com>
      Co-authored-by: default avatarBen Gamari <bgamari.foss@gmail.com>
      81006a06
    • Ben Gamari's avatar
      Document that ccall convention doesn't support varargs · 0b772221
      Ben Gamari authored and Marge Bot's avatar Marge Bot committed
      We do not support foreign "C" imports of varargs functions. While this
      works on amd64, in general the platform's calling convention may need
      more type information that our Cmm representation can currently provide.
      For instance, this is the case with Darwin's AArch64 calling convention.
      Document this fact in the users guide and fix T5423 which makes use of a
      disallowed foreign import.
      
      Closes #18854.
      0b772221
    • GHC GitLab CI's avatar
      testsuite: Add --top flag to driver · 4ce2f7d6
      GHC GitLab CI authored and Marge Bot's avatar Marge Bot committed
      This allows us to make `config.top` a proper Path. Previously it was a
      str, which caused the Ghostscript detection logic to break.
      4ce2f7d6
  2. Nov 01, 2020
  3. Oct 31, 2020
    • Andrzej Rybczak's avatar
      Add testcase for #816 · eb368078
      Andrzej Rybczak authored and Marge Bot's avatar Marge Bot committed
      eb368078
    • Tamar Christina's avatar
      winio: Fix unused variables warnings · cb1f755c
      Tamar Christina authored and Marge Bot's avatar Marge Bot committed
      cb1f755c
    • Sylvain Henry's avatar
      Move loadDecl into IfaceToCore · 08e6993a
      Sylvain Henry authored and Marge Bot's avatar Marge Bot committed
      08e6993a
    • Ben Gamari's avatar
      primops: Generate ByteArray# index/read/write primops · b4278a41
      Ben Gamari authored and Marge Bot's avatar Marge Bot committed
      Previously these were mostly undocumented and was ripe for potential
      inconsistencies.
      b4278a41
    • Ben Gamari's avatar
      primops.txt.pp: Move ByteArray# primops to separate file · d5a53c1a
      Ben Gamari authored and Marge Bot's avatar Marge Bot committed
      This file will be generated.
      d5a53c1a
    • Sylvain Henry's avatar
      Simplify constant-folding (#18032) · 730ef38f
      Sylvain Henry authored and Marge Bot's avatar Marge Bot committed
      See #18032 for the details.
      
      * Use `Lit (LitNumber _ i)` instead of `isLitValue_maybe` which does
        more work but that is not needed for constant-folding
      * Don't export `GHC.Types.Literal.isLitValue_maybe`
      * Kill `GHC.Types.Literal.isLitValue` which isn't used
      730ef38f
    • Sylvain Henry's avatar
      Refactor numeric constant folding rules · a98593f0
      Sylvain Henry authored and Marge Bot's avatar Marge Bot committed
      Avoid the use of global pattern synonyms.
      
      1) I think it's going to be helpful to implement constant folding for
         other numeric types, especially Natural which doesn't have a wrapping
         behavior. We'll have to refactor these rules even more so we'd better
         make them less cryptic.
      
      2) It should also be slightly faster because global pattern synonyms
         matched operations for every numeric types instead of the current one:
         e.g., ":**:" pattern was matching multiplication for both Int# and
         Word# types. As we will probably want to implement constant folding
         for other numeric types (Int8#, Int16#, etc.), it is more efficient
         to only match primops for a given type as we do now.
      a98593f0
    • Ryan Scott's avatar
      Make typechecker equality consider visibility in ForAllTys · 57c3db96
      Ryan Scott authored and Marge Bot's avatar Marge Bot committed
      Previously, `can_eq_nc'` would equate `ForAllTy`s regardless of their
      `ArgFlag`, including `forall i -> i -> Type` and `forall i. i -> Type`! To fix
      this, `can_eq_nc'` now uses the `sameVis` function to first check if the
      `ArgFlag`s are equal modulo specificity. I have also updated `tcEqType`'s
      implementation to match this behavior. For more explanation on the "modulo
      specificity" part, see the new `Note [ForAllTy and typechecker equality]`
      in `GHC.Tc.Solver.Canonical`.
      
      While I was in town, I fixed some related documentation issues:
      
      * I added `Note [Typechecker equality]` to `GHC.Tc.Utils.TcType` to describe
        what exactly distinguishes `can_eq_nc'` and `tcEqType` (which implement
        typechecker equality) from `eqType` (which implements definitional equality,
        which does not care about the `ArgFlags` of `ForAllTy`s at all).
      * The User's Guide had some outdated prose on the specified/inferred
        distinction being different for types and kinds, a holdover from #15079. This
        is no longer the case on today's GHC, so I removed this prose, added some new
        prose to take its place, and added a regression test for the programs in
        #15079.
      * The User's Guide had some _more_ outdated prose on inferred type variables
        not being allowed in `default` type signatures for class methods, which is no
        longer true as of the resolution of #18432.
      * The related `Note [Deferred Unification]` was being referenced as
        `Note [Deferred unification]` elsewhere, which made it harder to `grep`
        for. I decided to change the name of the Note to `Deferred unification`
        for consistency with the capitalization style used for most other Notes.
      
      Fixes #18863.
      57c3db96
  4. Oct 30, 2020
    • Ryan Scott's avatar
      Split HsConDecl{H98,GADT}Details · 31fcb55f
      Ryan Scott authored and Marge Bot's avatar Marge Bot committed
      Haskell98 and GADT constructors both use `HsConDeclDetails`, which includes
      `InfixCon`. But `InfixCon` is never used for GADT constructors, which results
      in an awkward unrepresentable state. This removes the unrepresentable state by:
      
      * Renaming the existing `HsConDeclDetails` synonym to `HsConDeclH98Details`,
        which emphasizes the fact that it is now only used for Haskell98-style data
        constructors, and
      * Creating a new `HsConDeclGADTDetails` data type with `PrefixConGADT` and
        `RecConGADT` constructors that closely resemble `PrefixCon` and `InfixCon`
        in `HsConDeclH98Details`. The key difference is that `HsConDeclGADTDetails`
        lacks any way to represent infix constructors.
      
      The rest of the patch is refactoring to accommodate the new structure of
      `HsConDecl{H98,GADT}Details`. Some highlights:
      
      * The `getConArgs` and `hsConDeclArgTys` functions have been removed, as
        there is no way to implement these functions uniformly for all
        `ConDecl`s. For the most part, their previous call sites now
        pattern match on the `ConDecl`s directly and do different things for
        `ConDeclH98`s and `ConDeclGADT`s.
      
        I did introduce one new function to make the transition easier:
        `getRecConArgs_maybe`, which extracts the arguments from a `RecCon(GADT)`.
        This is still possible since `RecCon(GADT)`s still use the same representation
        in both `HsConDeclH98Details` and `HsConDeclGADTDetails`, and since the
        pattern that `getRecConArgs_maybe` implements is used in several places,
        I thought it worthwhile to factor it out into its own function.
      * Previously, the `con_args` fields in `ConDeclH98` and `ConDeclGADT` were
        both of type `HsConDeclDetails`. Now, the former is of type
        `HsConDeclH98Details`, and the latter is of type `HsConDeclGADTDetails`,
        which are distinct types. As a result, I had to rename the `con_args` field
        in `ConDeclGADT` to `con_g_args` to make it typecheck.
      
        A consequence of all this is that the `con_args` field is now partial, so
        using `con_args` as a top-level field selector is dangerous. (Indeed, Haddock
        was using `con_args` at the top-level, which caused it to crash at runtime
        before I noticed what was wrong!) I decided to add a disclaimer in the 9.2.1
        release notes to advertise this pitfall.
      
      Fixes #18844. Bumps the `haddock` submodule.
      31fcb55f
    • vdukhovni's avatar
      [skip ci] Fix typo in `callocBytes` haddock. · 9902d9ec
      vdukhovni authored
      9902d9ec
    • Richard Eisenberg's avatar
      Remove unnecessary gender from comments/docs · 7f8be3eb
      Richard Eisenberg authored and Marge Bot's avatar Marge Bot committed
      While, say, alternating "he" and "she" in sequential writing
      may be nicer than always using "they", reading code/documentation
      is almost never sequential. If this small change makes individuals
      feel more welcome in GHC's codebase, that's a good thing.
      7f8be3eb
  5. Oct 29, 2020
    • Ryan Scott's avatar
      Check for large tuples more thoroughly · 2ef2fac4
      Ryan Scott authored
      This fixes #18723 by:
      
      * Moving the existing `GHC.Tc.Gen.HsType.bigConstraintTuple` validity
        check to `GHC.Rename.Utils.checkCTupSize` for consistency with
        `GHC.Rename.Utils.checkTupSize`, and
      * Using `check(C)TupSize` when checking tuple _types_, in addition
        to checking names, expressions, and patterns.
      
      Note that I put as many of these checks as possible in the typechecker so
      that GHC can properly distinguish between boxed and constraint tuples. The
      exception to this rule is checking names, which I perform in the renamer
      (in `GHC.Rename.Env`) so that we can rule out `(,, ... ,,)` and
      `''(,, ... ,,)` alike in one fell swoop.
      
      While I was in town, I also removed the `HsConstraintTuple` and
      `HsBoxedTuple` constructors of `HsTupleSort`, which are functionally
      unused. This requires a `haddock` submodule bump.
      2ef2fac4
    • Sylvain Henry's avatar
      GC: Avoid data race (#18717, #17964) · 22f5d9a9
      Sylvain Henry authored and Marge Bot's avatar Marge Bot committed
      22f5d9a9
    • Sylvain Henry's avatar
      Split GHC.Driver.Types · 0e9f6def
      Sylvain Henry authored and Marge Bot's avatar Marge Bot committed
      I was working on making DynFlags stateless (#17957), especially by
      storing loaded plugins into HscEnv instead of DynFlags. It turned out to
      be complicated because HscEnv is in GHC.Driver.Types but LoadedPlugin
      isn't: it is in GHC.Driver.Plugins which depends on GHC.Driver.Types. I
      didn't feel like introducing yet another hs-boot file to break the loop.
      
      Additionally I remember that while we introduced the module hierarchy
      (#13009) we talked about splitting GHC.Driver.Types because it contained
      various unrelated types and functions, but we never executed. I didn't
      feel like making GHC.Driver.Types bigger with more unrelated Plugins
      related types, so finally I bit the bullet and split GHC.Driver.Types.
      
      As a consequence this patch moves a lot of things. I've tried to put
      them into appropriate modules but nothing is set in stone.
      
      Several other things moved to avoid loops.
      
      * Removed Binary instances from GHC.Utils.Binary for random compiler
        things
      * Moved Typeable Binary instances into GHC.Utils.Binary.Typeable: they
        import a lot of things that users of GHC.Utils.Binary don't want to
        depend on.
      * put everything related to Units/Modules under GHC.Unit:
        GHC.Unit.Finder, GHC.Unit.Module.{ModGuts,ModIface,Deps,etc.}
      * Created several modules under GHC.Types: GHC.Types.Fixity, SourceText,
        etc.
      * Split GHC.Utils.Error (into GHC.Types.Error)
      * Finally removed GHC.Driver.Types
      
      Note that this patch doesn't put loaded plugins into HscEnv. It's left
      for another patch.
      
      Bump haddock submodule
      0e9f6def
    • John Ericson's avatar
      Widen acceptance threshold for T10421a · 795908dc
      John Ericson authored and Marge Bot's avatar Marge Bot committed
      Progress towards #18842. As @sgraf812 points out, widening the window is
      dangerous until the exponential described in #17658 is fixed. But this
      test has caused enough misery and is low stakes enough that we and
      @bgamari think it's worth it in this one case for the time being.
      795908dc
    • Alan Zimmerman's avatar
      API Annotations: put constructors in alphabetical order · c85eb372
      Alan Zimmerman authored and Marge Bot's avatar Marge Bot committed
      c85eb372
    • Ben Gamari's avatar
      hadrian: Don't quote metric baseline argument · 60322f93
      Ben Gamari authored and Marge Bot's avatar Marge Bot committed
      Previously this was quoted inappropriately.
      60322f93
  6. Oct 27, 2020
    • Sebastian Graf's avatar
      DmdAnal: Kill `is_thunk` case in `splitFV` · 28f98b01
      Sebastian Graf authored and Marge Bot's avatar Marge Bot committed
      The `splitFV` function implements the highly dubious hack
      described in `Note [Lazy und unleashable free variables]` in
      GHC.Core.Opt.DmdAnal. It arranges it so that demand signatures only
      carry strictness info on free variables. Usage info is released through
      other means, see the Note. It's purely for analysis performance reasons.
      
      It turns out that `splitFV` has a quite involved case for thunks that
      produces slightly different usage signatures and it's not clear why we
      need it: `splitFV` is only relevant in the LetDown case and the only
      time we call it on thunks is for top-level or local recursive thunks.
      
      Since usage signatures of top-level thunks can only reference other
      top-level bindings and we completely discard demand info we have on
      top-level things (see the lack of `setIdDemandInfo` in
      `dmdAnalTopBind`), the `is_thunk` case is completely irrelevant here.
      
      For local, recursive thunks, the added benefit of the `is_thunk` test
      is marginal: We get used-multiple-times in some cases where previously
      we had used-once if a recursive thunk has multiple call sites. It's
      very unlikely and not a case to optimise for.
      
      So we kill the `is_thunk` case and inline `splitFV` at its call site,
      exposing `isWeakDmd` from `GHC.Types.Demand` instead.
      
      The NoFib summary supports this decision:
      
      ```
                  Min           0.0%     -0.0%
                  Max           0.0%     +0.0%
       Geometric Mean          -0.0%     -0.0%
      ```
      28f98b01
    • Ben Gamari's avatar
      gitlab-ci: Bump ci-images · d2a25f42
      Ben Gamari authored and Marge Bot's avatar Marge Bot committed
      Bumps bootstrap compiler to 8.10.1.
      d2a25f42
    • Alan Zimmerman's avatar
      Api Annotations: Introduce AnnPercent for HsExplicitMult · e3fdd419
      Alan Zimmerman authored and Marge Bot's avatar Marge Bot committed
      For the case
      
        foo :: a %p -> b
      
      The location of the '%' is captured, separate from the 'p'
      e3fdd419
    • davide's avatar
      Use config.run_ways for multi_compile_and_run tests · 78b52c88
      davide authored and Marge Bot's avatar Marge Bot committed
      78b52c88
    • Sergei Trofimovich's avatar
      ghc.mk: amend 'make sdist' · f76c5a08
      Sergei Trofimovich authored and Marge Bot's avatar Marge Bot committed
      
      Noticed 'make sdist' failure seen as:
      
      ```
      "rm" -rf sdistprep/ghc/ghc-9.1.0.20201020/hadrian/_build/ (SRC_DIST_GHC_DIR)/hadrian/dist-newstyle/
      /bin/sh: -c: line 0: syntax error near unexpected token `('
      ```
      
      commit 9657f6f3
      ("sdist: Include hadrian sources in source distribution")
      added a new cleanup path without a variable expantion.
      
      The change adds variable reference. While at it move directory
      cleanup to a separate statement.
      
      Amends #18794
      
      Signed-off-by: default avatarSergei Trofimovich <slyfox@gentoo.org>
      f76c5a08
    • Simon Peyton Jones's avatar
      Fix two constraint solving problems · 0b3d23af
      Simon Peyton Jones authored and Marge Bot's avatar Marge Bot committed
      This patch fixes two problems in the constraint solver.
      
      * An actual bug #18555: we were floating out a constraint to eagerly,
        and that was ultimately fatal.  It's explained in
        Note [Do not float blocked constraints] in GHC.Core.Constraint.
      
        This is all very delicate, but it's all going to become irrelevant
        when we stop floating constraints (#17656).
      
      * A major performance infelicity in the flattener.  When flattening
        (ty |> co) we *never* generated Refl, even when there was nothing
        at all to do.  Result: we would gratuitously rewrite the constraint
        to exactly the same thing, wasting work.  Described in #18413, and
        came up again in #18855.
      
        Solution: exploit the special case by calling the new function
        castCoercionKind1.  See Note [castCoercionKind1] in
        GHC.Core.Coercion
      0b3d23af
    • Ben Gamari's avatar
      build system: Clean mingw tarballs · f3d8ab2e
      Ben Gamari authored and Marge Bot's avatar Marge Bot committed
      Tamar noticed in !4293 that the build systems fail to clean up the mingw
      tarballs directory (`ghc-tarballs`). Fix this in both the make build
      system and Hadrian.
      f3d8ab2e
Loading