1. 30 Apr, 2020 7 commits
    • Sylvain Henry's avatar
      Unit: split and rename modules · 8bfb0219
      Sylvain Henry authored
      Introduce GHC.Unit.* hierarchy for everything concerning units, packages
      and modules.
      
      Update Haddock submodule
      8bfb0219
    • Sylvain Henry's avatar
      Refactoring unit management code · 10d15f1e
      Sylvain Henry authored
      Over the years the unit management code has been modified a lot to keep
      up with changes in Cabal (e.g. support for several library components in
      the same package), to integrate BackPack, etc. I found it very hard to
      understand as the terminology wasn't consistent, was referring to past
      concepts, etc.
      
      The terminology is now explained as clearly as I could in the Note
      "About Units" and the code is refactored to reflect it.
      
      -------------------
      
      Many names were misleading: UnitId is not an Id but could be a virtual
      unit (an indefinite one instantiated on the fly), IndefUnitId
      constructor may contain a definite instantiated unit, etc.
      
         * Rename IndefUnitId into InstantiatedUnit
         * Rename IndefModule into InstantiatedModule
         * Rename UnitId type into Unit
         * Rename IndefiniteUnitId constructor into VirtUnit
         * Rename DefiniteUnitId constructor into RealUnit
         * Rename packageConfigId into mkUnit
         * Rename getPackageDetails into unsafeGetUnitInfo
         * Rename InstalledUnitId into UnitId
      
      Remove references to misleading ComponentId: a ComponentId is just an
      indefinite unit-id to be instantiated.
      
         * Rename ComponentId into IndefUnitId
         * Rename ComponentDetails into UnitPprInfo
         * Fix display of UnitPprInfo with empty version: this is now used for
           units dynamically generated by BackPack
      
      Generalize several types (Module, Unit, etc.) so that they can be used
      with different unit identifier types: UnitKey, UnitId, Unit, etc.
      
         * GenModule: Module, InstantiatedModule and InstalledModule are now
           instances of this type
         * Generalize DefUnitId, IndefUnitId, Unit, InstantiatedUnit,
           PackageDatabase
      
      Replace BackPack fake "hole" UnitId by a proper HoleUnit constructor.
      
      Add basic support for UnitKey. They should be used more in the future to
      avoid mixing them up with UnitId as we do now.
      
      Add many comments.
      
      Update Haddock submodule
      10d15f1e
    • Sylvain Henry's avatar
      Factorize mungePackagePaths code · ea717aa4
      Sylvain Henry authored
      This patch factorizes the duplicated code used in ghc-pkg and in GHC to
      munge package paths/urls.
      
      It also fixes haddock-html munging in GHC (allowed to be either a file
      or a url) to mimic ghc-pkg behavior.
      ea717aa4
    • Sylvain Henry's avatar
      Refactor UnitInfo load/store from databases · 9e2c8e0e
      Sylvain Henry authored
      Converting between UnitInfo stored in package databases and UnitInfo as
      they are used in ghc-pkg and ghc was done in a very convoluted way (via
      BinaryStringRep and DbUnitModuleRep type classes using fun deps, etc.).
      It was difficult to understand and even more to modify (I wanted to
      try to use a GADT for UnitId but fun deps got in the way).
      
      The new code uses much more straightforward functions to convert between
      the different representations. Much simpler.
      9e2c8e0e
    • Sylvain Henry's avatar
      Remove unused `emptyGenericUnitInfo` · 69562e34
      Sylvain Henry authored
      69562e34
    • Sylvain Henry's avatar
      Refactor UnitInfo · 10a2ba90
      Sylvain Henry authored
      * Rename InstalledPackageInfo into GenericUnitInfo
      
      The name InstalledPackageInfo is only kept for alleged backward
      compatibility reason in Cabal. ghc-boot has its own stripped down copy
      of this datatype but it doesn't need to keep the name. Internally we
      already use type aliases (UnitInfo in GHC, PackageCacheFormat in
      ghc-pkg).
      
      * Rename UnitInfo fields: add "unit" prefix and fix misleading names
      
      * Add comments on every UnitInfo field
      
      * Rename SourcePackageId into PackageId
      
      "Package" already indicates that it's a "source package". Installed
      package components are called units.
      
      Update Haddock submodule
      10a2ba90
    • Sylvain Henry's avatar
      Document backpack fields in DynFlags · 2cfc4ab9
      Sylvain Henry authored
      2cfc4ab9
  2. 28 Apr, 2020 4 commits
    • Ryan Scott's avatar
      Make boxed 1-tuples have known keys · 518a63d4
      Ryan Scott authored
      Unlike other tuples, which use special syntax and are "known" by way
      of a special `isBuiltInOcc_maybe` code path, boxed 1-tuples do not
      use special syntax. Therefore, in order to make sure that the
      internals of GHC are aware of the `data Unit a = Unit a` definition
      in `GHC.Tuple`, we give `Unit` known keys. For the full details, see
      `Note [One-tuples] (Wrinkle: Make boxed one-tuple names have known keys)`
      in `GHC.Builtin.Types`.
      
      Fixes #18097.
      518a63d4
    • Ryan Scott's avatar
      Define a Quote IO instance · 4b9764db
      Ryan Scott authored
      Fixes #18103.
      4b9764db
    • Alp Mestanogullari's avatar
      hadrian: always capture both stdout and stderr when running a builder fails · c62271a2
      Alp Mestanogullari authored
      The idea being that when a builder('s command) fails, we quite likely want to
      have all the information available to figure out why. Depending on the builder
      _and_ the particular problem, the useful bits of information can be printed
      on stdout or stderr.
      
      We accomplish this by defining a simple wrapper for Shake's `cmd` function,
      that just _always_ captures both streams in case the command returns a non-zero
      exit code, and by using this wrapper everywhere in `hadrian/src/Builder.hs`.
      
      Fixes #18089.
      c62271a2
    • Sylvain Henry's avatar
      TH: fix Show/Eq/Ord instances for Bytes (#16457) · 99823ed2
      Sylvain Henry authored
      We shouldn't compare pointer values but the actual bytes.
      99823ed2
  3. 26 Apr, 2020 3 commits
  4. 24 Apr, 2020 1 commit
    • John Ericson's avatar
      Switch order on `GhcMake.IsBoot` · b0fbfc75
      John Ericson authored
      In !1798 we were requested to replace many `Bool`s with this data type.
      But those bools had `False` meaning `NotBoot`, so the `Ord` instance
      would be flipped if we use this data-type as-is.
      
      Since the planned formally-`Bool` occurrences vastly outnumber the
      current occurrences, we figured it would be better to conform the `Ord`
      instance to how the `Bool` is used now, fixing any issues, rather than
      fix them currently with the bigger refactor later in !1798. That way,
      !1798 can be a "pure" refactor with no behavioral changes.
      b0fbfc75
  5. 23 Apr, 2020 24 commits
    • mniip's avatar
      GHC.Prim docs: note and test · 0ac29c88
      mniip authored
      0ac29c88
    • mniip's avatar
      2c23e2e3
    • mniip's avatar
      Add :doc to GHC.Prim · 72da0c29
      mniip authored
      72da0c29
    • John Ericson's avatar
      Trees That Grow refactor for `ConPat` and `CoPat` · c42754d5
      John Ericson authored
      - `ConPat{In,Out}` -> `ConPat`
      
      - `CoPat` -> `XPat (CoPat ..)`
      
      Note that `GHC.HS.*` still uses `HsWrap`, but only when `p ~ GhcTc`.
      After this change, moving the type family instances out of `GHC.HS.*` is
      sufficient to break the cycle.
      
      Add XCollectPat class to decide how binders are collected from XXPat based on the pass.
      
      Previously we did this with IsPass, but that doesn't work for Haddock's
      DocNameI, and the constraint doesn't express what actual distinction is being
      made. Perhaps a class for collecting binders more generally is in order, but we
      haven't attempted this yet.
      
      Pure refactor of code around ConPat
      
       - InPat/OutPat synonyms removed
      
       - rename several identifiers
      
       - redundant constraints removed
      
       - move extension field in ConPat to be first
      
       - make ConPat use record syntax more consistently
      
      Fix T6145 (ConPatIn became ConPat)
      
      Add comments from SPJ.
      
      Add comment about haddock's use of CollectPass.
      
      Updates haddock submodule.
      c42754d5
    • Ben Gamari's avatar
      testsuite: Don't attempt to read .std{err,out} files if they don't exist · 5946c85a
      Ben Gamari authored
      Simon reports that he was previously seeing framework failures due to
      an attempt to read the non-existing T13456.stderr. While I don't know
      exactly what this is due to, it does seem like a non-existing
      .std{out,err} file should be equivalent to an empty file. Teach the
      testsuite driver to treat it as such.
      5946c85a
    • Ben Gamari's avatar
      hadrian/ghci: Allow arguments to be passed to GHCi · 339e8ece
      Ben Gamari authored
      Previously the arguments passed to hadrian/ghci were passed both to
      `hadrian` and GHCi. This is rather odd given that there are essentially
      not arguments in the intersection of the two. Let's just pass them to
      GHCi; this allows `hadrian/ghci -Werror`.
      339e8ece
    • Ryan Scott's avatar
      Create di_scoped_tvs for associated data family instances properly · cd8409c2
      Ryan Scott authored
      See `Note [Associated data family instances and di_scoped_tvs]` in
      `GHC.Tc.TyCl.Instance`, which explains all of the moving parts.
      
      Fixes #18055.
      cd8409c2
    • Sylvain Henry's avatar
      RTS: workaround a Linux kernel bug in timerfd · 8ea37b01
      Sylvain Henry authored
      Reading a timerfd may return 0: https://lkml.org/lkml/2019/8/16/335.
      
      This is currently undocumented behavior and documentation "won't happen
      anytime soon" (https://lkml.org/lkml/2020/2/13/295).
      
      With this patch, we just ignore the result instead of crashing. It may
      fix #18033 but we can't be sure because we don't have enough
      information.
      
      See also this discussion about the kernel bug:
      https://github.com/Azure/sonic-swss-common/pull/302/files/1f070e7920c2e5d63316c0105bf4481e73d72dc9
      8ea37b01
    • Ömer Sinan Ağacan's avatar
      Remove leftover comment in tcRnModule', redundant bind · 125aa2b8
      Ömer Sinan Ağacan authored
      The code for the comment was moved in dc8c03b2 but the comment was
      forgotten.
      125aa2b8
    • Ryan Scott's avatar
      Update commentary and slightly refactor GHC.Tc.Deriv.Infer · c409961a
      Ryan Scott authored
      There was some out-of-date commentary in `GHC.Tc.Deriv.Infer` that
      has been modernized. Along the way, I removed the `bad` constraints
      in `simplifyDeriv`, which did not serve any useful purpose (besides
      being printed in debugging output).
      
      Fixes #18073.
      c409961a
    • Moritz Angermann's avatar
    • Ben Gamari's avatar
      llvmGen: Remove -fast-llvm flag · 4b4a8b60
      Ben Gamari authored
      Issue #18076 drew my attention to the undocumented `-fast-llvm` flag for
      the LLVM code generator introduced in
      22733532. Speaking to Moritz about this,
      the motivation for this flag was to avoid potential incompatibilities
      between LLVM and the assembler/linker toolchain by making LLVM
      responsible for machine-code generation.
      
      Unfortunately, this cannot possibly work: the LLVM backend's mangler
      performs a number of transforms on the assembler generated by LLVM that
      are necessary for correctness. These are currently:
      
       * mangling Haskell functions' symbol types to be `object` instead of
         `function` on ELF platforms (necessary for tables-next-to-code)
       * mangling AVX instructions to ensure that we don't assume alignment
         (which LLVM otherwise does)
       * mangling Darwin's  subsections-via-symbols directives
      
      Given that these are all necessary I don't believe that we can support
      `-fast-llvm`. Let's rather remove it.
      4b4a8b60
    • Andreas Klebinger's avatar
      c29f0fa6
    • Ben Gamari's avatar
      rts: Ensure that sigaction structs are initialized · 6f84aca3
      Ben Gamari authored
      I noticed these may have uninitialized fields when looking into #18037.
      The reporter says that zeroing them doesn't fix the MSAN failures they
      observe but zeroing them is the right thing to do regardless.
      6f84aca3
    • Simon Peyton Jones's avatar
      Do eager instantation in terms · ffde2348
      Simon Peyton Jones authored
      This patch implements eager instantiation, a small but critical change
      to the type inference engine, #17173.  The main change is this:
      
        When inferring types, always return an instantiated type
        (for now, deeply instantiated; in future shallowly instantiated)
      
      There is more discussion in
      https://www.tweag.io/posts/2020-04-02-lazy-eager-instantiation.html
      
      There is quite a bit of refactoring in this patch:
      
      * The ir_inst field of GHC.Tc.Utils.TcType.InferResultk
        has entirely gone.  So tcInferInst and tcInferNoInst have collapsed
        into tcInfer.
      
      * Type inference of applications, via tcInferApp and
        tcInferAppHead, are substantially refactored, preparing
        the way for Quick Look impredicativity.
      
      * New pure function GHC.Tc.Gen.Expr.collectHsArgs and applyHsArgs
        are beatifully dual.  We can see the zipper!
      
      * GHC.Tc.Gen.Expr.tcArgs is now much nicer; no longer needs to return
        a wrapper
      
      * In HsExpr, HsTypeApp now contains the the actual type argument,
        and is used in desugaring, rather than putting it in a mysterious
        wrapper.
      
      * I struggled a bit with good error reporting in
        Unify.matchActualFunTysPart. It's a little bit simpler than before,
        but still not great.
      
      Some smaller things
      
      * Rename tcPolyExpr --> tcCheckExpr
               tcMonoExpr --> tcLExpr
      * tcPatSig moves from GHC.Tc.Gen.HsType to GHC.Tc.Gen.Pat
      
      Metric Decrease:
          T9961
      
      Reduction of 1.6% in comiler allocation on T9961, I think.
      ffde2348
    • Peter Trommler's avatar
      PPC NCG: Add DWARF constants and debug labels · 34a45ee6
      Peter Trommler authored
      Fixes #11261
      34a45ee6
    • Roland Senn's avatar
      Fix tab-completion for :break (#17989) · 48b8951e
      Roland Senn authored
      In tab-completion for the `:break` command, only those
      identifiers should be shown, that are accepted in the
      `:break` command. Hence these identifiers must be
      
      - defined in an interpreted module
      - top-level
      - currently in scope
      - listed in a `ModBreaks` value as a possible breakpoint.
      
      The identifiers my be qualified or unqualified.
      
      To get all possible top-level breakpoints for tab-completeion
      with the correct qualification do:
      
      1. Build the  list called `pifsBreaks` of all pairs of
      (Identifier, module-filename) from the `ModBreaks` values.
      Here all identifiers are unqualified.
      
      2. Build the list called `pifInscope` of all pairs of
      (Identifiers, module-filename) with identifiers from
      the `GlobalRdrEnv`. Take only those identifiers that are
      in scope and have the  correct prefix.
      Here the identifiers may be qualified.
      
      3. From the `pifInscope` list seclect all pairs that can be
      found in the `pifsBreaks` list, by comparing only the
      unqualified part of the identifier.
      The remaining identifiers can be used for tab-completion.
      
      This ensures, that we show only identifiers, that can be used
      in a `:break` command.
      48b8951e
    • Alexis King's avatar
      Mark DataCon wrappers CONLIKE · 6c9fae23
      Alexis King authored
      Now that DataCon wrappers don’t inline until phase 0 (see commit
      b78cc64e), it’s important that
      case-of-known-constructor and RULE matching be able to see saturated
      applications of DataCon wrappers in unfoldings. Making them conlike is a
      natural way to do it, since they are, in fact, precisely the sort of
      thing the CONLIKE pragma exists to solve.
      
      Fixes #18012.
      
      This also bumps the version of the parsec submodule to incorporate a
      patch that avoids a metric increase on the haddock perf tests. The
      increase was not really a flaw in this patch, as parsec was implicitly
      relying on inlining heuristics. The patch to parsec just adds some
      INLINABLE pragmas, and we get a nice performance bump out of it (well
      beyond the performance we lost from this patch).
      
      Metric Decrease:
          T12234
          WWRec
          haddock.Cabal
          haddock.base
          haddock.compiler
      6c9fae23
    • John Ericson's avatar
      `MatchResult'` -> `MatchResult` · 401f7bb3
      John Ericson authored
      Inline `MatchResult` alias accordingly.
      401f7bb3
    • John Ericson's avatar
      Generalize type of `matchCanFail` · 72cb6bcc
      John Ericson authored
      72cb6bcc
    • John Ericson's avatar
      Inline `adjustMatchResult` · cde23cd4
      John Ericson authored
      It is just `fmap`
      cde23cd4
    • John Ericson's avatar
      Remove panic in dsHandleMonadicFailure · dcb7fe5a
      John Ericson authored
      Rework dsHandleMonadicFailure to be correct by construction instead of
      using an unreachable panic.
      dcb7fe5a
    • Jonathan DK Gibbons's avatar
      Refactor the `MatchResult` type in the desugarer · e8a5d81b
      Jonathan DK Gibbons authored
      This way, it does a better job of proving whether or not the fail operator is used.
      e8a5d81b
    • Takenobu Tani's avatar
      stg-spec: Modify file paths according to new module hierarchy · ffd7eef2
      Takenobu Tani authored
      This patch updates file paths according to new module hierarchy [1]:
      
        * GHC/Stg/Syntax.hs       <= stgSyn/StgSyn.hs
        * GHC/Types/Literal.hs    <= basicTypes/Literal.hs
        * GHC/Types/CostCentre.hs <= profiling/CostCentre.hs
      
      This patch also updates old file path [2]:
      
        * utils/genapply/Main.hs  <= utils/genapply/GenApply.hs
      
      [1]: https://gitlab.haskell.org/ghc/ghc/-/wikis/Make-GHC-codebase-more-modular
      [2]: commit 0cc4aad3
      
      [skip ci]
      ffd7eef2
  6. 21 Apr, 2020 1 commit
    • Sylvain Henry's avatar
      CmmToAsm DynFlags refactoring (#17957) · 747093b7
      Sylvain Henry authored
      * Remove `DynFlags` parameter from `isDynLinkName`: `isDynLinkName` used
        to test the global `ExternalDynamicRefs` flag. Now we test it outside of
        `isDynLinkName`
      
      * Add new fields into `NCGConfig`: current unit id, sse/bmi versions,
        externalDynamicRefs, etc.
      
      * Replace many uses of `DynFlags` by `NCGConfig`
      
      * Moved `BMI/SSE` datatypes into `GHC.Platform`
      747093b7