1. 08 Mar, 2021 1 commit
  2. 03 Mar, 2021 3 commits
    • Matthew Pickering's avatar
      7b9767b8
    • Matthew Pickering's avatar
      Add option to give each usage of a data constructor its own info table · a7aac008
      Matthew Pickering authored
      The `-fdistinct-constructor-tables` flag will generate a fresh info
      table for the usage of any data constructor. This is useful for
      debugging as now by inspecting the info table, you can determine which
      usage of a constructor caused that allocation rather than the old
      situation where the info table always mapped to the definition site of
      the data constructor which is useless.
      
      In conjunction with `-hi` and `-finfo-table-map` this gives a more fine
      grained understanding of where constructor allocations arise from in a
      program.
      a7aac008
    • Matthew Pickering's avatar
      Add -finfo-table-map which maps info tables to source positions · 4b297979
      Matthew Pickering authored
      This new flag embeds a lookup table from the address of an info table
      to information about that info table.
      
      The main interface for consulting the map is the `lookupIPE` C function
      
      > InfoProvEnt * lookupIPE(StgInfoTable *info)
      
      The `InfoProvEnt` has the following structure:
      
      > typedef struct InfoProv_{
      >     char * table_name;
      >     char * closure_desc;
      >     char * ty_desc;
      >     char * label;
      >     char * module;
      >     char * srcloc;
      > } InfoProv;
      >
      > typedef struct InfoProvEnt_ {
      >     StgInfoTable * info;
      >     InfoProv prov;
      >     struct InfoProvEnt_ *link;
      > } InfoProvEnt;
      
      The source positions are approximated in a similar way to the source
      positions for DWARF debugging information. They are only approximate but
      in our experience provide a good enough hint about where the problem
      might be. It is therefore recommended to use this flag in conjunction
      with `-g<n>` for more accurate locations.
      
      The lookup table is also emitted into the eventlog when it is available
      as it is intended to be used with the `-hi` profiling mode.
      
      Using this flag will significantly increase the size of the resulting
      object file but only by a factor of 2-3x in our experience.
      4b297979
  3. 14 Feb, 2021 1 commit
    • Sylvain Henry's avatar
      Refactor Logger · 8e2f85f6
      Sylvain Henry authored
      Before this patch, the only way to override GHC's default logging
      behavior was to set `log_action`, `dump_action` and `trace_action`
      fields in DynFlags. This patch introduces a new Logger abstraction and
      stores it in HscEnv instead.
      
      This is part of #17957 (avoid storing state in DynFlags). DynFlags are
      duplicated and updated per-module (because of OPTIONS_GHC pragma), so
      we shouldn't store global state in them.
      
      This patch also fixes a race in parallel "--make" mode which updated
      the `generatedDumps` IORef concurrently.
      
      Bump haddock submodule
      
      The increase in MultilayerModules is tracked in #19293.
      
      Metric Increase:
          MultiLayerModules
      8e2f85f6
  4. 29 Oct, 2020 1 commit
    • Sylvain Henry's avatar
      Split GHC.Driver.Types · 0e9f6def
      Sylvain Henry authored
      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
  5. 12 Aug, 2020 1 commit
    • Sylvain Henry's avatar
      DynFlags: disentangle Outputable · accbc242
      Sylvain Henry authored
      - put panic related functions into GHC.Utils.Panic
      - put trace related functions using DynFlags in GHC.Driver.Ppr
      
      One step closer making Outputable fully independent of DynFlags.
      
      Bump haddock submodule
      accbc242
  6. 31 Jul, 2020 1 commit
    • Sylvain Henry's avatar
      Refactor CLabel pretty-printing · 56a7c193
      Sylvain Henry authored
      Pretty-printing CLabel relies on sdocWithDynFlags that we want to remove
      (#10143, #17957). It uses it to query the backend and the platform.
      
      This patch exposes Clabel ppr functions specialised for each backend so
      that backend code can directly use them.
      56a7c193
  7. 25 Jul, 2020 1 commit
    • Sylvain Henry's avatar
      Remove platform constant wrappers · 9dfeca6c
      Sylvain Henry authored
      Platform constant wrappers took a DynFlags parameter, hence implicitly
      used the target platform constants. We removed them to allow support
      for several platforms at once (#14335) and to avoid having to pass
      the full DynFlags to every function (#17957).
      
      Metric Decrease:
         T4801
      9dfeca6c
  8. 23 Jul, 2020 2 commits
    • Sylvain Henry's avatar
      Replace HscTarget with Backend · f7cc4313
      Sylvain Henry authored
      They both have the same role and Backend name is more explicit.
      
      Metric Decrease:
          T3064
      
      Update Haddock submodule
      f7cc4313
    • Sylvain Henry's avatar
      Correctly test active backend · e079bb72
      Sylvain Henry authored
      Previously we used a platform settings to detect if the native code
      generator was used. This was wrong. We need to use the
      `DynFlags.hscTarget` field instead.
      e079bb72
  9. 17 Jun, 2020 1 commit
    • Krzysztof Gogolewski's avatar
      Linear types (#15981) · 40fa237e
      Krzysztof Gogolewski authored
      This is the first step towards implementation of the linear types proposal
      (https://github.com/ghc-proposals/ghc-proposals/pull/111).
      
      It features
      
      * A language extension -XLinearTypes
      * Syntax for linear functions in the surface language
      * Linearity checking in Core Lint, enabled with -dlinear-core-lint
      * Core-to-core passes are mostly compatible with linearity
      * Fields in a data type can be linear or unrestricted; linear fields
        have multiplicity-polymorphic constructors.
        If -XLinearTypes is disabled, the GADT syntax defaults to linear fields
      
      The following items are not yet supported:
      
      * a # m -> b syntax (only prefix FUN is supported for now)
      * Full multiplicity inference (multiplicities are really only checked)
      * Decent linearity error messages
      * Linear let, where, and case expressions in the surface language
        (each of these currently introduce the unrestricted variant)
      * Multiplicity-parametric fields
      * Syntax for annotating lambda-bound or let-bound with a multiplicity
      * Syntax for non-linear/multiple-field-multiplicity records
      * Linear projections for records with a single linear field
      * Linear pattern synonyms
      * Multiplicity coercions (test LinearPolyType)
      
      A high-level description can be found at
      https://ghc.haskell.org/trac/ghc/wiki/LinearTypes/Implementation
      Following the link above you will find a description of the changes made to Core.
      This commit has been authored by
      
      * Richard Eisenberg
      * Krzysztof Gogolewski
      * Matthew Pickering
      * Arnaud Spiwack
      
      With contributions from:
      
      * Mark Barbone
      * Alexander Vershilov
      
      Updates haddock submodule.
      40fa237e
  10. 10 Jun, 2020 1 commit
    • Ömer Sinan Ağacan's avatar
      Cross-module LambdaFormInfo passing · 7a737e89
      Ömer Sinan Ağacan authored
      - Store LambdaFormInfos of exported Ids in interface files
      - Use them in importing modules
      
      This is for optimization purposes: if we know LambdaFormInfo of imported
      Ids we can generate more efficient calling code, see `getCallMethod`.
      
      Exporting (putting them in interface files or in ModDetails) and
      importing (reading them from interface files) are both optional. We
      don't assume known LambdaFormInfos anywhere and do not change how we
      call Ids with unknown LambdaFormInfos.
      
      Runtime, allocation, and residency numbers when building
      Cabal-the-library (commit 0d4ee7ba3):
      
      (Log and .hp files are in the MR: !2842)
      
      |     | GHC HEAD | This patch | Diff           |
      |-----|----------|------------|----------------|
      | -O0 |  0:35.89 |    0:34.10 | -1.78s, -4.98% |
      | -O1 |  2:24.01 |    2:23.62 | -0.39s, -0.27% |
      | -O2 |  2:52.23 |    2:51.35 | -0.88s, -0.51% |
      
      |     | GHC HEAD        | This patch      | Diff                       |
      |-----|-----------------|-----------------|----------------------------|
      | -O0 |  54,843,608,416 |  54,878,769,544 |  +35,161,128 bytes, +0.06% |
      | -O1 | 227,136,076,400 | 227,569,045,168 | +432,968,768 bytes, +0.19% |
      | -O2 | 266,147,063,296 | 266,749,643,440 | +602,580,144 bytes, +0.22% |
      
      NOTE: Residency is measured with extra runtime args: `-i0 -h` which effectively
      turn all GCs into major GCs, and do GC more often.
      
      |     | GHC HEAD                   | This patch                   | Diff                       |
      |-----|----------------------------|------------------------------|----------------------------|
      | -O0 | 410,284,000 (910 samples)  | 411,745,008 (906 samples)    | +1,461,008 bytes, +0.35%   |
      | -O1 | 928,580,856 (2109 samples) | 943,506,552 (2103 samples)   | +14,925,696 bytes, +1.60%  |
      | -O2 | 993,951,352 (2549 samples) | 1,010,156,328 (2545 samples) | +16,204,9760 bytes, +1.63% |
      
      NoFib results:
      
      --------------------------------------------------------------------------------
              Program           Size    Allocs    Instrs     Reads    Writes
      --------------------------------------------------------------------------------
                   CS           0.0%      0.0%     +0.0%     +0.0%     +0.0%
                  CSD           0.0%      0.0%      0.0%     +0.0%     +0.0%
                   FS           0.0%      0.0%     +0.0%     +0.0%     +0.0%
                    S           0.0%      0.0%     +0.0%     +0.0%     +0.0%
                   VS           0.0%      0.0%     +0.0%     +0.0%     +0.0%
                  VSD           0.0%      0.0%     +0.0%     +0.0%     +0.1%
                  VSM           0.0%      0.0%     +0.0%     +0.0%     +0.0%
                 anna           0.0%      0.0%     -0.3%     -0.8%     -0.0%
                 ansi           0.0%      0.0%     -0.0%     -0.0%      0.0%
                 atom           0.0%      0.0%     -0.0%     -0.0%      0.0%
               awards           0.0%      0.0%     -0.1%     -0.3%      0.0%
               banner           0.0%      0.0%     -0.0%     -0.0%     -0.0%
           bernouilli           0.0%      0.0%     -0.0%     -0.0%     -0.0%
         binary-trees           0.0%      0.0%     -0.0%     -0.0%     +0.0%
                boyer           0.0%      0.0%     -0.0%     -0.0%      0.0%
               boyer2           0.0%      0.0%     -0.0%     -0.0%      0.0%
                 bspt           0.0%      0.0%     -0.0%     -0.2%      0.0%
            cacheprof           0.0%      0.0%     -0.1%     -0.4%     +0.0%
             calendar           0.0%      0.0%     -0.0%     -0.0%      0.0%
             cichelli           0.0%      0.0%     -0.9%     -2.4%      0.0%
              circsim           0.0%      0.0%     -0.0%     -0.0%      0.0%
             clausify           0.0%      0.0%     -0.1%     -0.3%      0.0%
        comp_lab_zift           0.0%      0.0%     -0.0%     -0.0%     +0.0%
             compress           0.0%      0.0%     -0.0%     -0.0%     -0.0%
            compress2           0.0%      0.0%     -0.0%     -0.0%      0.0%
          constraints           0.0%      0.0%     -0.1%     -0.2%     -0.0%
         cryptarithm1           0.0%      0.0%     -0.0%     -0.0%      0.0%
         cryptarithm2           0.0%      0.0%     -1.4%     -4.1%     -0.0%
                  cse           0.0%      0.0%     -0.0%     -0.0%     -0.0%
         digits-of-e1           0.0%      0.0%     -0.0%     -0.0%     -0.0%
         digits-of-e2           0.0%      0.0%     -0.0%     -0.0%     -0.0%
               dom-lt           0.0%      0.0%     -0.1%     -0.2%      0.0%
                eliza           0.0%      0.0%     -0.5%     -1.5%      0.0%
                event           0.0%      0.0%     -0.0%     -0.0%     -0.0%
          exact-reals           0.0%      0.0%     -0.1%     -0.3%     +0.0%
               exp3_8           0.0%      0.0%     -0.0%     -0.0%     -0.0%
               expert           0.0%      0.0%     -0.3%     -1.0%     -0.0%
       fannkuch-redux           0.0%      0.0%     +0.0%     +0.0%     +0.0%
                fasta           0.0%      0.0%     -0.0%     -0.0%     +0.0%
                  fem           0.0%      0.0%     -0.0%     -0.0%      0.0%
                  fft           0.0%      0.0%     -0.0%     -0.0%      0.0%
                 fft2           0.0%      0.0%     -0.0%     -0.0%      0.0%
             fibheaps           0.0%      0.0%     -0.0%     -0.0%     +0.0%
                 fish           0.0%      0.0%      0.0%     -0.0%     +0.0%
                fluid           0.0%      0.0%     -0.4%     -1.2%     +0.0%
               fulsom           0.0%      0.0%     -0.0%     -0.0%      0.0%
               gamteb           0.0%      0.0%     -0.1%     -0.3%      0.0%
                  gcd           0.0%      0.0%     -0.0%     -0.0%      0.0%
          gen_regexps           0.0%      0.0%     -0.0%     -0.0%     -0.0%
               genfft           0.0%      0.0%     -0.0%     -0.0%      0.0%
                   gg           0.0%      0.0%     -0.0%     -0.0%     +0.0%
                 grep           0.0%      0.0%     -0.0%     -0.0%     -0.0%
               hidden           0.0%      0.0%     -0.1%     -0.4%     -0.0%
                  hpg           0.0%      0.0%     -0.2%     -0.5%     +0.0%
                  ida           0.0%      0.0%     -0.0%     -0.0%     +0.0%
                infer           0.0%      0.0%     -0.3%     -0.8%     -0.0%
              integer           0.0%      0.0%     -0.0%     -0.0%     +0.0%
            integrate           0.0%      0.0%     -0.0%     -0.0%      0.0%
         k-nucleotide           0.0%      0.0%     -0.0%     -0.0%     +0.0%
                kahan           0.0%      0.0%     -0.0%     -0.0%     +0.0%
              knights           0.0%      0.0%     -2.2%     -5.4%      0.0%
               lambda           0.0%      0.0%     -0.6%     -1.8%      0.0%
           last-piece           0.0%      0.0%     -0.0%     -0.0%      0.0%
                 lcss           0.0%      0.0%     -0.0%     -0.1%      0.0%
                 life           0.0%      0.0%     -0.0%     -0.1%      0.0%
                 lift           0.0%      0.0%     -0.2%     -0.6%     +0.0%
               linear           0.0%      0.0%     -0.0%     -0.0%     -0.0%
            listcompr           0.0%      0.0%     -0.0%     -0.0%      0.0%
             listcopy           0.0%      0.0%     -0.0%     -0.0%      0.0%
             maillist           0.0%      0.0%     -0.1%     -0.3%     +0.0%
               mandel           0.0%      0.0%     -0.0%     -0.0%      0.0%
              mandel2           0.0%      0.0%     -0.0%     -0.0%     -0.0%
                 mate          +0.0%      0.0%     -0.0%     -0.0%     -0.0%
              minimax           0.0%      0.0%     -0.2%     -1.0%      0.0%
              mkhprog           0.0%      0.0%     -0.1%     -0.2%     -0.0%
           multiplier           0.0%      0.0%     -0.0%     -0.0%     -0.0%
               n-body           0.0%      0.0%     -0.0%     -0.0%     +0.0%
             nucleic2           0.0%      0.0%     -0.1%     -0.2%      0.0%
                 para           0.0%      0.0%     -0.0%     -0.0%     -0.0%
            paraffins           0.0%      0.0%     -0.0%     -0.0%      0.0%
               parser           0.0%      0.0%     -0.2%     -0.7%      0.0%
              parstof           0.0%      0.0%     -0.0%     -0.0%     +0.0%
                  pic           0.0%      0.0%     -0.0%     -0.0%      0.0%
             pidigits           0.0%      0.0%     +0.0%     +0.0%     +0.0%
                power           0.0%      0.0%     -0.2%     -0.6%     +0.0%
               pretty           0.0%      0.0%     -0.0%     -0.0%     -0.0%
               primes           0.0%      0.0%     -0.0%     -0.0%      0.0%
            primetest           0.0%      0.0%     -0.0%     -0.0%     -0.0%
               prolog           0.0%      0.0%     -0.3%     -1.1%      0.0%
               puzzle           0.0%      0.0%     -0.0%     -0.0%      0.0%
               queens           0.0%      0.0%     -0.0%     -0.0%     +0.0%
              reptile           0.0%      0.0%     -0.0%     -0.0%      0.0%
      reverse-complem           0.0%      0.0%     -0.0%     -0.0%     +0.0%
              rewrite           0.0%      0.0%     -0.7%     -2.5%     -0.0%
                 rfib           0.0%      0.0%     -0.0%     -0.0%      0.0%
                  rsa           0.0%      0.0%     -0.0%     -0.0%      0.0%
                  scc           0.0%      0.0%     -0.1%     -0.2%     -0.0%
                sched           0.0%      0.0%     -0.0%     -0.0%     -0.0%
                  scs           0.0%      0.0%     -1.0%     -2.6%     +0.0%
               simple           0.0%      0.0%     +0.0%     -0.0%     +0.0%
                solid           0.0%      0.0%     -0.0%     -0.0%      0.0%
              sorting           0.0%      0.0%     -0.6%     -1.6%      0.0%
        spectral-norm           0.0%      0.0%     +0.0%      0.0%     +0.0%
               sphere           0.0%      0.0%     -0.0%     -0.0%     -0.0%
               symalg           0.0%      0.0%     -0.0%     -0.0%     +0.0%
                  tak           0.0%      0.0%     -0.0%     -0.0%      0.0%
            transform           0.0%      0.0%     -0.0%     -0.0%      0.0%
             treejoin           0.0%      0.0%     -0.0%     -0.0%      0.0%
            typecheck           0.0%      0.0%     -0.0%     -0.0%     +0.0%
              veritas          +0.0%      0.0%     -0.2%     -0.4%     +0.0%
                 wang           0.0%      0.0%     -0.0%     -0.0%      0.0%
            wave4main           0.0%      0.0%     -0.0%     -0.0%     -0.0%
         wheel-sieve1           0.0%      0.0%     -0.0%     -0.0%     -0.0%
         wheel-sieve2           0.0%      0.0%     -0.0%     -0.0%     +0.0%
                 x2n1           0.0%      0.0%     -0.0%     -0.0%     -0.0%
      --------------------------------------------------------------------------------
                  Min           0.0%      0.0%     -2.2%     -5.4%     -0.0%
                  Max          +0.0%      0.0%     +0.0%     +0.0%     +0.1%
       Geometric Mean          -0.0%     -0.0%     -0.1%     -0.3%     +0.0%
      
      Metric increases micro benchmarks tracked in #17686:
      
      Metric Increase:
          T12150
          T12234
          T12425
          T13035
          T5837
          T6048
          T9233
      Co-authored-by: Andreas Klebinger's avatarAndreas Klebinger <klebinger.andreas@gmx.at>
      7a737e89
  11. 30 Apr, 2020 1 commit
  12. 26 Apr, 2020 1 commit
  13. 18 Apr, 2020 1 commit
    • Sylvain Henry's avatar
      Modules (#13009) · 15312bbb
      Sylvain Henry authored
      * SysTools
      * Parser
      * GHC.Builtin
      * GHC.Iface.Recomp
      * Settings
      
      Update Haddock submodule
      
      Metric Decrease:
          Naperian
          parsing001
      15312bbb
  14. 03 Apr, 2020 2 commits
    • Sylvain Henry's avatar
      Refactor CmmStatics · cc2918a0
      Sylvain Henry authored
      In !2959 we noticed that there was some redundant code (in GHC.Cmm.Utils
      and GHC.Cmm.StgToCmm.Utils) used to deal with `CmmStatics` datatype
      (before SRT generation) and `RawCmmStatics` datatype (after SRT
      generation).
      
      This patch removes this redundant code by using a single GADT for
      (Raw)CmmStatics.
      cc2918a0
    • Sylvain Henry's avatar
      Move blob handling into StgToCmm · a485c3c4
      Sylvain Henry authored
      Move handling of big literal strings from CmmToAsm to StgToCmm. It
      avoids the use of `sdocWithDynFlags` (cf #10143). We might need to move
      this handling even higher in the pipeline in the future (cf #17960):
      this patch will make it easier.
      a485c3c4
  15. 29 Mar, 2020 1 commit
  16. 19 Mar, 2020 1 commit
  17. 17 Mar, 2020 1 commit
  18. 22 Feb, 2020 1 commit
  19. 31 Jan, 2020 1 commit
    • Ömer Sinan Ağacan's avatar
      Do CafInfo/SRT analysis in Cmm · c846618a
      Ömer Sinan Ağacan authored
      This patch removes all CafInfo predictions and various hacks to preserve
      predicted CafInfos from the compiler and assigns final CafInfos to
      interface Ids after code generation. SRT analysis is extended to support
      static data, and Cmm generator is modified to allow generating
      static_link fields after SRT analysis.
      
      This also fixes `-fcatch-bottoms`, which introduces error calls in case
      expressions in CorePrep, which runs *after* CoreTidy (which is where we
      decide on CafInfos) and turns previously non-CAFFY things into CAFFY.
      
      Fixes #17648
      Fixes #9718
      
      Evaluation
      ==========
      
      NoFib
      -----
      
      Boot with: `make boot mode=fast`
      Run: `make mode=fast EXTRA_RUNTEST_OPTS="-cachegrind" NoFibRuns=1`
      
      --------------------------------------------------------------------------------
              Program           Size    Allocs    Instrs     Reads    Writes
      --------------------------------------------------------------------------------
                   CS          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
                  CSD          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
                   FS          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
                    S          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
                   VS          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
                  VSD          -0.0%      0.0%     -0.0%     -0.0%     -0.5%
                  VSM          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
                 anna          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
                 ansi          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
                 atom          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
               awards          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
               banner          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
           bernouilli          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
         binary-trees          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
                boyer          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
               boyer2          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
                 bspt          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
            cacheprof          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
             calendar          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
             cichelli          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
              circsim          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
             clausify          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
        comp_lab_zift          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
             compress          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
            compress2          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
          constraints          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
         cryptarithm1          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
         cryptarithm2          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
                  cse          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
         digits-of-e1          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
         digits-of-e2          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
               dom-lt          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
                eliza          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
                event          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
          exact-reals          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
               exp3_8          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
               expert          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
       fannkuch-redux          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
                fasta          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
                  fem          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
                  fft          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
                 fft2          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
             fibheaps          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
                 fish          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
                fluid          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
               fulsom          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
               gamteb          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
                  gcd          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
          gen_regexps          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
               genfft          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
                   gg          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
                 grep          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
               hidden          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
                  hpg          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
                  ida          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
                infer          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
              integer          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
            integrate          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
         k-nucleotide          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
                kahan          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
              knights          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
               lambda          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
           last-piece          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
                 lcss          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
                 life          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
                 lift          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
               linear          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
            listcompr          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
             listcopy          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
             maillist          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
               mandel          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
              mandel2          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
                 mate          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
              minimax          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
              mkhprog          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
           multiplier          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
               n-body          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
             nucleic2          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
                 para          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
            paraffins          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
               parser          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
              parstof          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
                  pic          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
             pidigits          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
                power          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
               pretty          -0.0%      0.0%     -0.3%     -0.4%     -0.4%
               primes          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
            primetest          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
               prolog          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
               puzzle          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
               queens          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
              reptile          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
      reverse-complem          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
              rewrite          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
                 rfib          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
                  rsa          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
                  scc          -0.0%      0.0%     -0.3%     -0.5%     -0.4%
                sched          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
                  scs          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
               simple          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
                solid          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
              sorting          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
        spectral-norm          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
               sphere          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
               symalg          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
                  tak          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
            transform          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
             treejoin          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
            typecheck          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
              veritas          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
                 wang          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
            wave4main          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
         wheel-sieve1          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
         wheel-sieve2          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
                 x2n1          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
      --------------------------------------------------------------------------------
                  Min          -0.1%      0.0%     -0.3%     -0.5%     -0.5%
                  Max          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
       Geometric Mean          -0.0%     -0.0%     -0.0%     -0.0%     -0.0%
      
      --------------------------------------------------------------------------------
              Program           Size    Allocs    Instrs     Reads    Writes
      --------------------------------------------------------------------------------
              circsim          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
          constraints          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
             fibheaps          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
             gc_bench          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
                 hash          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
                 lcss          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
                power          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
           spellcheck          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
      --------------------------------------------------------------------------------
                  Min          -0.1%      0.0%     -0.0%     -0.0%     -0.0%
                  Max          -0.0%      0.0%     -0.0%     -0.0%     -0.0%
       Geometric Mean          -0.0%     +0.0%     -0.0%     -0.0%     -0.0%
      
      Manual inspection of programs in testsuite/tests/programs
      ---------------------------------------------------------
      
      I built these programs with a bunch of dump flags and `-O` and compared
      STG, Cmm, and Asm dumps and file sizes.
      
      (Below the numbers in parenthesis show number of modules in the program)
      
      These programs have identical compiler (same .hi and .o sizes, STG, and
      Cmm and Asm dumps):
      
      - Queens (1), andre_monad (1), cholewo-eval (2), cvh_unboxing (3),
        andy_cherry (7), fun_insts (1), hs-boot (4), fast2haskell (2),
        jl_defaults (1), jq_readsPrec (1), jules_xref (1), jtod_circint (4),
        jules_xref2 (1), lennart_range (1), lex (1), life_space_leak (1),
        bargon-mangler-bug (7), record_upd (1), rittri (1), sanders_array (1),
        strict_anns (1), thurston-module-arith (2), okeefe_neural (1),
        joao-circular (6), 10queens (1)
      
      Programs with different compiler outputs:
      
      - jl_defaults (1): For some reason GHC HEAD marks a lot of top-level
        `[Int]` closures as CAFFY for no reason. With this patch we no longer
        make them CAFFY and generate less SRT entries. For some reason Main.o
        is slightly larger with this patch (1.3%) and the executable sizes are
        the same. (I'd expect both to be smaller)
      
      - launchbury (1): Same as jl_defaults: top-level `[Int]` closures marked
        as CAFFY for no reason. Similarly `Main.o` is 1.4% larger but the
        executable sizes are the same.
      
      - galois_raytrace (13): Differences are in the Parse module. There are a
        lot, but some of the changes are caused by the fact that for some
        reason (I think a bug) GHC HEAD marks the dictionary for `Functor
        Identity` as CAFFY. Parse.o is 0.4% larger, the executable size is the
        same.
      
      - north_array: We now generate less SRT entries because some of array
        primops used in this program like `NewArrayOp` get eliminated during
        Stg-to-Cmm and turn some CAFFY things into non-CAFFY. Main.o gets 24%
        larger (9224 bytes from 9000 bytes), executable sizes are the same.
      
      - seward-space-leak: Difference in this program is better shown by this
        smaller example:
      
            module Lib where
      
            data CDS
              = Case [CDS] [(Int, CDS)]
              | Call CDS CDS
      
            instance Eq CDS where
              Case sels1 rets1 == Case sels2 rets2 =
                  sels1 == sels2 && rets1 == rets2
              Call a1 b1 == Call a2 b2 =
                  a1 == a2 && b1 == b2
              _ == _ =
                  False
      
         In this program GHC HEAD builds a new SRT for the recursive group of
         `(==)`, `(/=)` and the dictionary closure. Then `/=` points to `==`
         in its SRT field, and `==` uses the SRT object as its SRT. With this
         patch we use the closure for `/=` as the SRT and add `==` there. Then
         `/=` gets an empty SRT field and `==` points to `/=` in its SRT
         field.
      
         This change looks fine to me.
      
         Main.o gets 0.07% larger, executable sizes are identical.
      
      head.hackage
      ------------
      
      head.hackage's CI script builds 428 packages from Hackage using this
      patch with no failures.
      
      Compiler performance
      --------------------
      
      The compiler perf tests report that the compiler allocates slightly more
      (worst case observed so far is 4%). However most programs in the test
      suite are small, single file programs. To benchmark compiler performance
      on something more realistic I build Cabal (the library, 236 modules)
      with different optimisation levels. For the "max residency" row I run
      GHC with `+RTS -s -A100k -i0 -h` for more accurate numbers. Other rows
      are generated with just `-s`. (This is because `-i0` causes running GC
      much more frequently and as a result "bytes copied" gets inflated by
      more than 25x in some cases)
      
      * -O0
      
      |                 | GHC HEAD       | This MR        | Diff   |
      | --------------- | -------------- | -------------- | ------ |
      | Bytes allocated | 54,413,350,872 | 54,701,099,464 | +0.52% |
      | Bytes copied    |  4,926,037,184 |  4,990,638,760 | +1.31% |
      | Max residency   |    421,225,624 |    424,324,264 | +0.73% |
      
      * -O1
      
      |                 | GHC HEAD        | This MR         | Diff   |
      | --------------- | --------------- | --------------- | ------ |
      | Bytes allocated | 245,849,209,992 | 246,562,088,672 | +0.28% |
      | Bytes copied    |  26,943,452,560 |  27,089,972,296 | +0.54% |
      | Max residency   |     982,643,440 |     991,663,432 | +0.91% |
      
      * -O2
      
      |                 | GHC HEAD        | This MR         | Diff   |
      | --------------- | --------------- | --------------- | ------ |
      | Bytes allocated | 291,044,511,408 | 291,863,910,912 | +0.28% |
      | Bytes copied    |  37,044,237,616 |  36,121,690,472 | -2.49% |
      | Max residency   |   1,071,600,328 |   1,086,396,256 | +1.38% |
      
      Extra compiler allocations
      --------------------------
      
      Runtime allocations of programs are as reported above (NoFib section).
      
      The compiler now allocates more than before. Main source of allocation
      in this patch compared to base commit is the new SRT algorithm
      (GHC.Cmm.Info.Build). Below is some of the extra work we do with this
      patch, numbers generated by profiled stage 2 compiler when building a
      pathological case (the test 'ManyConstructors') with '-O2':
      
      - We now sort the final STG for a module, which means traversing the
        entire program, generating free variable set for each top-level
        binding, doing SCC analysis, and re-ordering the program. In
        ManyConstructors this step allocates 97,889,952 bytes.
      
      - We now do SRT analysis on static data, which in a program like
        ManyConstructors causes analysing 10,000 bindings that we would
        previously just skip. This step allocates 70,898,352 bytes.
      
      - We now maintain an SRT map for the entire module as we compile Cmm
        groups:
      
            data ModuleSRTInfo = ModuleSRTInfo
              { ...
              , moduleSRTMap :: SRTMap
              }
      
         (SRTMap is just a strict Map from the 'containers' library)
      
         This map gets an entry for most bindings in a module (exceptions are
         THUNKs and CAFFY static functions). For ManyConstructors this map
         gets 50015 entries.
      
      - Once we're done with code generation we generate a NameSet from SRTMap
        for the non-CAFFY names in the current module. This set gets the same
        number of entries as the SRTMap.
      
      - Finally we update CafInfos in ModDetails for the non-CAFFY Ids, using
        the NameSet generated in the previous step. This usually does the
        least amount of allocation among the work listed here.
      
      Only place with this patch where we do less work in the CAF analysis in
      the tidying pass (CoreTidy). However that doesn't save us much, as the
      pass still needs to traverse the whole program and update IdInfos for
      other reasons. Only thing we don't here do is the `hasCafRefs` pass over
      the RHS of bindings, which is a stateless pass that returns a boolean
      value, so it doesn't allocate much.
      
      (Metric changes blow are all increased allocations)
      
      Metric changes
      --------------
      
      Metric Increase:
          ManyAlternatives
          ManyConstructors
          T13035
          T14683
          T1969
          T9961
      c846618a
  20. 25 Jan, 2020 1 commit
  21. 31 Dec, 2019 1 commit
  22. 23 Oct, 2019 1 commit
    • Andreas Klebinger's avatar
      Make dynflag argument for withTiming pure. · 6beea836
      Andreas Klebinger authored
      19 times out of 20 we already have dynflags in scope.
      
      We could just always use `return dflags`. But this is in fact not free.
      When looking at some STG code I noticed that we always allocate a
      closure for this expression in the heap. Clearly a waste in these cases.
      
      For the other cases we can either just modify the callsite to
      get dynflags or use the _D variants of withTiming I added which
      will use getDynFlags under the hood.
      6beea836
  23. 20 Sep, 2019 1 commit
    • Alp Mestanogullari's avatar
      ErrUtils: split withTiming into withTiming and withTimingSilent · b3e5c731
      Alp Mestanogullari authored
      'withTiming' becomes a function that, when passed '-vN' (N >= 2) or
      '-ddump-timings', will print timing (and possibly allocations) related
      information. When additionally built with '-eventlog' and executed with
      '+RTS -l', 'withTiming' will also emit both 'traceMarker' and 'traceEvent'
      events to the eventlog.
      
      'withTimingSilent' on the other hand will never print any timing information,
      under any circumstance, and will only emit 'traceEvent' events to the eventlog.
      As pointed out in !1672, 'traceMarker' is better suited for things that we
      might want to visualize in tools like eventlog2html, while 'traceEvent'
      is better suited for internal events that occur a lot more often and that we
      don't necessarily want to visualize.
      
      This addresses #17138 by using 'withTimingSilent' for all the codegen bits
      that are expressed as a bunch of small computations over streams of codegen
      ASTs.
      b3e5c731
  24. 16 Sep, 2019 1 commit
  25. 09 Sep, 2019 1 commit
    • Sylvain Henry's avatar
      Module hierarchy: StgToCmm (#13009) · 447864a9
      Sylvain Henry authored
      Add StgToCmm module hierarchy. Platform modules that are used in several
      other places (NCG, LLVM codegen, Cmm transformations) are put into
      GHC.Platform.
      447864a9
  26. 03 Aug, 2019 1 commit
  27. 06 Mar, 2019 1 commit
    • Ben Gamari's avatar
      Rip out object splitting · 37f257af
      Ben Gamari authored
      The splitter is an evil Perl script that processes assembler code.
      Its job can be done better by the linker's --gc-sections flag. GHC
      passes this flag to the linker whenever -split-sections is passed on
      the command line.
      
      This is based on @DemiMarie's D2768.
      
      Fixes Trac #11315
      Fixes Trac #9832
      Fixes Trac #8964
      Fixes Trac #8685
      Fixes Trac #8629
      37f257af
  28. 31 Jan, 2019 1 commit
  29. 23 Nov, 2018 1 commit
    • Sebastian Graf's avatar
      Implement late lambda lift · b2950e03
      Sebastian Graf authored
      Summary:
      This implements a selective lambda-lifting pass late in the STG
      pipeline.
      
      Lambda lifting has the effect of avoiding closure allocation at the cost
      of having to make former free vars available at call sites, possibly
      enlarging closures surrounding call sites in turn.
      
      We identify beneficial cases by means of an analysis that estimates
      closure growth.
      
      There's a Wiki page at
      https://ghc.haskell.org/trac/ghc/wiki/LateLamLift.
      
      Reviewers: simonpj, bgamari, simonmar
      
      Reviewed By: simonpj
      
      Subscribers: rwbarton, carter
      
      GHC Trac Issues: #9476
      
      Differential Revision: https://phabricator.haskell.org/D5224
      b2950e03
  30. 19 Nov, 2018 1 commit
    • Sebastian Graf's avatar
      Don't track free variables in STG syntax by default · 47bbc709
      Sebastian Graf authored
      Summary:
      Currently, `CoreToStg` annotates `StgRhsClosure`s with their set of non-global
      free variables.  This free variable information is only needed in the final
      code generation step (i.e. `StgCmm.codeGen`), which leads to transformations
      such as `StgCse` and `StgUnarise` having to maintain this information.
      
      This is tiresome and unnecessary, so this patch introduces a trees-to-grow-like
      approach that only introduces the free variable set into the syntax tree in the
      code gen pass, along with a free variable analysis on STG terms to generate
      that information.
      
      Fixes #15754.
      
      Reviewers: simonpj, osa1, bgamari, simonmar
      
      Reviewed By: osa1
      
      Subscribers: rwbarton, carter
      
      GHC Trac Issues: #15754
      
      Differential Revision: https://phabricator.haskell.org/D5324
      47bbc709
  31. 12 Nov, 2018 1 commit
    • Ömer Sinan Ağacan's avatar
      Remove StgBinderInfo and related computation in CoreToStg · d30352ad
      Ömer Sinan Ağacan authored
      - The StgBinderInfo type was never used in the code gen, so the type, related
        computation in CoreToStg, and some comments about it are removed. See #15770
        for more details.
      
      - Simplified CoreToStg after removing the StgBinderInfo computation: removed
        StgBinderInfo arguments and mfix stuff.
      
      The StgBinderInfo values were not used in the code gen, but I still run nofib
      just to make sure: 0.0% change in allocations and binary sizes.
      
      Test Plan: Validated locally
      
      Reviewers: simonpj, simonmar, bgamari, sgraf
      
      Reviewed By: sgraf
      
      Subscribers: AndreasK, sgraf, rwbarton, carter
      
      Differential Revision: https://phabricator.haskell.org/D5232
      d30352ad
  32. 26 Sep, 2017 1 commit
  33. 19 Sep, 2017 1 commit
    • Herbert Valerio Riedel's avatar
      compiler: introduce custom "GhcPrelude" Prelude · f63bc730
      Herbert Valerio Riedel authored
      This switches the compiler/ component to get compiled with
      -XNoImplicitPrelude and a `import GhcPrelude` is inserted in all
      modules.
      
      This is motivated by the upcoming "Prelude" re-export of
      `Semigroup((<>))` which would cause lots of name clashes in every
      modulewhich imports also `Outputable`
      
      Reviewers: austin, goldfire, bgamari, alanz, simonmar
      
      Reviewed By: bgamari
      
      Subscribers: goldfire, rwbarton, thomie, mpickering, bgamari
      
      Differential Revision: https://phabricator.haskell.org/D3989
      f63bc730
  34. 17 Apr, 2017 1 commit
    • Sergei Trofimovich's avatar
      hs_add_root() RTS API removal · a92ff5d6
      Sergei Trofimovich authored
      Before ghc-7.2 hs_add_root() had to be used to initialize haskell
      modules when haskell was called from FFI.
      
      commit a52ff761
      ("Change the way module initialisation is done (#3252, #4417)")
      removed needs for hs_add_root() and made function a no-op.
      For backward compatibility '__stginit_<module>' symbol was
      not removed.
      
      This change removes no-op hs_add_root() function and unused
      '__stginit_<module>' symbol from each haskell module.
      Signed-off-by: default avatarSergei Trofimovich <slyfox@gentoo.org>
      
      Test Plan: ./validate
      
      Reviewers: simonmar, austin, bgamari, erikd
      
      Reviewed By: simonmar
      
      Subscribers: rwbarton, thomie
      
      Differential Revision: https://phabricator.haskell.org/D3460
      a92ff5d6
  35. 20 Jan, 2017 1 commit
    • takano-akio's avatar
      Allow top-level string literals in Core (#8472) · d49b2bb2
      takano-akio authored
      This commits relaxes the invariants of the Core syntax so that a
      top-level variable can be bound to a primitive string literal of type
      Addr#.
      
      This commit:
      
      * Relaxes the invatiants of the Core, and allows top-level bindings whose
        type is Addr# as long as their RHS is either a primitive string literal or
        another variable.
      
      * Allows the simplifier and the full-laziness transformer to float out
        primitive string literals to the top leve.
      
      * Introduces the new StgGenTopBinding type to accomodate top-level Addr#
        bindings.
      
      * Introduces a new type of labels in the object code, with the suffix "_bytes",
        for exported top-level Addr# bindings.
      
      * Makes some built-in rules more robust. This was necessary to keep them
        functional after the above changes.
      
      This is a continuation of D2554.
      
      Rebasing notes:
      This had two slightly suspicious performance regressions:
      
      * T12425: bytes allocated regressed by roughly 5%
      * T4029: bytes allocated regressed by a bit over 1%
      * T13035: bytes allocated regressed by a bit over 5%
      
      These deserve additional investigation.
      
      Rebased by: bgamari.
      
      Test Plan: ./validate --slow
      
      Reviewers: goldfire, trofi, simonmar, simonpj, austin, hvr, bgamari
      
      Reviewed By: trofi, simonpj, bgamari
      
      Subscribers: trofi, simonpj, gridaphobe, thomie
      
      Differential Revision: https://phabricator.haskell.org/D2605
      
      GHC Trac Issues: #8472
      d49b2bb2
  36. 19 Jan, 2017 1 commit
    • Richard Eisenberg's avatar
      Update levity polymorphism · e7985ed2
      Richard Eisenberg authored
      This commit implements the proposal in
      https://github.com/ghc-proposals/ghc-proposals/pull/29 and
      https://github.com/ghc-proposals/ghc-proposals/pull/35.
      
      Here are some of the pieces of that proposal:
      
      * Some of RuntimeRep's constructors have been shortened.
      
      * TupleRep and SumRep are now parameterized over a list of RuntimeReps.
      * This
      means that two types with the same kind surely have the same
      representation.
      Previously, all unboxed tuples had the same kind, and thus the fact
      above was
      false.
      
      * RepType.typePrimRep and friends now return a *list* of PrimReps. These
      functions can now work successfully on unboxed tuples. This change is
      necessary because we allow abstraction over unboxed tuple types and so
      cannot
      always handle unboxed tuples specially as we did before.
      
      * We sometimes have to create an Id from a PrimRep. I thus split PtrRep
      * into
      LiftedRep and UnliftedRep, so that the created Ids have the right
      strictness.
      
      * The RepType.RepType type was removed, as it didn't seem to help with
      * much.
      
      * The RepType.repType function is also removed, in favor of typePrimRep.
      
      * I have waffled a good deal on whether or not to keep VoidRep in
      TyCon.PrimRep. In the end, I decided to keep it there. PrimRep is *not*
      represented in RuntimeRep, and typePrimRep will never return a list
      including
      VoidRep. But it's handy to have in, e.g., ByteCodeGen and friends. I can
      imagine another design choice where we have a PrimRepV type that is
      PrimRep
      with an extra constructor. That seemed to be a heavier design, though,
      and I'm
      not sure what the benefit would be.
      
      * The last, unused vestiges of # (unliftedTypeKind) have been removed.
      
      * There were several pretty-printing bugs that this change exposed;
      * these are fixed.
      
      * We previously checked for levity polymorphism in the types of binders.
      * But we
      also must exclude levity polymorphism in function arguments. This is
      hard to check
      for, requiring a good deal of care in the desugarer. See Note [Levity
      polymorphism
      checking] in DsMonad.
      
      * In order to efficiently check for levity polymorphism in functions, it
      * was necessary
      to add a new bit of IdInfo. See Note [Levity info] in IdInfo.
      
      * It is now safe for unlifted types to be unsaturated in Core. Core Lint
      * is updated
      accordingly.
      
      * We can only know strictness after zonking, so several checks around
      * strictness
      in the type-checker (checkStrictBinds, the check for unlifted variables
      under a ~
      pattern) have been moved to the desugarer.
      
      * Along the way, I improved the treatment of unlifted vs. banged
      * bindings. See
      Note [Strict binds checks] in DsBinds and #13075.
      
      * Now that we print type-checked source, we must be careful to print
      * ConLikes correctly.
      This is facilitated by a new HsConLikeOut constructor to HsExpr.
      Particularly troublesome
      are unlifted pattern synonyms that get an extra void# argument.
      
      * Includes a submodule update for haddock, getting rid of #.
      
      * New testcases:
        typecheck/should_fail/StrictBinds
        typecheck/should_fail/T12973
        typecheck/should_run/StrictPats
        typecheck/should_run/T12809
        typecheck/should_fail/T13105
        patsyn/should_fail/UnliftedPSBind
        typecheck/should_fail/LevPolyBounded
        typecheck/should_compile/T12987
        typecheck/should_compile/T11736
      
      * Fixed tickets:
        #12809
        #12973
        #11736
        #13075
        #12987
      
      * This also adds a test case for #13105. This test case is
      * "compile_fail" and
      succeeds, because I want the testsuite to monitor the error message.
      When #13105 is fixed, the test case will compile cleanly.
      e7985ed2