1. 05 Sep, 2017 1 commit
  2. 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
  3. 29 Aug, 2017 1 commit
  4. 18 Aug, 2017 1 commit
  5. 02 Aug, 2017 1 commit
  6. 01 Aug, 2017 1 commit
  7. 31 Jul, 2017 1 commit
  8. 30 Jul, 2017 1 commit
  9. 28 Jul, 2017 2 commits
  10. 26 Jul, 2017 1 commit
    • Simon Peyton Jones's avatar
      Fix binder visiblity for default methods · 75bf11c0
      Simon Peyton Jones authored
      Trac #13998 showed that default methods were getting bogus tyvar
      binder visiblity info; and that it matters in the code genreated
      by the default-method fill-in mechanism
      
      * The actual fix: in TcTyDecls.mkDefaultMethodType, make TyVarBinders
        with the right visibility info by getting TyConBinders from the
        class TyCon.  (Previously we made up visiblity info, but that
        caused #13998.)
      
      * Define TyCon.tyConTyVarBinders :: [TyConBinder] -> [TyVarBinder]
        which can build correct forall binders for
          a) default methods (Trac #13998)
          b) data constructors
        This was originally BuildTyCl.mkDataConUnivTyVarBinders
      
      * Move mkTyVarBinder, mkTyVarBinders from Type to Var
      75bf11c0
  11. 20 Jul, 2017 1 commit
  12. 19 Jul, 2017 1 commit
    • Ben Gamari's avatar
      dmdAnal: Ensure that ExnStr flag isn't dropped inappropriately · c940e3b9
      Ben Gamari authored
      This fixes #13977 and consequently #13615. Here an optimization in the
      demand analyser was too liberal, causing us to drop the ExnStr flag and
      consequently resulting in incorrect demand signatures. This manifested
      as a segmentation fault in #13615 as we incorrectly concluded that an
      application of catchRetry# would bottom.
      
      Specifically, we had
      
          orElse' :: STM a -> STM a -> STM a
          orElse' x = catchRetry# x y
            where y = {- some action -}
      
      Where the catchRetry# primop places a demand of <xC(S),1*C1(U)> on its
      first argument. However, due to #13977 the demand analyser would assign
      a demand of <C(S),1*C1(U)> on the first argument of orElse'. Note the
      missing `x`.
      
          case orElse' bottomingAction anotherAction of { x -> Just x }
      
      being transformed to,
      
          case orElse' bottomingAction anotherAction of {}
      
      by the simplifier. This would naturally blow up when orElse' returned at
      runtime, causing the segmentation fault described in #13615.
      
      Test Plan: Validate, perhaps add a testcase
      
      Reviewers: austin, simonpj
      
      Reviewed By: simonpj
      
      Subscribers: rwbarton, thomie
      
      GHC Trac Issues: #13977, #13615
      
      Differential Revision: https://phabricator.haskell.org/D3756
      c940e3b9
  13. 18 Jul, 2017 1 commit
    • niteria's avatar
      Make module membership on ModuleGraph faster · b8fec695
      niteria authored
      When loading/reloading with a large number of modules
      (>5000) the cost of linear lookups becomes significant.
      
      The changes here made `:reload` go from 6s to 1s on my
      test case.
      
      The bottlenecks were `needsLinker` in `DriverPipeline` and
      `getModLoop` in `GhcMake`.
      
      Test Plan: ./validate
      
      Reviewers: simonmar, austin, bgamari
      
      Subscribers: thomie, rwbarton
      
      Differential Revision: https://phabricator.haskell.org/D3703
      b8fec695
  14. 29 Jun, 2017 1 commit
  15. 28 Jun, 2017 2 commits
  16. 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
  17. 29 May, 2017 1 commit
  18. 26 May, 2017 1 commit
    • Simon Peyton Jones's avatar
      Some tidying up of type pretty-printing · ad14efd5
      Simon Peyton Jones authored
      Triggered by the changes in #13677, I ended up doing a bit of
      refactoring in type pretty-printing.
      
      * We were using TyOpPrec and FunPrec rather inconsitently, so
        I made it consisent.
      
      * That exposed the fact that we were a bit undecided about whether
        to print
           a + b -> c + d   vs   (a+b) -> (c+d)
        and similarly
           a ~ [b] => blah  vs   (a ~ [b]) => blah
      
        I decided to make TyOpPrec and FunPrec compare equal
        (in BasicTypes), so (->) is treated as equal precedence with
        other type operators, so you get the unambiguous forms above,
        even though they have more parens.
      
        We could readily reverse this decision.
        See Note [Type operator precedence] in BasicTypes
      
      * I fixed a bug in pretty-printing of HsType where some
        parens were omitted by mistake.
      ad14efd5
  19. 22 May, 2017 1 commit
  20. 19 May, 2017 1 commit
  21. 17 May, 2017 1 commit
    • Simon Peyton Jones's avatar
      Handle type-lets better · d6461f96
      Simon Peyton Jones authored
      Core allows non-recursive type-lets, thus
      
         let a = TYPE ty in ...
      
      They are substituted away very quickly, but it's convenient for
      some passes to produce them (rather than to have to substitute
      immediately).
      
      Trac #13708 tried the effect of not running the simplifer at all
      (a rather bizarre thing to do, but still).  That showed that some
      passes crashed because they always treated a let-bounder binder
      as an Id.  This patch adds some easy fixes.
      d6461f96
  22. 12 May, 2017 1 commit
  23. 11 May, 2017 1 commit
  24. 10 May, 2017 1 commit
  25. 08 May, 2017 1 commit
  26. 05 May, 2017 1 commit
  27. 30 Apr, 2017 1 commit
  28. 29 Apr, 2017 1 commit
  29. 28 Apr, 2017 2 commits
    • Simon Peyton Jones's avatar
      Re-engineer caseRules to add tagToEnum/dataToTag · 193664d4
      Simon Peyton Jones authored
      See Note [Scrutinee Constant Folding] in SimplUtils
      
      * Add cases for tagToEnum and dataToTag. This is the main new
        bit.  It allows the simplifier to remove the pervasive uses
        of     case tagToEnum (a > b) of
                  False -> e1
                  True  -> e2
        and replace it by the simpler
               case a > b of
                  DEFAULT -> e1
                  1#      -> e2
        See Note [caseRules for tagToEnum]
        and Note [caseRules for dataToTag] in PrelRules.
      
      * This required some changes to the API of caseRules, and hence
        to code in SimplUtils.  See Note [Scrutinee Constant Folding]
        in SimplUtils.
      
      * Avoid duplication of work in the (unusual) case of
           case BIG + 3# of b
             DEFAULT -> e1
             6#      -> e2
      
        Previously we got
           case BIG of
             DEFAULT -> let b = BIG + 3# in e1
             3#      -> let b = 6#       in e2
      
        Now we get
           case BIG of b#
             DEFAULT -> let b = b' + 3# in e1
             3#      -> let b = 6#      in e2
      
      * Avoid duplicated code in caseRules
      
      A knock-on refactoring:
      
      * Move Note [Word/Int underflow/overflow] to Literal, as
        documentation to accompany mkMachIntWrap etc; and get
        rid of PrelRuls.intResult' in favour of mkMachIntWrap
      193664d4
    • Simon Peyton Jones's avatar
      Move dataConTagZ to DataCon · 1cae73aa
      Simon Peyton Jones authored
      Just a simple refactoring to remove duplication
      1cae73aa
  30. 18 Apr, 2017 1 commit
  31. 07 Apr, 2017 1 commit
    • Simon Peyton Jones's avatar
      Do Note [Improving seq] always · f0d98fc6
      Simon Peyton Jones authored
      This patch fixes Trac #13468, and at the same time makes the
      code simpler and more uniform.  In particular, I've eliminated
      the awkward conflict between the old built-in rule for seq
      (which elimianted a cast), and the desire to make case scrutinse
      a data type by doing type-family reduction (which adds a cast).
      
      Nice.
      f0d98fc6
  32. 05 Apr, 2017 1 commit
  33. 01 Apr, 2017 1 commit
    • rwbarton's avatar
      Stamp out space leaks from demand analysis · f2b10f35
      rwbarton authored
      This reduces peak memory usage by ~30% on my test case (DynFlags),
      and (probably as a result of reduced GC work) decreases compilation
      time by a few percent as well.
      
      Also fix a bug in seqStrDmd so that demeand info is fully evaluated.
      
      Reviewers: simonpj, austin, bgamari
      
      Reviewed By: bgamari
      
      Subscribers: dfeuer, thomie
      
      Differential Revision: https://phabricator.haskell.org/D3400
      f2b10f35
  34. 29 Mar, 2017 1 commit
    • Sergei Trofimovich's avatar
      unique: fix UNIQUE_BITS crosscompilation (Trac #13491) · 01b062ec
      Sergei Trofimovich authored
      
      
      The #13491 manifests best when we try to crosscompile
      from 32-bit (i386-linux) to 64-bit (powerpc64-linux)
      system:
          ./configure --target=powerpc64-unknown-linux-gnu
      
      The build fails at assembly time:
        "inplace/bin/ghc-stage1" ...  -c rts/StgStartup.cmm
          /tmp/ghc19687_0/ghc_4.s: Assembler messages:
      
          /tmp/ghc19687_0/ghc_4.s:11:0: error:
               Error: unknown pseudo-op: `.l'
             |
          11 | .L<\x00>4:
             | ^
      
      That happens because UNIQUE_BITS is defined in terms
      of WORD_SIZE_IN_BITS macro:
          #define UNIQUE_BITS (WORD_SIZE_IN_BITS - 8)
      
      WORD_SIZE_IN_BITS is 64 bits (equals to target value)
      while ghc-stage1 is still running on i386-linux
      
      The fix is to stop relying on target macros and use
      host's 'sizeof (HsInt)' and 'finiteBitSize' way to
      determine unique layout.
      Signed-off-by: default avatarSergei Trofimovich <slyfox@gentoo.org>
      
      Test Plan: build i386-to-powerpc64 crosscompiler
      
      Reviewers: rwbarton, austin, bgamari
      
      Reviewed By: bgamari
      
      Subscribe...
      01b062ec
  35. 28 Mar, 2017 1 commit
    • Joachim Breitner's avatar
      Zap Call Arity info in the simplifier · e07211f7
      Joachim Breitner authored
      As #13479 shows, there are corner cases where the simplifier decides to
      not eta-expand a function as much as its call arity would suggest, but
      instead transforms the code that the call arity annotation becomes a
      lie.
      
      As the call arity information is only meant to be used by the
      immediatelly following simplifier run, it makes sense to simply zap the
      information there.
      
      Differential Revision: https://phabricator.haskell.org/D3390
      e07211f7
  36. 24 Mar, 2017 1 commit
  37. 14 Mar, 2017 1 commit