1. 23 Jan, 2019 1 commit
  2. 13 Dec, 2018 1 commit
  3. 08 Dec, 2018 1 commit
    • Ömer Sinan Ağacan's avatar
      Fix StgLint bound id check, generalize StgLint · 04caa935
      Ömer Sinan Ağacan authored
      StgLint was incorrectly using isLocalId for bound id check to see
      whether an id is imported (in which case we don't expect it to be bound)
      or local.  The problem with isLocalId is that its semantics changes
      after Core, as explained in the note: (last line)
      
          Note [GlobalId/LocalId]
          ~~~~~~~~~~~~~~~~~~~~~~~
          A GlobalId is
            * always a constant (top-level)
            * imported, or data constructor, or primop, or record selector
            * has a Unique that is globally unique across the whole
              GHC invocation (a single invocation may compile multiple
              modules)
            * never treated as a candidate by the free-variable finder;
                  it's a constant!
      
          A LocalId is
            * bound within an expression (lambda, case, local let(rec))
            * or defined at top level in the module being compiled
            * always treated as a candidate by the free-variable finder
      
          After CoreTidy, top-level LocalIds are turned into GlobalIds
      
      We now pass current module as a parameter to StgLint, which uses it to
      see if an id should be bound (defined in the current module) or not
      (imported).
      
      Other changes:
      
      - Generalized StgLint to make it work on both StgTopBinding and
        CgStgTopBinding.
      - Bring all top-level binders into scope before linting top-level
        bindings to allow uses before definitions.
      
      TODO: We should remove the binder from local vars when checking RHSs of
      non-recursive bindings.
      
      Test Plan: This validates.
      
      Reviewers: simonpj, bgamari, sgraf
      
      Reviewed By: simonpj, sgraf
      
      Subscribers: rwbarton, carter
      
      Differential Revision: https://phabricator.haskell.org/D5370
      04caa935
  4. 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
  5. 22 Nov, 2018 1 commit
    • Sylvain Henry's avatar
      Rename literal constructors · 13bb4bf4
      Sylvain Henry authored
      In a previous patch we replaced some built-in literal constructors
      (MachInt, MachWord, etc.) with a single LitNumber constructor.
      
      In this patch we replace the `Mach` prefix of the remaining constructors
      with `Lit` for consistency (e.g., LitChar, LitLabel, etc.).
      
      Sadly the name `LitString` was already taken for a kind of FastString
      and it would become misleading to have both `LitStr` (literal
      constructor renamed after `MachStr`) and `LitString` (FastString
      variant). Hence this patch renames the FastString variant `PtrString`
      (which is more accurate) and the literal string constructor now uses the
      least surprising `LitString` name.
      
      Both `Literal` and `LitString/PtrString` have recently seen breaking
      changes so doing this kind of renaming now shouldn't harm much.
      
      Reviewers: hvr, goldfire, bgamari, simonmar, jrtc27, tdammers
      
      Subscribers: tdammers, rwbarton, thomie, carter
      
      Differential Revision: https://phabricator.haskell.org/D4881
      13bb4bf4
  6. 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
  7. 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
  8. 14 Oct, 2018 1 commit
    • Sebastian Graf's avatar
      Add RubbishLit for absent bindings of UnliftedRep · 448b77b9
      Sebastian Graf authored
      Summary:
      Trac #9279 reminded us that the worker wrapper transformation copes
      really badly with absent unlifted boxed bindings.
      
      As `Note [Absent errors]` in WwLib.hs points out, we can't just use
      `absentError` for unlifted bindings because there is no bottom to hide
      the error in.
      So instead, we synthesise a new `RubbishLit` of type
      `forall (a :: TYPE 'UnliftedRep). a`, which code-gen may subsitute for
      any boxed value. We choose `()`, so that there is a good chance that
      the program crashes instead instead of leading to corrupt data, should
      absence analysis have been too optimistic (#11126).
      
      Reviewers: simonpj, hvr, goldfire, bgamari, simonmar
      
      Reviewed By: simonpj
      
      Subscribers: osa1, rwbarton, carter
      
      GHC Trac Issues: #15627, #9279, #4306, #11126
      
      Differential Revision: https://phabricator.haskell.org/D5153
      448b77b9
  9. 27 Jul, 2018 1 commit
    • Ömer Sinan Ağacan's avatar
      Run StgCse after unarise, fixes #15300 · 3c311e50
      Ömer Sinan Ağacan authored
      Given two unboxed sum terms:
      
          (# 1 | #) :: (# Int | Int# #)
          (# 1 | #) :: (# Int | Int  #)
      
      These two terms are not equal as they unarise to different unboxed
      tuples. However StgCse was thinking that these are equal, and replacing
      one of these with a binder to the other.
      
      To not deal with unboxed sums in StgCse we now do it after unarise. For
      StgCse to maintain post-unarise invariants we factor-out case binder
      in-scopeness check to `stgCaseBndrInScope` and use it in StgCse.
      
      Also did some refactoring in SimplStg.
      
      Another way to fix this would be adding a special case in StgCse to not
      bring unboxed sum binders in scope:
      
          diff --git a/compiler/simplStg/StgCse.hs
      b/compiler/simplStg/StgCse.hs
          index 6c740ca4cb..93a0f8f6ad 100644
          --- a/compiler/simplStg/StgCse.hs
          +++ b/compiler/simplStg/StgCse.hs
          @@ -332,7 +332,11 @@ stgCseExpr env (StgLetNoEscape binds body)
           stgCseAlt :: CseEnv -> OutId -> InStgAlt -> OutStgAlt
           stgCseAlt env case_bndr (DataAlt dataCon, args, rhs)
               = let (env1, args') = substBndrs env args
          -          env2 = addDataCon case_bndr dataCon (map StgVarArg
      args') env1
          +          env2
          +            | isUnboxedSumCon dataCon
          +            = env1
          +            | otherwise
          +            = addDataCon case_bndr dataCon (map StgVarArg args')
      env1
                       -- see note [Case 2: CSEing case binders]
                     rhs' = stgCseExpr env2 rhs
                 in (DataAlt dataCon, args', rhs')
      
      I think this patch seems better in that it doesn't add a special case to
      StgCse.
      
      Test Plan:
      Validate.
      
      I tried to come up with a minimal example but failed. I thought a simple
      program like
      
          data T = T (# Int | Int #) (# Int# | Int #)
      
          case T (# 1 | #) (# 1 | #) of ...
      
      should be enough to trigger this bug, but for some reason StgCse
      doesn't do
      anything on this program.
      
      Reviewers: simonpj, bgamari
      
      Reviewed By: simonpj
      
      Subscribers: rwbarton, thomie, carter
      
      GHC Trac Issues: #15300
      
      Differential Revision: https://phabricator.haskell.org/D4962
      3c311e50
  10. 15 Jun, 2018 1 commit
    • Sylvain Henry's avatar
      Built-in Natural literals in Core · fe770c21
      Sylvain Henry authored
      Add support for built-in Natural literals in Core.
      
      - Replace MachInt,MachWord, LitInteger, etc. with a single LitNumber
        constructor with a LitNumType field
      - Support built-in Natural literals
      - Add desugar warning for negative literals
      - Move Maybe(..) from GHC.Base to GHC.Maybe for module dependency
        reasons
      
      This patch introduces only a few rules for Natural literals (compared
      to Integer's rules). Factorization of the built-in rules for numeric
      literals will be done in another patch as this one is already big to
      review.
      
      Test Plan:
        validate
        test build with integer-simple
      
      Reviewers: hvr, bgamari, goldfire, Bodigrim, simonmar
      
      Reviewed By: bgamari
      
      Subscribers: phadej, simonpj, RyanGlScott, carter, hsyl20, rwbarton,
      thomie
      
      GHC Trac Issues: #14170, #14465
      
      Differential Revision: https://phabricator.haskell.org/D4212
      fe770c21
  11. 16 May, 2018 1 commit
    • Simon Marlow's avatar
      An overhaul of the SRT representation · eb8e692c
      Simon Marlow authored
      Summary:
      - Previously we would hvae a single big table of pointers per module,
        with a set of bitmaps to reference entries within it. The new
        representation is identical to a static constructor, which is much
        simpler for the GC to traverse, and we get to remove the complicated
        bitmap-traversal code from the GC.
      
      - Rewrite all the code to generate SRTs in CmmBuildInfoTables, and
        document it much better (see Note [SRTs]). This has been something
        I've wanted to do since we moved to the new code generator, I
        finally had the opportunity to finish it while on a transatlantic
        flight recently :)
      
      There are a series of 4 diffs:
      
      1. D4632 (this one), which does the bulk of the changes
      
      2. D4633 which adds support for smaller `CmmLabelDiffOff` constants
      
      3. D4634 which takes advantage of D4632 and D4633 to save a word in
         info tables that have an SRT on x86_64. This is where most of the
         binary size improvement comes from.
      
      4. D4637 which makes a further optimisation to merge some SRTs with
         static FUN closures.  This adds some complexity and the benefits
         are fairly modest, so it's not clear yet whether we should do this.
      
      Results (after (3), on x86_64)
      
      - GHC itself (staticaly linked) is 5.2% smaller
      
      - -1.7% binary sizes in nofib, -2.9% module sizes. Full nofib results: P176
      
      - I measured the overhead of traversing all the static objects in a
        major GC in GHC itself by doing `replicateM_ 1000 performGC` as the
        first thing in `Main.main`.  The new version was 5-10% faster, but
        the results did vary quite a bit.
      
      - I'm not sure if there's a compile-time difference, the results are
        too unreliable.
      
      Test Plan: validate
      
      Reviewers: bgamari, michalt, niteria, simonpj, erikd, osa1
      
      Subscribers: thomie, carter
      
      Differential Revision: https://phabricator.haskell.org/D4632
      eb8e692c
  12. 26 Mar, 2018 1 commit
  13. 06 Mar, 2018 1 commit
    • niteria's avatar
      Allow top level ticked string literals · 5bc195a2
      niteria authored
      This reverts f5b275a2
      and changes the places that looked for `Lit (MachStr _))`
      to use `exprIsMbTickedLitString_maybe` to unwrap ticks as
      necessary.
      Also updated relevant comments.
      
      Test Plan:
      I added 3 new tests that previously reproduced.
      GHC HEAD now builds with -g
      
      Reviewers: simonpj, simonmar, bgamari, hvr, goldfire
      
      Subscribers: rwbarton, thomie, carter
      
      GHC Trac Issues: #14779
      
      Differential Revision: https://phabricator.haskell.org/D4470
      5bc195a2
  14. 02 Mar, 2018 1 commit
    • shlevy's avatar
      Make cost centre symbol names deterministic. · d8e47a2e
      shlevy authored
      Previously, non-CAF cost centre symbol names contained a unique,
      leading to non-deterministic object files which, among other issues,
      can lead to an inconsistency causing linking failure when using cached
      builds sourced from multiple machines, such as with nix. Now, each
      cost centre symbol is annotated with the type of cost centre it
      is (CAF, expression annotation, declaration annotation, or HPC) and,
      when a single module has multiple cost centres with the same name and
      type, a 0-based index.
      
      Reviewers: bgamari, simonmar
      
      Reviewed By: bgamari
      
      Subscribers: niteria, simonmar, RyanGlScott, osa1, rwbarton, thomie, carter
      
      GHC Trac Issues: #4012, #12935
      
      Differential Revision: https://phabricator.haskell.org/D4388
      d8e47a2e
  15. 18 Feb, 2018 1 commit
    • Ömer Sinan Ağacan's avatar
      StgLint overhaul · 7f389a58
      Ömer Sinan Ağacan authored
      - Remove all type checks
      - Check two STG invariants (no unboxed let bindings, variables defined
        before used) and post-unarisation invariants.
      
      See the module header and #14787.
      
      This version validates with `-dstg-lint` added to `GhcStage2HcOpts` and
      `GhcLibHcOpts` and `EXTRA_HC_OPTS`.
      
      Unarise changes:
      
      - `unariseConArgBinder` and `unariseFunArgBinder` functions were almost
        the same; only difference was when unarising fun args we keep void
        args while in con args we drop them. A new function `unariseArgBinder`
        added with a `Bool` argument for whether we're unarising a con arg.
        `unariseConArgBinder` and `unariseFunArgBinder` are now defined as
      
            unariseConArgBinder = unarsieArgBinder True  -- data con
            unariseFunArgBinder = unariseArgBinder False -- not data con
      
      - A bug in `unariseConArgBinder` and `unariseFunArgBinder` (which are
        just calls to `unariseArgBinder` now) that invalidated the
        post-unarise invariants when the argument has single type rep (i.e.
        `length (typePrimRep x) == 1`) fixed. This isn't a correctness issue
        (it's fine not to unarise if a variable is already represented as
        single value), but it triggers StgLint.
      
      Test Plan:
      - Pass testsuite with `-dstg-lint` [done]
      - Boot stage2 (including libraries) with `-dstg-lint` [done]
      
      Reviewers: simonpj, bgamari
      
      Reviewed By: bgamari
      
      Subscribers: duog, rwbarton, thomie, carter
      
      GHC Trac Issues: #14787
      
      Differential Revision: https://phabricator.haskell.org/D4404
      7f389a58
  16. 13 Feb, 2018 1 commit
    • Ömer Sinan Ağacan's avatar
      Collect CCs in CorePrep, including CCs in unfoldings · 59574058
      Ömer Sinan Ağacan authored
      This patch includes two changes:
      
      1. Move cost centre collection from `SCCfinal` to `CorePrep`, to be able
         to collect cost centres in unfoldings. `CorePrep` drops unfoldings, so
         that's the latest stage in the compilation pipeline for this.
      
         After this change `SCCfinal` no longer collects all cost centres, but
         it still generates & collects CAF cost centres + updates cost centre
         stacks of `StgRhsClosure` and `StgRhsCon`s.
      
         This fixes #5889.
      
      2. Initialize cost centre stack fields of `StgRhs` in `coreToStg`. With
         this we no longer need to update cost centre stack fields in
         `SCCfinal`, so that module is removed.
      
         Cost centre initialization explained in Note [Cost-centre
         initialization plan].
      
         Because with -fcaf-all we need to attach a new cost-centre to each
         CAF, `coreTopBindToStg` now returns `CollectedCCs`.
      
      Test Plan: validate
      
      Reviewers: simonpj, bgamari, simonmar
      
      Reviewed By: simonpj, bgamari
      
      Subscribers: rwbarton, thomie, carter
      
      GHC Trac Issues: #5889
      
      Differential Revision: https://phabricator.haskell.org/D4325
      59574058
  17. 02 Nov, 2017 1 commit
  18. 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
  19. 07 Sep, 2017 1 commit
  20. 05 Sep, 2017 1 commit
  21. 31 Aug, 2017 1 commit
    • Simon Peyton Jones's avatar
      Add debugPprType · 805b29bb
      Simon Peyton Jones authored
      We pretty-print a type by converting it to an IfaceType and
      pretty-printing that.  But
       (a) that's a bit indirect, and
       (b) delibrately loses information about (e.g.) the kind
            on the /occurrences/ of a type variable
      
      So this patch implements debugPprType, which pretty prints
      the type directly, with no fancy formatting.  It's just used
      for debugging.
      
      I took the opportunity to refactor the debug-pretty-printing
      machinery a little.  In particular, define these functions
      and use them:
      
        ifPprDeubug :: SDoc -> SDOc -> SDoc
          -- Says what to do with and without -dppr-debug
        whenPprDebug :: SDoc -> SDoc
          -- Says what to do with  -dppr-debug; without is empty
        getPprDebug :: (Bool -> SDoc) -> SDoc
      
      getPprDebug used to be called sdocPprDebugWith
      whenPprDebug used to be called ifPprDebug
      
      So a lot of files get touched in a very mechanical way
      805b29bb
  22. 29 Aug, 2017 3 commits
  23. 22 Aug, 2017 1 commit
  24. 11 Jul, 2017 1 commit
  25. 02 Jun, 2017 1 commit
    • Ryan Scott's avatar
      Use lengthIs and friends in more places · a786b136
      Ryan Scott authored
      While investigating #12545, I discovered several places in the code
      that performed length-checks like so:
      
      ```
      length ts == 4
      ```
      
      This is not ideal, since the length of `ts` could be much longer than 4,
      and we'd be doing way more work than necessary! There are already a slew
      of helper functions in `Util` such as `lengthIs` that are designed to do
      this efficiently, so I found every place where they ought to be used and
      did just that. I also defined a couple more utility functions for list
      length that were common patterns (e.g., `ltLength`).
      
      Test Plan: ./validate
      
      Reviewers: austin, hvr, goldfire, bgamari, simonmar
      
      Reviewed By: bgamari, simonmar
      
      Subscribers: goldfire, rwbarton, thomie
      
      Differential Revision: https://phabricator.haskell.org/D3622
      a786b136
  26. 20 Feb, 2017 1 commit
    • Simon Peyton Jones's avatar
      Change -dppr-ticks to -dsuppress-ticks · 2d5be63d
      Simon Peyton Jones authored
      I spent about two hours today hunting fruitlessly for a simplifier
      bug (when fixing Trac #13255), only to find that it was caused by
      -ddump-X silently suppressing all ticks in Core.
      
      I think this has happened to me once before.
      
      So I've changed to make tick-printing on by default (like coercions,
      etc), with a flag -dsuppress-ticks (like -dsuppress-coercions) to
      suppress them.
      
      Blargh.
      
      -dppr-ticks is still there, but deprecated.
      2d5be63d
  27. 01 Feb, 2017 1 commit
  28. 25 Jan, 2017 1 commit
  29. 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
  30. 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
  31. 18 Jan, 2017 1 commit
  32. 05 Jan, 2017 1 commit
    • Joachim Breitner's avatar
      Add a CSE pass to Stg (#9291) · 19d5c731
      Joachim Breitner authored
      This CSE pass only targets data constructor applications. This is
      probably the best we can do, as function calls and primitive operations
      might have side-effects.
      
      Introduces the flag -fstg-cse, enabled by default with -O for now. It
      might also be a good candiate for -O2.
      
      Differential Revision: https://phabricator.haskell.org/D2871
      19d5c731
  33. 16 Dec, 2016 1 commit
  34. 02 Nov, 2016 1 commit
  35. 10 Aug, 2016 1 commit
    • Ömer Sinan Ağacan's avatar
      Remove StgRubbishArg and CmmArg · 9684dbb1
      Ömer Sinan Ağacan authored
      The idea behind adding special "rubbish" arguments was in unboxed sum types
      depending on the tag some arguments are not used and we don't want to move some
      special values (like 0 for literals and some special pointer for boxed slots)
      for those arguments (to stack locations or registers). "StgRubbishArg" was an
      indicator to the code generator that the value won't be used. During Stg-to-Cmm
      we were then not generating any move or store instructions at all.
      
      This caused problems in the register allocator because some variables were only
      initialized in some code paths. As an example, suppose we have this STG: (after
      unarise)
      
          Lib.$WT =
              \r [dt_sit]
                  case
                      case dt_sit of {
                        Lib.F dt_siv [Occ=Once] ->
                            (#,,#) [1# dt_siv StgRubbishArg::GHC.Prim.Int#];
                        Lib.I dt_siw [Occ=Once] ->
                            (#,,#) [2# StgRubbishArg::GHC.Types.Any dt_siw];
                      }
                  of
                  dt_six
                  { (#,,#) us_giC us_giD us_giE -> Lib.T [us_giC us_giD us_giE];
                  };
      
      This basically unpacks a sum type to an unboxed sum with 3 fields, and then
      moves the unboxed sum to a constructor (`Lib.T`).
      
      This is the Cmm for the inner case expression (case expression in the scrutinee
      position of the outer case):
      
          ciN:
              ...
              -- look at dt_sit's tag
              if (_ciT::P64 != 1) goto ciS; else goto ciR;
          ciS: -- Tag is 2, i.e. Lib.F
              _siw::I64 = I64[_siu::P64 + 6];
              _giE::I64 = _siw::I64;
              _giD::P64 = stg_RUBBISH_ENTRY_info;
              _giC::I64 = 2;
              goto ciU;
          ciR: -- Tag is 1, i.e. Lib.I
              _siv::P64 = P64[_siu::P64 + 7];
              _giD::P64 = _siv::P64;
              _giC::I64 = 1;
              goto ciU;
      
      Here one of the blocks `ciS` and `ciR` is executed and then the execution
      continues to `ciR`, but only `ciS` initializes `_giE`, in the other branch
      `_giE` is not initialized, because it's "rubbish" in the STG and so we don't
      generate an assignment during code generator. The code generator then panics
      during the register allocations:
      
          ghc-stage1: panic! (the 'impossible' happened)
            (GHC version 8.1.20160722 for x86_64-unknown-linux):
                  LocalReg's live-in to graph ciY {_giE::I64}
      
      (`_giD` is also "rubbish" in `ciS`, but it's still initialized because it's a
      pointer slot, we have to initialize it otherwise garbage collector follows the
      pointer to some random place. So we only remove assignment if the "rubbish" arg
      has unboxed type.)
      
      This patch removes `StgRubbishArg` and `CmmArg`. We now always initialize
      rubbish slots. If the slot is for boxed types we use the existing `absentError`,
      otherwise we initialize the slot with literal 0.
      
      Reviewers: simonpj, erikd, austin, simonmar, bgamari
      
      Reviewed By: erikd
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2446
      9684dbb1
  36. 03 Aug, 2016 1 commit
  37. 25 Jul, 2016 1 commit
  38. 22 Jul, 2016 1 commit
    • Erik de Castro Lopo's avatar
      Fix the non-Linux build · d068220f
      Erik de Castro Lopo authored
      Summary:
      The recent Compact Regions commit (cf989ffe) builds fine on Linux
      but doesn't build on OS X r Windows.
      
      * rts/sm/CNF.c: Drop un-needed #includes.
      * Fix parenthesis usage with CPP ASSERT macro.
      * Fix format string in debugBelch messages.
      * Use stg_max() instead hand rolled inline max() function.
      
      Test Plan: Build on Linux, OS X and Windows
      
      Reviewers: gcampax, simonmar, austin, bgamari
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2421
      d068220f