Skip to content
Snippets Groups Projects
  1. Dec 24, 2023
    • Ben Bellick's avatar
      Deprecate -ddump-json and introduce -fdiagnostics-as-json · dfd670a0
      Ben Bellick authored and Marge Bot's avatar Marge Bot committed
      Addresses #19278
      
      This commit deprecates the underspecified -ddump-json flag and
      introduces a newer, well-specified flag -fdiagnostics-as-json.
      
      Also included is a JSON schema as part of the documentation.
      
      The -ddump-json flag will be slated for removal shortly after this merge.
      dfd670a0
  2. Dec 13, 2023
  3. Nov 27, 2023
    • Matthew Pickering's avatar
      testsuite: Add mechanism to collect generic metrics · b5213542
      Matthew Pickering authored and Marge Bot's avatar Marge Bot committed
      * Generalise the metric logic by adding an additional field which
        allows you to specify how to query for the actual value. Previously
        the method of querying the baseline value was abstracted (but always
        set to the same thing).
      
      * This requires rejigging how the stat collection works slightly but now
        it's more uniform and hopefully simpler.
      
      * Introduce some new "generic" helper functions for writing generic
        stats tests.
      
        - collect_size ( deviation, path )
          Record the size of the file as a metric
      
        - stat_from_file ( metric, deviation, path )
          Read a value from the given path, and store that as a metric
      
        - collect_generic_stat ( metric, deviation, get_stat)
          Provide your own `get_stat` function, `lambda way: <Int>`, which
          can be used to establish the current value of the metric.
      
        - collect_generic_stats ( metric_info ):
          Like collect_generic_stat but provide the whole dictionary of metric
          definitions.
      
          { metric: {
              deviation: <Int>
              current: lambda way: <Int>
              } }
      
      * Introduce two new "size" metrics for keeping track of build products.
          - `size_hello_obj` - The size of `hello.o` from compiling hello.hs
          - `libdir` - The total size of the `libdir` folder.
      
      * Track the number of modules in the AST tests
         - CountDepsAst
         - CountDepsParser
      
      This lays the infrastructure for #24191 #22256 #17129
      b5213542
  4. Jul 05, 2023
    • Jaro Reinders's avatar
      Refactor Unique to be represented by Word64 · 9edcb1fb
      Jaro Reinders authored and Marge Bot's avatar Marge Bot committed
      In #22010 we established that Int was not always sufficient to store all
      the uniques we generate during compilation on 32-bit platforms. This
      commit addresses that problem by using Word64 instead of Int for
      uniques.
      
      The core of the change is in GHC.Core.Types.Unique and
      GHC.Core.Types.Unique.Supply. However, the representation of uniques is
      used in many other places, so those needed changes too. Additionally, the RTS
      has been extended with an atomic_inc64 operation.
      
      One major change from this commit is the introduction of the Word64Set and
      Word64Map data types. These are adapted versions of IntSet and IntMap
      from the containers package. These are planned to be upstreamed in the
      future.
      
      As a natural consequence of these changes, the compiler will be a bit
      slower and take more space on 32-bit platforms. Our CI tests indicate
      around a 5% residency increase.
      
      Metric Increase:
          CoOpt_Read
          CoOpt_Singletons
          LargeRecord
          ManyAlternatives
          ManyConstructors
          MultiComponentModules
          MultiComponentModulesRecomp
          MultiLayerModulesTH_OneShot
          RecordUpdPerf
          T10421
          T10547
          T12150
          T12227
          T12234
          T12425
          T12707
          T13035
          T13056
          T13253
          T13253-spj
          T13379
          T13386
          T13719
          T14683
          T14697
          T14766
          T15164
          T15703
          T16577
          T16875
          T17516
          T18140
          T18223
          T18282
          T18304
          T18698a
          T18698b
          T18923
          T1969
          T19695
          T20049
          T21839c
          T3064
          T3294
          T4801
          T5030
          T5321FD
          T5321Fun
          T5631
          T5642
          T5837
          T6048
          T783
          T8095
          T9020
          T9198
          T9233
          T9630
          T9675
          T9872a
          T9872b
          T9872b_defer
          T9872c
          T9872d
          T9961
          TcPlugin_RewritePerf
          UniqLoop
          WWRec
          hard_hole_fits
      9edcb1fb
  5. Jun 05, 2023
    • Matthew Pickering's avatar
      testsuite: Accept new output for CountDepsAst and CountDepsParser tests · 698d160c
      Matthew Pickering authored
      These are in a separate commit as the improvement to these tests is the
      cumulative effect of the previous set of patches rather than just the
      responsibility of the last one in the patchset.
      698d160c
    • Matthew Pickering's avatar
      Big TcLclEnv and CtLoc refactoring · 7cd8a61e
      Matthew Pickering authored
      The overall goal of this refactoring is to reduce the dependency
      footprint of the parser and syntax tree. Good reasons include:
      
      - Better module graph parallelisability
      - Make it easier to migrate error messages without introducing module loops
      - Philosophically, there's not reason for the AST to depend on half the
        compiler.
      
      One of the key edges which added this dependency was
      
      > GHC.Hs.Expr -> GHC.Tc.Types (TcLclEnv)
      
      As this in turn depending on TcM which depends on HscEnv and so on.
      
      Therefore the goal of this patch is to move `TcLclEnv` out of
      `GHC.Tc.Types` so that `GHC.Hs.Expr` can import TcLclEnv without
      incurring a huge dependency chain.
      
      The changes in this patch are:
      
      * Move TcLclEnv from GHC.Tc.Types to GHC.Tc.Types.LclEnv
      * Create new smaller modules for the types used in TcLclEnv
        New Modules:
        - GHC.Tc.Types.ErrCtxt
        - GHC.Tc.Types.BasicTypes
        - GHC.Tc.Types.TH
        - GHC.Tc.Types.LclEnv
        - GHC.Tc.Types.CtLocEnv
        - GHC.Tc.Errors.Types.PromotionErr
      
        Removed Boot File:
        - {-# SOURCE #-} GHC.Tc.Types
      
      * Introduce TcLclCtxt, the part of the TcLclEnv which doesn't
        participate in restoreLclEnv.
      
      * Replace TcLclEnv in CtLoc with specific CtLocEnv which is defined in
        GHC.Tc.Types.CtLocEnv. Use CtLocEnv in Implic and CtLoc to record the
        location of the implication and constraint.
      
      By splitting up TcLclEnv from GHC.Tc.Types we allow GHC.Hs.Expr to no
      longer depend on the TcM monad and all that entails.
      
      Fixes #23389 #23409
      7cd8a61e
  6. May 31, 2023
    • sheaf's avatar
      Restructure the zonker · f62d8195
      sheaf authored and Marge Bot's avatar Marge Bot committed
      This commit splits up the zonker into a few separate components, described
      in Note [The structure of the zonker] in `GHC.Tc.Zonk.Type`.
      
      1. `GHC.Tc.Zonk.Monad` introduces a pared-down `TcM` monad, `ZonkM`,
           which has enough information for zonking types.
           This allows us to refactor `ErrCtxt` to use `ZonkM` instead of `TcM`,
           which guarantees we don't throw an error while reporting an error.
      
      2. `GHC.Tc.Zonk.Env` is the new home of `ZonkEnv`, and also defines
          two zonking monad transformers, `ZonkT` and `ZonkBndrT`.
          `ZonkT` is a reader monad transformer over `ZonkEnv`.
          `ZonkBndrT m` is the codensity monad over `ZonkT m`.
      
           `ZonkBndrT` is used for computations that accumulate binders
           in the `ZonkEnv`.
      
      3. `GHC.Tc.Zonk.TcType` contains the code for zonking types, for use
          in the typechecker. It uses the `ZonkM` monad.
      
      4. `GHC.Tc.Zonk.Type` contains the code for final zonking to `Type`,
          which has been refactored to use `ZonkTcM = ZonkT TcM` and
          `ZonkBndrTcM = ZonkBndrT TcM`.
      
      Allocations slightly decrease on the whole due to using
      continuation-passing style instead of manual state passing of ZonkEnv
      in the final zonking to Type.
      
      -------------------------
      Metric Decrease:
          T4029
          T8095
          T14766
          T15304
          hard_hole_fits
          RecordUpdPerf
      Metric Increase:
          T10421
      -------------------------
      f62d8195
    • sheaf's avatar
      Introduce Codensity monad · 88cc19b3
      sheaf authored and Marge Bot's avatar Marge Bot committed
      The Codensity monad is useful to write state-passing computations in
      continuation-passing style, e.g. to implement a State monad as
      continuation-passing style over a Reader monad.
      88cc19b3
    • sheaf's avatar
      Split off TcRef into its own module · 09d4d307
      sheaf authored and Marge Bot's avatar Marge Bot committed
      This helps avoid pull in the full TcM monad when we just want access
      to mutable references in the typechecker. This facilitates later patches
      which introduce a slimmed down TcM monad for zonking.
      09d4d307
    • sheaf's avatar
      Split off TcBinderStack into its own module · 5366cd35
      sheaf authored and Marge Bot's avatar Marge Bot committed
      This commit splits off TcBinderStack into its own module,
      to avoid module cycles: we might want to refer to it without also
      pulling in the TcM monad.
      5366cd35
  7. May 27, 2023
  8. May 15, 2023
    • sheaf's avatar
      Migrate errors to diagnostics in GHC.Tc.Module · 4d29ecdf
      sheaf authored and Marge Bot's avatar Marge Bot committed
      This commit migrates the errors in GHC.Tc.Module to use the new
      diagnostic infrastructure.
      
      It required a significant overhaul of the compatibility checks between
      an hs-boot or signature module and its implementation; we now use
      a Writer monad to accumulate errors; see the BootMismatch datatype
      in GHC.Tc.Errors.Types, with its panoply of subtypes.
      For the sake of readability, several local functions inside the
      'checkBootTyCon' function were split off into top-level functions.
      
      We split off GHC.Types.HscSource into a "boot or sig" vs "normal hs file"
      datatype, as this mirrors the logic in several other places where we
      want to treat hs-boot and hsig files in a similar fashion.
      
      This commit also refactors the Backpack checks for type synonyms
      implementing abstract data, to correctly reject implementations that
      contain qualified or quantified types (this fixes #23342 and #23344).
      4d29ecdf
    • sheaf's avatar
      Split up tyThingToIfaceDecl from GHC.Iface.Make · d69cbd78
      sheaf authored and Marge Bot's avatar Marge Bot committed
      This commit moves tyThingToIfaceDecl and coAxiomToIfaceDecl
      from GHC.Iface.Make into GHC.Iface.Decl.
      This avoids GHC.Types.TyThing.Ppr, which needs tyThingToIfaceDecl,
      transitively depending on e.g. GHC.Iface.Load and GHC.Tc.Utils.Monad.
      d69cbd78
    • Oleg Grenrus's avatar
      Split DynFlags structure into own module · 86aae570
      Oleg Grenrus authored and Marge Bot's avatar Marge Bot committed
      This will allow to make command line parsing to depend on
      diagnostic system (which depends on dynflags)
      86aae570
  9. Apr 18, 2023
    • Matthew Pickering's avatar
      Convert interface file loading errors into proper diagnostics · 5e1d33d7
      Matthew Pickering authored and Marge Bot's avatar Marge Bot committed
      This patch converts all the errors to do with loading interface files
      into proper structured diagnostics.
      
      * DriverMessage: Sometimes in the driver we attempt to load an interface
        file so we embed the IfaceMessage into the DriverMessage.
      * TcRnMessage: Most the time we are loading interface files during
        typechecking, so we embed the IfaceMessage
      
      This patch also removes the TcRnInterfaceLookupError constructor which
      is superceded by the IfaceMessage, which is now structured compared to
      just storing an SDoc before.
      5e1d33d7
  10. Mar 29, 2023
    • sheaf's avatar
      Handle records in the renamer · 3f374399
      sheaf authored
      This patch moves the field-based logic for disambiguating record updates
      to the renamer. The type-directed logic, scheduled for removal, remains
      in the typechecker.
      
      To do this properly (and fix the myriad of bugs surrounding the treatment
      of duplicate record fields), we took the following main steps:
      
        1. Create GREInfo, a renamer-level equivalent to TyThing which stores
           information pertinent to the renamer.
           This allows us to uniformly treat imported and local Names in the
           renamer, as described in Note [GREInfo].
      
        2. Remove GreName. Instead of a GlobalRdrElt storing GreNames, which
           distinguished between normal names and field names, we now store
           simple Names in GlobalRdrElt, along with the new GREInfo information
           which allows us to recover the FieldLabel for record fields.
      
        3. Add namespacing for record fields, within the OccNames themselves.
           This allows us to remove the mangling of duplicate field selectors.
      
           This change ensures we don't print mangled names to the user in
           error messages, and allows us to handle duplicate record fields
           in Template Haskell.
      
        4. Move record disambiguation to the renamer, and operate on the
           level of data constructors instead, to handle #21443.
      
           The error message text for ambiguous record updates has also been
           changed to reflect that type-directed disambiguation is on the way
           out.
      
      (3) means that OccEnv is now a bit more complex: we first key on the
      textual name, which gives an inner map keyed on NameSpace:
      
        OccEnv a ~ FastStringEnv (UniqFM NameSpace a)
      
      Note that this change, along with (2), both increase the memory residency
      of GlobalRdrEnv = OccEnv [GlobalRdrElt], which causes a few tests to
      regress somewhat in compile-time allocation.
      
      Even though (3) simplified a lot of code (in particular the treatment of
      field selectors within Template Haskell and in error messages), it came
      with one important wrinkle: in the situation of
      
        -- M.hs-boot
        module M where { data A; foo :: A -> Int }
        -- M.hs
        module M where { data A = MkA { foo :: Int } }
      
      we have that M.hs-boot exports a variable foo, which is supposed to match
      with the record field foo that M exports. To solve this issue, we add a
      new impedance-matching binding to M
      
        foo{var} = foo{fld}
      
      This mimics the logic that existed already for impedance-binding DFunIds,
      but getting it right was a bit tricky.
      See Note [Record field impedance matching] in GHC.Tc.Module.
      
      We also needed to be careful to avoid introducing space leaks in GHCi.
      So we dehydrate the GlobalRdrEnv before storing it anywhere, e.g. in
      ModIface. This means stubbing out all the GREInfo fields, with the
      function forceGlobalRdrEnv.
      When we read it back in, we rehydrate with rehydrateGlobalRdrEnv.
      This robustly avoids any space leaks caused by retaining old type
      environments.
      
      Fixes #13352 #14848 #17381 #17551 #19664 #21443 #21444 #21720 #21898 #21946 #21959 #22125 #22160 #23010 #23062 #23063
      
      Updates haddock submodule
      
      -------------------------
      Metric Increase:
          MultiComponentModules
          MultiLayerModules
          MultiLayerModulesDefsGhci
          MultiLayerModulesNoCode
          T13701
          T14697
          hard_hole_fits
      -------------------------
      3f374399
  11. Feb 21, 2023
    • Georgi Lyubenov's avatar
      GHC proposal 496 - Nullary record wildcards · 172ff88f
      Georgi Lyubenov authored and Marge Bot's avatar Marge Bot committed
      This patch implements GHC proposal 496, which allows record wildcards
      to be used for nullary constructors, e.g.
      
        data A = MkA1 | MkA2 { fld1 :: Int }
        f :: A -> Int
        f (MkA1 {..}) = 0
        f (MkA2 {..}) = fld1
      
      To achieve this, we add arity information to the record field
      environment, so that we can accept a constructor which has no fields
      while continuing to reject non-record constructors with more than 1
      field. See Note [Nullary constructors and empty record wildcards],
      as well as the more general overview in Note [Local constructor info in the renamer],
      both in the newly introduced GHC.Types.ConInfo module.
      
      Fixes #22161
      172ff88f
  12. Jan 28, 2023
    • Simon Peyton Jones's avatar
      Avoid orphans in STG · faa300fb
      Simon Peyton Jones authored and Marge Bot's avatar Marge Bot committed
      This patch removes some orphan instances in the STG namespace
      by introducing the GHC.Stg.Lift.Types module, which allows various
      type family instances to be moved to GHC.Stg.Syntax, avoiding orphan
      instances.
      faa300fb
  13. Jan 17, 2023
  14. Dec 09, 2022
  15. Nov 11, 2022
    • Simon Peyton Jones's avatar
      Type vs Constraint: finally nailed · 778c6adc
      Simon Peyton Jones authored and Simon Peyton Jones's avatar Simon Peyton Jones committed
      This big patch addresses the rats-nest of issues that have plagued
      us for years, about the relationship between Type and Constraint.
      See #11715/#21623.
      
      The main payload of the patch is:
      * To introduce CONSTRAINT :: RuntimeRep -> Type
      * To make TYPE and CONSTRAINT distinct throughout the compiler
      
      Two overview Notes in GHC.Builtin.Types.Prim
      
      * Note [TYPE and CONSTRAINT]
      
      * Note [Type and Constraint are not apart]
        This is the main complication.
      
      The specifics
      
      * New primitive types (GHC.Builtin.Types.Prim)
        - CONSTRAINT
        - ctArrowTyCon (=>)
        - tcArrowTyCon (-=>)
        - ccArrowTyCon (==>)
        - funTyCon     FUN     -- Not new
        See Note [Function type constructors and FunTy]
        and Note [TYPE and CONSTRAINT]
      
      * GHC.Builtin.Types:
        - New type Constraint = CONSTRAINT LiftedRep
        - I also stopped nonEmptyTyCon being built-in; it only needs to be wired-in
      
      * Exploit the fact that Type and Constraint are distinct throughout GHC
        - Get rid of tcView in favour of coreView.
        - Many tcXX functions become XX functions.
          e.g. tcGetCastedTyVar --> getCastedTyVar
      
      * Kill off Note [ForAllTy and typechecker equality], in (old)
        GHC.Tc.Solver.Canonical.  It said that typechecker-equality should ignore
        the specified/inferred distinction when comparein two ForAllTys.  But
        that wsa only weakly supported and (worse) implies that we need a separate
        typechecker equality, different from core equality. No no no.
      
      * GHC.Core.TyCon: kill off FunTyCon in data TyCon.  There was no need for it,
        and anyway now we have four of them!
      
      * GHC.Core.TyCo.Rep: add two FunTyFlags to FunCo
        See Note [FunCo] in that module.
      
      * GHC.Core.Type.  Lots and lots of changes driven by adding CONSTRAINT.
        The key new function is sORTKind_maybe; most other changes are built
        on top of that.
      
        See also `funTyConAppTy_maybe` and `tyConAppFun_maybe`.
      
      * Fix a longstanding bug in GHC.Core.Type.typeKind, and Core Lint, in
        kinding ForAllTys.  See new tules (FORALL1) and (FORALL2) in GHC.Core.Type.
        (The bug was that before (forall (cv::t1 ~# t2). blah), where
        blah::TYPE IntRep, would get kind (TYPE IntRep), but it should be
        (TYPE LiftedRep).  See Note [Kinding rules for types] in GHC.Core.Type.
      
      * GHC.Core.TyCo.Compare is a new module in which we do eqType and cmpType.
        Of course, no tcEqType any more.
      
      * GHC.Core.TyCo.FVs. I moved some free-var-like function into this module:
        tyConsOfType, visVarsOfType, and occCheckExpand.  Refactoring only.
      
      * GHC.Builtin.Types.  Compiletely re-engineer boxingDataCon_maybe to
        have one for each /RuntimeRep/, rather than one for each /Type/.
        This dramatically widens the range of types we can auto-box.
        See Note [Boxing constructors] in GHC.Builtin.Types
        The boxing types themselves are declared in library ghc-prim:GHC.Types.
      
        GHC.Core.Make.  Re-engineer the treatment of "big" tuples (mkBigCoreVarTup
        etc) GHC.Core.Make, so that it auto-boxes unboxed values and (crucially)
        types of kind Constraint. That allows the desugaring for arrows to work;
        it gathers up free variables (including dictionaries) into tuples.
        See  Note [Big tuples] in GHC.Core.Make.
      
        There is still work to do here: #22336. But things are better than
        before.
      
      * GHC.Core.Make.  We need two absent-error Ids, aBSENT_ERROR_ID for types of
        kind Type, and aBSENT_CONSTRAINT_ERROR_ID for vaues of kind Constraint.
        Ditto noInlineId vs noInlieConstraintId in GHC.Types.Id.Make;
        see Note [inlineId magic].
      
      * GHC.Core.TyCo.Rep. Completely refactor the NthCo coercion.  It is now called
        SelCo, and its fields are much more descriptive than the single Int we used to
        have.  A great improvement.  See Note [SelCo] in GHC.Core.TyCo.Rep.
      
      * GHC.Core.RoughMap.roughMatchTyConName.  Collapse TYPE and CONSTRAINT to
        a single TyCon, so that the rough-map does not distinguish them.
      
      * GHC.Core.DataCon
        - Mainly just improve documentation
      
      * Some significant renamings:
        GHC.Core.Multiplicity: Many -->  ManyTy (easier to grep for)
                               One  -->  OneTy
        GHC.Core.TyCo.Rep TyCoBinder      -->   GHC.Core.Var.PiTyBinder
        GHC.Core.Var      TyCoVarBinder   -->   ForAllTyBinder
                          AnonArgFlag     -->   FunTyFlag
                          ArgFlag         -->   ForAllTyFlag
        GHC.Core.TyCon    TyConTyCoBinder --> TyConPiTyBinder
        Many functions are renamed in consequence
        e.g. isinvisibleArgFlag becomes isInvisibleForAllTyFlag, etc
      
      * I refactored FunTyFlag (was AnonArgFlag) into a simple, flat data type
          data FunTyFlag
            = FTF_T_T           -- (->)  Type -> Type
            | FTF_T_C           -- (-=>) Type -> Constraint
            | FTF_C_T           -- (=>)  Constraint -> Type
            | FTF_C_C           -- (==>) Constraint -> Constraint
      
      * GHC.Tc.Errors.Ppr.  Some significant refactoring in the TypeEqMisMatch case
        of pprMismatchMsg.
      
      * I made the tyConUnique field of TyCon strict, because I
        saw code with lots of silly eval's.  That revealed that
        GHC.Settings.Constants.mAX_SUM_SIZE can only be 63, because
        we pack the sum tag into a 6-bit field.  (Lurking bug squashed.)
      
      Fixes
      * #21530
      
      Updates haddock submodule slightly.
      
      Performance changes
      ~~~~~~~~~~~~~~~~~~~
      I was worried that compile times would get worse, but after
      some careful profiling we are down to a geometric mean 0.1%
      increase in allocation (in perf/compiler).  That seems fine.
      
      There is a big runtime improvement in T10359
      
      Metric Decrease:
          LargeRecord
          MultiLayerModulesTH_OneShot
          T13386
          T13719
      Metric Increase:
          T8095
      778c6adc
    • Cheng Shao's avatar
      Add support for the wasm32-wasi target tuple · df7bfef8
      Cheng Shao authored and Marge Bot's avatar Marge Bot committed
      This patch adds the wasm32-wasi tuple support to various places in the
      tree: autoconf, hadrian, ghc-boot and also the compiler. The codegen
      logic will come in subsequent commits.
      df7bfef8
  16. Nov 08, 2022
    • M Farkas-Dyck's avatar
      Define `Infinite` list and use where appropriate. · 68f49874
      M Farkas-Dyck authored and Marge Bot's avatar Marge Bot committed
      Also add perf test for infinite list fusion.
      
      In particular, in `GHC.Core`, often we deal with infinite lists of roles. Also in a few locations we deal with infinite lists of names.
      
      Thanks to simonpj for helping to write the Note [Fusion for `Infinite` lists].
      68f49874
  17. Nov 04, 2022
  18. Oct 22, 2022
  19. Oct 11, 2022
    • Matthew Pickering's avatar
      Interface Files with Core Definitions · e058b138
      Matthew Pickering authored and Marge Bot's avatar Marge Bot committed
      This commit adds three new flags
      
      * -fwrite-if-simplified-core: Writes the whole core program into an interface
        file
      * -fbyte-code-and-object-code: Generate both byte code and object code
        when compiling a file
      * -fprefer-byte-code: Prefer to use byte-code if it's available when
        running TH splices.
      
      The goal for including the core bindings in an interface file is to be able to restart the compiler pipeline
      at the point just after simplification and before code generation. Once compilation is
      restarted then code can be created for the byte code backend.
      This can significantly speed up
      start-times for projects in GHCi. HLS already implements its own version of these extended interface
      files for this reason.
      
      Preferring to use byte-code means that we can avoid some potentially
      expensive code generation steps (see #21700)
      
      * Producing object code is much slower than producing bytecode, and normally you
        need to compile with `-dynamic-too` to produce code in the static and dynamic way, the
        dynamic way just for Template Haskell execution when using a dynamically linked compiler.
      
      * Linking many large object files, which happens once per splice, can be quite
        expensive compared to linking bytecode.
      
      And you can get GHC to compile the necessary byte code so
      `-fprefer-byte-code` has access to it by using
      `-fbyte-code-and-object-code`.
      
      Fixes #21067
      e058b138
  20. Sep 28, 2022
    • Andreas Klebinger's avatar
      Apply some tricks to speed up core lint. · c2d73cb4
      Andreas Klebinger authored and Marge Bot's avatar Marge Bot committed
      Below are the noteworthy changes and if given their impact on compiler
      allocations for a type heavy module:
      
      * Use the oneShot trick on LintM
      * Use a unboxed tuple for the result of LintM: ~6% reduction
      * Avoid a thunk for the result of typeKind in lintType: ~5% reduction
      * lint_app: Don't allocate the error msg in the hot code path: ~4%
        reduction
      * lint_app: Eagerly force the in scope set: ~4%
      * nonDetCmpType: Try to short cut using reallyUnsafePtrEquality#: ~2%
      * lintM: Use a unboxed maybe for the `a` result: ~12%
      * lint_app: make go_app tail recursive to avoid allocating the go function
                  as heap closure: ~7%
      * expandSynTyCon_maybe: Use a specialized data type
      
      For a less type heavy module like nofib/spectral/simple compiled with
      -O -dcore-lint allocations went down by ~24% and compile time by ~9%.
      
      -------------------------
      Metric Decrease:
          T1969
      -------------------------
      c2d73cb4
  21. Sep 13, 2022
    • sheaf's avatar
      Diagnostic codes: acccept test changes · 362cca13
      sheaf authored and Marge Bot's avatar Marge Bot committed
      The testsuite output now contains diagnostic codes, so many tests need
      to be updated at once.
      We decided it was best to keep the diagnostic codes in the testsuite
      output, so that contributors don't inadvertently make changes to the
      diagnostic codes.
      362cca13
  22. Aug 10, 2022
    • Sylvain Henry's avatar
      Add support for external static plugins (#20964) · f95bbdca
      Sylvain Henry authored and Marge Bot's avatar Marge Bot committed
      
      This patch adds a new command-line flag:
      
        -fplugin-library=<file-path>;<unit-id>;<module>;<args>
      
      used like this:
      
        -fplugin-library=path/to/plugin.so;package-123;Plugin.Module;["Argument","List"]
      
      It allows a plugin to be loaded directly from a shared library. With
      this approach, GHC doesn't compile anything for the plugin and doesn't
      load any .hi file for the plugin and its dependencies. As such GHC
      doesn't need to support two environments (one for plugins, one for
      target code), which was the more ambitious approach tracked in #14335.
      
      Fix #20964
      
      Co-authored-by: default avatarJosh Meredith <joshmeredith2008@gmail.com>
      f95bbdca
  23. Jul 22, 2022
    • Dominik Peteler's avatar
      Refactored Simplify pass · 9a3e1f31
      Dominik Peteler authored and Marge Bot's avatar Marge Bot committed
       * Removed references to driver from GHC.Core.LateCC, GHC.Core.Simplify
         namespace and GHC.Core.Opt.Stats.
         Also removed services from configuration records.
      
       * Renamed GHC.Core.Opt.Simplify to GHC.Core.Opt.Simplify.Iteration.
      
       * Inlined `simplifyPgm` and renamed `simplifyPgmIO` to `simplifyPgm`
         and moved the Simplify driver to GHC.Core.Opt.Simplify.
      
       * Moved `SimplMode` and `FloatEnable` to GHC.Core.Opt.Simplify.Env.
      
       * Added a configuration record `TopEnvConfig` for the `SimplTopEnv` environment
         in GHC.Core.Opt.Simplify.Monad.
      
       * Added `SimplifyOpts` and `SimplifyExprOpts`. Provide initialization functions
         for those in a new module GHC.Driver.Config.Core.Opt.Simplify.
         Also added initialization functions for `SimplMode` to that module.
      
       * Moved `CoreToDo` and friends to a new module GHC.Core.Pipeline.Types
         and the counting types and functions (`SimplCount` and `Tick`) to new
         module GHC.Core.Opt.Stats.
      
       * Added getter functions for the fields of `SimplMode`. The pedantic bottoms
         option and the platform are retrieved from the ArityOpts and RuleOpts and the
         getter functions allow us to retrieve values from `SpecEnv` without the
         knowledge where the data is stored exactly.
      
       * Moved the coercion optimization options from the top environment to
         `SimplMode`. This way the values left in the top environment are those
         dealing with monadic functionality, namely logging, IO related stuff and
         counting. Added a note "The environments of the Simplify pass".
      
       * Removed `CoreToDo` from GHC.Core.Lint and GHC.CoreToStg.Prep and got rid of
         `CoreDoSimplify`. Pass `SimplifyOpts` in the `CoreToDo` type instead.
      
       * Prep work before removing `InteractiveContext` from `HscEnv`.
      9a3e1f31
  24. Jul 16, 2022
    • Ben Gamari's avatar
      cmm: Eliminate orphan Outputable instances · f1c44991
      Ben Gamari authored and Marge Bot's avatar Marge Bot committed
      Here we reorganize `GHC.Cmm` to eliminate the orphan `Outputable` and
      `OutputableP` instances for the Cmm AST. This makes it significantly
      easier to use the Cmm pretty-printers in tracing output without
      incurring module import cycles.
      f1c44991
  25. Jul 06, 2022
    • Rodrigo Mesquita's avatar
      Remove many GHC dependencies from L.H.S · fd379d1b
      Rodrigo Mesquita authored and Marge Bot's avatar Marge Bot committed
      Continue to prune the `Language.Haskell.Syntax.*` modules out of GHC
      imports according to the plan in the linked issue.
      
      Moves more GHC-specific declarations to `GHC.*` and brings more required
      GHC-independent declarations to `Language.Haskell.Syntax.*` (extending
      e.g. `Language.Haskell.Syntax.Basic`).
      
      Progress towards #21592
      
      Bump haddock submodule for !8308
      
      -------------------------
      Metric Decrease:
          hard_hole_fits
      -------------------------
      fd379d1b
  26. Jul 03, 2022
    • Rodrigo Mesquita's avatar
      Refactor ModuleName to L.H.S.Module.Name · c43dbac0
      Rodrigo Mesquita authored and Marge Bot's avatar Marge Bot committed
      ModuleName used to live in GHC.Unit.Module.Name. In this commit, the
      definition of ModuleName and its associated functions are moved to
      Language.Haskell.Syntax.Module.Name according to the current plan
      towards making the AST GHC-independent.
      
      The instances for ModuleName for Outputable, Uniquable and Binary were
      moved to the module in which the class is defined because these instances
      depend on GHC.
      
      The instance of Eq for ModuleName is slightly changed to no longer
      depend on unique explicitly and instead uses FastString's instance of
      Eq.
      c43dbac0
    • Rodrigo Mesquita's avatar
      TTG: Move ImpExp client-independent bits to L.H.S.ImpExp · f9f80995
      Rodrigo Mesquita authored and Marge Bot's avatar Marge Bot committed
      Move the GHC-independent definitions from GHC.Hs.ImpExp to
      Language.Haskell.Syntax.ImpExp with the required TTG extension fields
      such as to keep the AST independent from GHC.
      
      This is progress towards having the haskell-syntax package, as described
      in #21592
      
      Bumps haddock submodule
      f9f80995
  27. Jun 20, 2022
    • Sebastian Graf's avatar
      CorePrep: Don't speculatively evaluate recursive calls (#20836) · b570da84
      Sebastian Graf authored
      In #20836 we have optimised a terminating program into an endless loop,
      because we speculated the self-recursive call of a recursive DFun.
      Now we track the set of enclosing recursive binders in CorePrep to prevent
      speculation of such self-recursive calls.
      
      See the updates to Note [Speculative evaluation] for details.
      
      Fixes #20836.
      b570da84
  28. Jun 07, 2022
  29. Jun 02, 2022
  30. May 31, 2022
    • John Ericson's avatar
      Purge `DynFlags` and `HscEnv` from some `GHC.Core` modules where it's not too hard · d4c71f09
      John Ericson authored
      Progress towards #17957
      
      Because of `CoreM`, I did not move the `DynFlags` and `HscEnv` to other
      modules as thoroughly as I usually do. This does mean that risk of
      `DynFlags` "creeping back in" is higher than it usually is.
      
      After we do the same process to the other Core passes, and then figure
      out what we want to do about `CoreM`, we can finish the job started
      here.
      
      That is a good deal more work, however, so it certainly makes sense to
      land this now.
      d4c71f09
  31. May 21, 2022
    • Norman Ramsey's avatar
      Change `Backend` type and remove direct dependencies · 4aa3c5bd
      Norman Ramsey authored and Cheng Shao's avatar Cheng Shao committed
      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
      4aa3c5bd
Loading