1. 22 Feb, 2020 2 commits
    • Sylvain Henry's avatar
      Modules: Driver (#13009) · 240f5bf6
      Sylvain Henry authored
      submodule updates: nofib, haddock
      240f5bf6
    • Vladislav Zavialov's avatar
      Parser API annotations: RealSrcLoc · be7068a6
      Vladislav Zavialov authored
      During parsing, GHC collects lexical information about AST nodes and
      stores it in a map. It is needed to faithfully restore original source
      code, e.g. compare these expressions:
      
      	a =  b
      	a  = b
      
      The position of the equality sign is not recorded in the AST, so it must
      be stored elsewhere.
      
      This system is described in Note [Api annotations].
      
      Before this patch, the mapping was represented by:
      
      	Map (SrcSpan, AnnKeywordId) SrcSpan
      
      After this patch, the mapping is represented by:
      
      	Map (RealSrcSpan, AnnKeywordId) RealSrcSpan
      
      The motivation behind this change is to avoid using the Ord SrcSpan
      instance (required by Map here), as it interferes with #17632 (see the
      discussion there).
      
      SrcSpan is isomorphic to  Either String RealSrcSpan,  but we shouldn't
      use those strings as Map keys. Those strings are intended as hints to
      the user, e.g. "<interactive>" or "<compiler-generated code>", so they
      are not a valid way to identify nodes in the source code.
      be7068a6
  2. 19 Feb, 2020 1 commit
  3. 12 Feb, 2020 1 commit
  4. 31 Jan, 2020 2 commits
    • Sylvain Henry's avatar
      Refactor package related code · 29c701c1
      Sylvain Henry authored
      The package terminology is a bit of a mess. Cabal packages contain
      components. Instances of these components when built with some
      flags/options/dependencies are called units. Units are registered into
      package databases and their metadata are called PackageConfig.
      
      GHC only knows about package databases containing units. It is a sad
      mismatch not fixed by this patch (we would have to rename parameters
      such as `package-id <unit-id>` which would affect users).
      
      This patch however fixes the following internal names:
      
      - Renames PackageConfig into UnitInfo.
      - Rename systemPackageConfig into globalPackageDatabase[Path]
      - Rename PkgConfXX into PkgDbXX
      - Rename pkgIdMap into unitIdMap
      - Rename ModuleToPkgDbAll into ModuleNameProvidersMap
      - Rename lookupPackage into lookupUnit
      - Add comments on DynFlags package related fields
      
      It also introduces a new `PackageDatabase` datatype instead of
      explicitly passing the following tuple: `(FilePath,[PackageConfig])`.
      
      The `pkgDatabase` field in `DynFlags` now contains the unit info for
      each unit of each package database exactly as they have been read from
      disk. Previously the command-line flag `-distrust-all-packages` would
      modify these unit info. Now this flag only affects the "dynamic"
      consolidated package state found in `pkgState` field. It makes sense
      because `initPackages` could be called first with this
      `distrust-all-packages` flag set and then again (using ghc-api) without
      and it should work (package databases are not read again from disk when
      `initPackages` is called the second time).
      
      Bump haddock submodule
      29c701c1
    • Sylvain Henry's avatar
      Call `interpretPackageEnv` from `setSessionDynFlags` · bf38a20e
      Sylvain Henry authored
      interpretPackageEnv modifies the flags by reading the dreaded package
      environments. It is much less surprising to call it from
      `setSessionDynFlags` instead of reading package environments as a
      side-effect of `initPackages`.
      bf38a20e
  5. 07 Jan, 2020 1 commit
    • Ryan Scott's avatar
      Monomorphize HsModule to GhcPs (#17642) · b69a3460
      Ryan Scott authored
      Analyzing the call sites for `HsModule` reveals that it is only ever
      used with parsed code (i.e., `GhcPs`). This simplifies `HsModule` by
      concretizing its `pass` parameter to always be `GhcPs`.
      
      Fixes #17642.
      b69a3460
  6. 06 Jan, 2020 1 commit
  7. 04 Jan, 2020 1 commit
  8. 17 Dec, 2019 1 commit
  9. 30 Nov, 2019 1 commit
  10. 13 Nov, 2019 1 commit
    • Ben Gamari's avatar
      Ensure that coreView/tcView are able to inline · 2d4f9ad8
      Ben Gamari authored
      Previously an import cycle between Type and TyCoRep meant that several
      functions in TyCoRep ended up SOURCE import coreView. This is quite
      unfortunate as coreView is intended to be fused into a larger pattern
      match and not incur an extra call.
      
      Fix this with a bit of restructuring:
      
       * Move the functions in `TyCoRep` which depend upon things in `Type`
         into `Type`
       * Fold contents of `Kind` into `Type` and turn `Kind` into a simple
         wrapper re-exporting kind-ish things from `Type`
       * Clean up the redundant imports that popped up as a result
      
      Closes #17441.
      
      Metric Decrease:
          T4334
      2d4f9ad8
  11. 16 Oct, 2019 1 commit
    • Richard Eisenberg's avatar
      Break up TcRnTypes, among other modules. · 51fad9e6
      Richard Eisenberg authored
      This introduces three new modules:
      
       - basicTypes/Predicate.hs describes predicates, moving
         this logic out of Type. Predicates don't really exist
         in Core, and so don't belong in Type.
      
       - typecheck/TcOrigin.hs describes the origin of constraints
         and types. It was easy to remove from other modules and
         can often be imported instead of other, scarier modules.
      
       - typecheck/Constraint.hs describes constraints as used in
         the solver. It is taken from TcRnTypes.
      
      No work other than module splitting is in this patch.
      
      This is the first step toward homogeneous equality, which will
      rely more strongly on predicates. And homogeneous equality is the
      next step toward a dependently typed core language.
      51fad9e6
  12. 07 Oct, 2019 1 commit
  13. 01 Oct, 2019 1 commit
    • Ömer Sinan Ağacan's avatar
      Refactor iface file generation: · f3cb8c7c
      Ömer Sinan Ağacan authored
      This commit refactors interface file generation to allow information
      from the later passed (NCG, STG) to be stored in interface files.
      
      We achieve this by splitting interface file generation into two parts:
      * Partial interfaces, built based on the result of the core pipeline
      * A fully instantiated interface, which also contains the final
      fingerprints and can optionally contain information produced by the backend.
      
      This change is required by !1304 and !1530.
      
      -dynamic-too handling is refactored too: previously when generating code
      we'd branch on -dynamic-too *before* code generation, but now we do it
      after.
      
      (Original code written by @AndreasK in !1530)
      
      Performance
      ~~~~~~~~~~~
      
      Before this patch interface files where created and immediately flushed
      to disk which made space leaks impossible.
      With this change we instead use NFData to force all iface related data
      structures to avoid space leaks.
      
      In the process of refactoring it was discovered that the code in the
      ToIface Module allocated a lot of thunks which were immediately forced
      when writing/forcing the interface file. So we made this module more
      strict to avoid creating many of those thunks.
      
      Bottom line is that allocations go down by about ~0.1% compared to
      master.
      Residency is not meaningfully different after this patch.
      Runtime was not benchmarked.
      Co-Authored-By: Andreas Klebinger's avatarAndreas Klebinger <klebinger.andreas@gmx.at>
      Co-Authored-By: Ömer Sinan Ağacan's avatarÖmer Sinan Ağacan <omer@well-typed.com>
      f3cb8c7c
  14. 20 Sep, 2019 1 commit
  15. 18 Aug, 2019 1 commit
  16. 20 Jun, 2019 1 commit
    • John Ericson's avatar
      Move 'Platform' to ghc-boot · bff2f24b
      John Ericson authored
      ghc-pkg needs to be aware of platforms so it can figure out which
      subdire within the user package db to use. This is admittedly
      roundabout, but maybe Cabal could use the same notion of a platform as
      GHC to good affect too.
      bff2f24b
  17. 04 Jun, 2019 1 commit
    • xldenis's avatar
      Add GHCi :instances command · 002594b7
      xldenis authored
      This commit adds the `:instances` command to ghci following proosal
      number 41.
      
      This makes it possible to query which instances are available to a given
      type.
      
      The output of this command is all the possible instances with type
      variables and constraints instantiated.
      002594b7
  18. 20 Mar, 2019 1 commit
  19. 15 Mar, 2019 1 commit
  20. 18 Feb, 2019 1 commit
  21. 14 Feb, 2019 1 commit
    • Simon Peyton Jones's avatar
      Make a smart mkAppTyM · 68278382
      Simon Peyton Jones authored
      This patch finally delivers on Trac #15952.  Specifically
      
      * Completely remove Note [The tcType invariant], along with
        its complicated consequences (IT1-IT6).
      
      * Replace Note [The well-kinded type invariant] with:
      
            Note [The Purely Kinded Type Invariant (PKTI)]
      
      * Instead, establish the (PKTI) in TcHsType.tcInferApps,
        by using a new function mkAppTyM when building a type
        application.  See Note [mkAppTyM].
      
      * As a result we can remove the delicate mkNakedXX functions
        entirely.  Specifically, mkNakedCastTy retained lots of
        extremly delicate Refl coercions which just cluttered
        everything up, and(worse) were very vulnerable to being
        silently eliminated by (say) substTy. This led to a
        succession of bug reports.
      
      The result is noticeably simpler to explain, simpler
      to code, and Richard and I are much more confident that
      it is correct.
      
      It does not actually fix any bugs, but it brings us closer.
      E.g. I hoped it'd fix #15918 and #15799, but it doesn't quite
      do so.  However, it makes it much easier to fix.
      
      I also did a raft of other minor refactorings:
      
      * Use tcTypeKind consistently in the type checker
      
      * Rename tcInstTyBinders to tcInvisibleTyBinders,
        and refactor it a bit
      
      * Refactor tcEqType, pickyEqType, tcEqTypeVis
        Simpler, probably more efficient.
      
      * Make zonkTcType zonk TcTyCons, at least if they have
        any free unification variables -- see zonk_tc_tycon
        in TcMType.zonkTcTypeMapper.
      
        Not zonking these TcTyCons was actually a bug before.
      
      * Simplify try_to_reduce_no_cache in TcFlatten (a lot)
      
      * Combine checkExpectedKind and checkExpectedKindX.
        And then combine the invisible-binder instantation code
        Much simpler now.
      
      * Fix a little bug in TcMType.skolemiseQuantifiedTyVar.
        I'm not sure how I came across this originally.
      
      * Fix a little bug in TyCoRep.isUnliftedRuntimeRep
        (the ASSERT was over-zealous).  Again I'm not certain
        how I encountered this.
      
      * Add a missing solveLocalEqualities in
        TcHsType.tcHsPartialSigType.
        I came across this when trying to get level numbers
        right.
      68278382
  22. 18 Jan, 2019 1 commit
  23. 13 Jan, 2019 1 commit
    • Ömer Sinan Ağacan's avatar
      Refactor GHCi UI to fix #11606, #12091, #15721, #16096 · a34ee615
      Ömer Sinan Ağacan authored
      Instead of parsing and executing a statement or declaration directly we
      now parse them first and then execute in a separate step. This gives us
      the flexibility to inspect the parsed declaration before execution.
      Using this we now inspect parsed declarations, and if it's a single
      declaration of form `x = y` we execute it as `let x = y` instead, fixing
      a ton of problems caused by poor declaration support in GHCi.
      
      To avoid any users of the modules I left `execStmt` and `runDecls`
      unchanged and added `execStmt'` and `runDecls'` which work on parsed
      statements/declarations.
      a34ee615
  24. 24 Nov, 2018 1 commit
  25. 22 Nov, 2018 1 commit
    • David Eichmann's avatar
      Fix unused-import warnings · 6353efc7
      David Eichmann authored
      This patch fixes a fairly long-standing bug (dating back to 2015) in
      RdrName.bestImport, namely
      
         commit 9376249b
         Author: Simon Peyton Jones <simonpj@microsoft.com>
         Date:   Wed Oct 28 17:16:55 2015 +0000
      
         Fix unused-import stuff in a better way
      
      In that patch got the sense of the comparison back to front, and
      thereby failed to implement the unused-import rules described in
        Note [Choosing the best import declaration] in RdrName
      
      This led to Trac #13064 and #15393
      
      Fixing this bug revealed a bunch of unused imports in libraries;
      the ones in the GHC repo are part of this commit.
      
      The two important changes are
      
      * Fix the bug in bestImport
      
      * Modified the rules by adding (a) in
           Note [Choosing the best import declaration] in RdrName
        Reason: the previosu rules made Trac #5211 go bad again.  And
        the new rule (a) makes sense to me.
      
      In unravalling this I also ended up doing a few other things
      
      * Refactor RnNames.ImportDeclUsage to use a [GlobalRdrElt] for the
        things that are used, rather than [AvailInfo]. This is simpler
        and more direct.
      
      * Rename greParentName to greParent_maybe, to follow GHC
        naming conventions
      
      * Delete dead code RdrName.greUsedRdrName
      
      Bumps a few submodules.
      
      Reviewers: hvr, goldfire, bgamari, simonmar, jrtc27
      
      Subscribers: rwbarton, carter
      
      Differential Revision: https://phabricator.haskell.org/D5312
      6353efc7
  26. 12 Sep, 2018 1 commit
  27. 07 Sep, 2018 1 commit
  28. 21 Aug, 2018 1 commit
    • Alec Theriault's avatar
      Explicitly tell 'getNameToInstances' mods to load · c971e119
      Alec Theriault authored
      Calculating which modules to load based on the InteractiveContext means
      maintaining a potentially very large GblRdrEnv.
      
      In Haddock's case, it is much cheaper (from a memory perspective) to
      just keep track of which modules interfaces we want loaded then hand
      these off explicitly to 'getNameToInstancesIndex'.
      
      Bumps haddock submodule.
      
      Reviewers: alexbiehl, bgamari
      
      Reviewed By: alexbiehl
      
      Subscribers: rwbarton, thomie, carter
      
      Differential Revision: https://phabricator.haskell.org/D5003
      c971e119
  29. 20 Jul, 2018 1 commit
  30. 04 Jun, 2018 1 commit
    • Simon Jakobi's avatar
      Serialize docstrings to ifaces, display them with new GHCi :doc command · 85309a3c
      Simon Jakobi authored
      If `-haddock` is set, we now extract docstrings from the renamed ast
      and serialize them in the .hi-files.
      
      This includes some of the changes from D4749 with the notable
      exceptions of the docstring lexing and renaming.
      
      A currently limited and experimental GHCi :doc command can be used
      to display docstrings for declarations.
      
      The formatting of pretty-printed docstrings is changed slightly,
      causing some changes in testsuite/tests/haddock.
      
      Test Plan: ./validate
      
      Reviewers: alexbiehl, hvr, gershomb, harpocrates, bgamari
      
      Reviewed By: alexbiehl
      
      Subscribers: rwbarton, thomie, carter
      
      Differential Revision: https://phabricator.haskell.org/D4758
      85309a3c
  31. 30 May, 2018 1 commit
    • Kavon Farvardin's avatar
      Extract hard-coded LLVM opt flags into a file · a4ae199c
      Kavon Farvardin authored
      To resolve ticket #11295, I think it makes sense to stop hard-coding
      the pass sequences used by GHC when compiling with LLVM into the
      compiler
      itself.
      
      This patchset introduces a companion to the existing `llvm-targets` file
      called `llvm-passes`. The passes file is a simple association list that
      holds the default LLVM `opt` pass sequence used by GHC. This allows end
      users to easily save their favorite optimization flags when compiling
      with LLVM.
      
      The main benefit for ticket #11295 is that when adding a custom pass
      sequence, it tends to be an extremely long string that would be
      unsightly in the code.
      
      This is essentially part 1 of 2 for ticket #11295.
      
      Test Plan: ./validate
      
      Reviewers: bgamari, angerman
      
      Reviewed By: angerman
      
      Subscribers: rwbarton, thomie, carter
      
      Differential Revision: https://phabricator.haskell.org/D4695
      a4ae199c
  32. 13 May, 2018 1 commit
    • Matthew Pickering's avatar
      Simplify -ddump-json implementation · 6ab7cf99
      Matthew Pickering authored
      This patch takes the much simpler route of whenever the compiler tries
      to output something. We just dump a JSON document there and then.
      
      I think this should be sufficient to work with and anything more refined
      quickly got complicated as it was necessary to demarcate message scopes
      and so on.
      
      Reviewers: bgamari, dfeuer
      
      Reviewed By: bgamari
      
      Subscribers: Phyx, dfeuer, rwbarton, thomie, carter
      
      GHC Trac Issues: #14078
      
      Differential Revision: https://phabricator.haskell.org/D4532
      6ab7cf99
  33. 26 Jan, 2018 1 commit
    • Alec Theriault's avatar
      Haddock needs to pass visible modules for instance filtering · 66961dc8
      Alec Theriault authored
      The GHC-side `getNameToInstancesIndex` filters out incorrectly some
      instances because it is not aware of what modules are visible. Using
      `runTcInteractive` means that `ie_visible` gets initialized to a one
      module set containing some dummy GHCi module. This is clearly not the
      module set we want to check against to see if a given orphan instance
      is visible or not.
      
      In fact, GHC has no way of knowing what we want that module set to be
      since it doesn't know ahead of time which modules Haddock is making its
      docs for. The fix is just to pass that set in as an argument.
      
      Bumps haddock submodule.
      
      Reviewers: bgamari
      
      Reviewed By: bgamari
      
      Subscribers: duog, alexbiehl, rwbarton, thomie, carter
      
      Differential Revision: https://phabricator.haskell.org/D4290
      66961dc8
  34. 22 Sep, 2017 1 commit
    • Facundo Domínguez's avatar
      Implement TH addCorePlugin. · 17558690
      Facundo Domínguez authored
      This allows template-haskell code to add plugins to the compilation
      pipeline. Otherwise, the user would have to pass -fplugin=... to ghc.
      
      For now, plugin modules in the current package can't be used. This is
      because when TH runs, it is too late to let GHC know that the plugin
      modules needed to be compiled first.
      
      Test Plan: ./validate
      
      Reviewers: simonpj, bgamari, austin, goldfire
      
      Reviewed By: bgamari
      
      Subscribers: angerman, rwbarton, mboes, thomie
      
      GHC Trac Issues: #13608
      
      Differential Revision: https://phabricator.haskell.org/D3821
      17558690
  35. 19 Sep, 2017 2 commits
  36. 06 Sep, 2017 1 commit
    • Moritz Angermann's avatar
      Clean up opt and llc · 22733532
      Moritz Angermann authored
      The LLVM backend shells out to LLVMs `opt` and `llc` tools. This clean
      up introduces a shared data structure to carry the arguments we pass to
      each tool so that corresponding flags are next to each other. It drops
      the hard coded data layouts in favor of using `-mtriple` and have LLVM
      infer them. Furthermore we add `clang` as a proper tool, so we don't
      rely on assuming that `clang` is called `clang` on the `PATH` when using
      `clang` as the assembler.  Finally this diff also changes the type of
      `optLevel` from `Int` to `Word`, as we do not have negative optimization
      levels.
      
      Reviewers: erikd, hvr, austin, rwbarton, bgamari, kavon
      
      Reviewed By: kavon
      
      Subscribers: michalt, Ericson2314, ryantrinkle, dfeuer, carter, simonpj,
      kavon, simonmar, thomie, erikd, snowleopard
      
      Differential Revision: https://phabricator.haskell.org/D3352
      22733532
  37. 05 Sep, 2017 1 commit