1. 25 Jan, 2016 1 commit
    • Simon Peyton Jones's avatar
      Fix exprIsHNF (Trac #11248) · 3c060f36
      Simon Peyton Jones authored
      Blimey!  CoreUtils.exprIsHNFlike had not one but two bugs.
      
       * is_hnf_like treated coercion args like type args
         (result: exprIsHNF might wrongly say True)
      
       * app_is_value treated type args like value args
         (result: exprIsHNF might wrongly say False)
      
      Bizarre.  This goes back to at least 2012. It's amazing that it
      hasn't caused more trouble.
      
      It was discovered by a Lint error when compiling Trac #11248 with -O.
      3c060f36
  2. 20 Jan, 2016 2 commits
    • Simon Peyton Jones's avatar
      Oops. Add missing close-comment · 0373a845
      Simon Peyton Jones authored
      This fixes 514bac26 for Trac #11172.  Sorry!
      0373a845
    • Simon Peyton Jones's avatar
      Fix combineIdenticalAlts · 514bac26
      Simon Peyton Jones authored
      This long-standing bug in CoreUtils.combineIdenticalAlts
      was shown up by Trac #11172. The effect was that it returned
      a correct set of alternatives, but a bogus set of "impossible
      default constructors".  That meant that we subsequently
      removed all the alternatives from a case, and hence ended
      up with a bogusly empty case that should not have been empty.
      
      See Note [Care with impossible-constructors when
      combining alternatives] in CoreUtils.
      514bac26
  3. 19 Jan, 2016 1 commit
    • niteria's avatar
      Check InScopeSet in substTy and provide substTyUnchecked · 9d33adb6
      niteria authored
      This adds sanity checks to `substTy` that implement:
      
      > when calling substTy subst ty it should be the case that the in-scope
      > set in the substitution is a superset of
      > * The free vars of the range of the substitution
      > * The free vars of ty minus the domain of the substitution
      
      and replaces violators with unchecked version. The violators were found
      by running the GHC test suite.
      
      This ensures that I can work on this incrementally and that what I fix won't
      be undone by some other change.
      
      It also includes a couple of fixes that I've already done.
      
      Test Plan: ./validate
      
      Reviewers: simonmar, goldfire, simonpj, austin, bgamari
      
      Reviewed By: simonpj, bgamari
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D1792
      
      GHC Trac Issues: #11371
      9d33adb6
  4. 18 Jan, 2016 1 commit
    • Jan Stolarek's avatar
      Replace calls to `ptext . sLit` with `text` · b8abd852
      Jan Stolarek authored
      Summary:
      In the past the canonical way for constructing an SDoc string literal was the
      composition `ptext . sLit`.  But for some time now we have function `text` that
      does the same.  Plus it has some rules that optimize its runtime behaviour.
      This patch takes all uses of `ptext . sLit` in the compiler and replaces them
      with calls to `text`.  The main benefits of this patch are clener (shorter) code
      and less dependencies between module, because many modules now do not need to
      import `FastString`.  I don't expect any performance benefits - we mostly use
      SDocs to report errors and it seems there is little to be gained here.
      
      Test Plan: ./validate
      
      Reviewers: bgamari, austin, goldfire, hvr, alanz
      
      Subscribers: goldfire, thomie, mpickering
      
      Differential Revision: https://phabricator.haskell.org/D1784
      b8abd852
  5. 31 Dec, 2015 1 commit
    • Simon Peyton Jones's avatar
      Improve exprIsBottom · 0579fe99
      Simon Peyton Jones authored
      This fixes Trac #11290, by being sligthtly cleverer about finding
      what expressions are bottom.  Actually this might have minor
      other side benefits.
      0579fe99
  6. 26 Dec, 2015 1 commit
    • eir@cis.upenn.edu's avatar
      Fix #11287. · da69358b
      eir@cis.upenn.edu authored
      Happily, the fix is simply deleting some old code. I love it when
      that happens.
      da69358b
  7. 17 Dec, 2015 1 commit
  8. 11 Dec, 2015 1 commit
    • eir@cis.upenn.edu's avatar
      Add kind equalities to GHC. · 67465497
      eir@cis.upenn.edu authored
      This implements the ideas originally put forward in
      "System FC with Explicit Kind Equality" (ICFP'13).
      
      There are several noteworthy changes with this patch:
       * We now have casts in types. These change the kind
         of a type. See new constructor `CastTy`.
      
       * All types and all constructors can be promoted.
         This includes GADT constructors. GADT pattern matches
         take place in type family equations. In Core,
         types can now be applied to coercions via the
         `CoercionTy` constructor.
      
       * Coercions can now be heterogeneous, relating types
         of different kinds. A coercion proving `t1 :: k1 ~ t2 :: k2`
         proves both that `t1` and `t2` are the same and also that
         `k1` and `k2` are the same.
      
       * The `Coercion` type has been significantly enhanced.
         The documentation in `docs/core-spec/core-spec.pdf` reflects
         the new reality.
      
       * The type of `*` is now `*`. No more `BOX`.
      
       * Users can write explicit kind variables in their code,
         anywhere they can write type variables. ...
      67465497
  9. 04 Dec, 2015 1 commit
    • Simon Peyton Jones's avatar
      Case-of-empty-alts is trivial (Trac #11155) · 1c9fd3f1
      Simon Peyton Jones authored
      As you'll see from Trac #11155, the code generator was confused
      by a binding let x = y in ....   Why did that happen? Because of
      a (case y of {}) expression on the RHS.
      
      The right thing is just to expand what a "trivial" expression is.
      
      See Note [Empty case is trivial] in CoreUtils.
      1c9fd3f1
  10. 30 Jul, 2015 1 commit
    • Simon Peyton Jones's avatar
      Define DsUtils.mkCastDs and use it · 92d25672
      Simon Peyton Jones authored
      This change avoids a spurious WARNing from mkCast.  In the output of
      the desugarer (only, I think) we can have a cast where the type of the
      expression and cast don't syntactically match, because of an enclosing
      type-let binding.
      92d25672
  11. 16 Jul, 2015 2 commits
  12. 18 Jun, 2015 1 commit
  13. 01 Jun, 2015 1 commit
  14. 24 Mar, 2015 2 commits
  15. 23 Mar, 2015 4 commits
  16. 18 Mar, 2015 1 commit
  17. 10 Feb, 2015 1 commit
  18. 04 Feb, 2015 1 commit
    • Simon Marlow's avatar
      Fix a profiling bug · daed18c3
      Simon Marlow authored
      Summary:
      We were erroneously discarding SCCs on function-typed variables.
      These can affect the call stack, so we have to retain them.  The bug
      was introduced during the recent SourceNote refactoring.
      
      This is an alternative to the fix proposed in D616.  I also added the
      scc005 test from that diff, which works with this change.
      
      While I was here, I also fixed up the other profiling tests, marking a
      few as expect_broken_for(10037) where the opt/unopt output differs in
      non-fatal ways.
      
      Test Plan: profiling tests
      
      Reviewers: scpmw, ezyang, austin
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D636
      
      GHC Trac Issues: #10007
      daed18c3
  19. 19 Jan, 2015 1 commit
  20. 23 Dec, 2014 2 commits
    • Simon Peyton Jones's avatar
      Eliminate so-called "silent superclass parameters" · a6f0f5ab
      Simon Peyton Jones authored
      The purpose of silent superclass parameters was to solve the
      awkward problem of superclass dictinaries being bound to bottom.
      See THE PROBLEM in Note [Recursive superclasses] in TcInstDcls
      
      Although the silent-superclass idea worked,
      
        * It had non-local consequences, and had effects even in Haddock,
          where we had to discard silent parameters before displaying
          instance declarations
      
        * It had unexpected peformance costs, shown up by Trac #3064 and its
          test case.  In monad-transformer code, when constructing a Monad
          dictionary you had to pass an Applicative dictionary; and to
          construct that you neede a Functor dictionary. Yet these extra
          dictionaries were often never used.  (All this got much worse when
          we added Applicative as a superclass of Monad.) Test T3064
          compiled *far* faster after silent superclasses were eliminated.
      
        * It introduced new bugs.  For example SilentParametersOverlapping,
          T5051, and T7862, all failed to compile because of instance overlap
          directly because of the silent-superclass trick.
      
      So this patch takes a new approach, which I worked out with Dimitrios
      in the closing hours before Christmas.  It is described in detail
      in THE PROBLEM in Note [Recursive superclasses] in TcInstDcls.
      
      Seems to work great!
      
      Quite a bit of knock-on effect
      
       * The main implementation work is in tcSuperClasses in TcInstDcls
         Everything else is fall-out
      
       * IdInfo.DFunId no longer needs its n-silent argument
         * Ditto IDFunId in IfaceSyn
         * Hence interface file format changes
      
       * Now that DFunIds do not have silent superclass parameters, printing
         out instance declarations is simpler. There is tiny knock-on effect
         in Haddock, so that submodule is updated
      
       * I realised that when computing the "size of a dictionary type"
         in TcValidity.sizePred, we should be rather conservative about
         type functions, which can arbitrarily increase the size of a type.
         Hence the new datatype TypeSize, which has a TSBig constructor for
         "arbitrarily big".
      
       * instDFunType moves from TcSMonad to Inst
      
       * Interestingly, CmmNode and CmmExpr both now need a non-silent
         (Ord r) in a couple of instance declarations. These were previously
         silent but must now be explicit.
      
       * Quite a bit of wibbling in error messages
      a6f0f5ab
    • Sergei Trofimovich's avatar
      dwarf: sync getIdFromTrivialExpr with exprIsTrivial (test break028 and others) · 30fdf86e
      Sergei Trofimovich authored
      Summary:
      The bug manifests when built with
          EXTRA_HC_OPTS += -g
      
      +++ ./ghci.debugger/scripts/break028.run.stderr 2014-12-19 23:08:46.199876621 +0000
      @@ -0,0 +1,11 @@
      +ghc-stage2: panic! (the 'impossible' happened)
      +  (GHC version 7.9.20141219 for x86_64-unknown-linux):
      +       getIdFromTrivialExpr x_alJ
      +
      +Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug
      
      
      +
      +
      +<interactive>:3:1: Not in scope: ‘g’
      +
      +<interactive>:3:3: Not in scope: data constructor ‘False’
      Signed-off-by: default avatarSergei Trofimovich <siarheit@google.com>
      
      Reviewers: simonmar, austin, scpmw
      
      Reviewed By: scpmw
      
      Subscribers: carter, thomie
      
      Differential Revision: https://phabricator.haskell.org/D580
      30fdf86e
  21. 17 Dec, 2014 1 commit
    • Simon Peyton Jones's avatar
      Improve TidyPgm.hasCafRefs to account for Integer literals (Trac #8525) · 6b11bab6
      Simon Peyton Jones authored
      See Note [Disgusting computation of CafRefs] in TidyPgm.
      
      Also affects CoreUtils.rhsIsStatic.
      
      The real solution here is to compute CAF and arity information
      from the STG-program, and feed it back to tidied program for
      the interface file and later GHCi clients.  A battle for another
      day.
      
      But at least this commit reduces the number of gratuitous CAFs, and
      hence SRT entries.  And kills off a batch of ASSERT failures.
      6b11bab6
  22. 16 Dec, 2014 2 commits
    • Peter Wortmann's avatar
      Annotation linting · 07d604fa
      Peter Wortmann authored
      This adds a way by which we can make sure that the Core passes treat
      annotations right: We run them twice and compare the results.
      
      The main problem here is that Core equivalence is awkward: We do not
      want the comparison to care about the order of, say, top-level or
      recursive bindings. This is important even if GHC generally generates
      the bindings in the right order - after all, if something goes wrong
      we don't want linting to dump out the whole program as the offense.
      
      So instead we do some heuristic matching - first greedily match
      everything that's easy, then match the rest by label order. This
      should work as long as GHC generates the labels in roughly the same
      order for both pass runs.  In practice it seems to work alright.
      
      We also check that IdInfos match, as this might cause hard-to-spot
      bugs down the line (I had at least one bug because unfolding guidance
      didn't match!). We especially check unfoldings up until the point
      where it might get us into an infinite loop.
      
      (From Phabricator D169)
      07d604fa
    • Peter Wortmann's avatar
      Source notes (Core support) · 993975d3
      Peter Wortmann authored
      This patch introduces "SourceNote" tickishs that link Core to the
      source code that generated it. The idea is to retain these source code
      links throughout code transformations so we can eventually relate
      object code all the way back to the original source (which we can,
      say, encode as DWARF information to allow debugging).  We generate
      these SourceNotes like other tickshs in the desugaring phase. The
      activating command line flag is "-g", consistent with the flag other
      compilers use to decide DWARF generation.
      
      Keeping ticks from getting into the way of Core transformations is
      tricky, but doable. The changes in this patch produce identical Core
      in all cases I tested -- which at this point is GHC, all libraries and
      nofib. Also note that this pass creates *lots* of tick nodes, which we
      reduce somewhat by removing duplicated and overlapping source
      ticks. This will still cause significant Tick "clumps" - a possible
      future optimization could be to make Tick carry a list of Tickishs
      instead of one at a time.
      
      (From Phabricator D169)
      993975d3
  23. 03 Dec, 2014 1 commit
  24. 19 Sep, 2014 1 commit
  25. 07 Aug, 2014 3 commits
    • Gabor Greif's avatar
      Fix some typos in recent comments/notes · 18ac546d
      Gabor Greif authored
      18ac546d
    • Simon Peyton Jones's avatar
      Extensive Notes on can_fail and has_side_effects · ab6480b8
      Simon Peyton Jones authored
      In fixing Trac #9390 I discovered that I *still* didn't really understand
      what the can_fail and has_side_effects properties of a PrimOp mean, precisely.
      
      The big new things I learned are
      
      * has_side_effects needs to be true only of *write* effects,
        Reads (which are, strictly speaking, effects) don't matter here.
      
      * has_side_effects must be true of primops that can throw a synchronous
        Haskell exception (eg raiseIO#)
      
      * can_fail is true only of primops that can cause an *unchecked* (not
        Haskell) system exception, like divide by zero, or accessing memory
        out of range through an array read or write.
      
      I've documented all this now.  The changes in this patch are only
      in comments.
      ab6480b8
    • Simon Peyton Jones's avatar
      Comments and white space · 61baf710
      Simon Peyton Jones authored
      61baf710
  26. 11 Jun, 2014 1 commit
    • eir@cis.upenn.edu's avatar
      Fix #9062. · e79e2c39
      eir@cis.upenn.edu authored
      Removed (pprEqPred (coercionKind co)) in favor of
      (pprType (coercionType co)).
      
      Also had to make "~R#" a *symbolic* identifier and BuiltInSyntax
      to squelch prefix notation and module prefixes in output. These
      changes are both sensible independent of #9062.
      e79e2c39
  27. 15 May, 2014 1 commit
    • Herbert Valerio Riedel's avatar
      Add LANGUAGE pragmas to compiler/ source files · 23892440
      Herbert Valerio Riedel authored
      In some cases, the layout of the LANGUAGE/OPTIONS_GHC lines has been
      reorganized, while following the convention, to
      
      - place `{-# LANGUAGE #-}` pragmas at the top of the source file, before
        any `{-# OPTIONS_GHC #-}`-lines.
      
      - Moreover, if the list of language extensions fit into a single
        `{-# LANGUAGE ... -#}`-line (shorter than 80 characters), keep it on one
        line. Otherwise split into `{-# LANGUAGE ... -#}`-lines for each
        individual language extension. In both cases, try to keep the
        enumeration alphabetically ordered.
        (The latter layout is preferable as it's more diff-friendly)
      
      While at it, this also replaces obsolete `{-# OPTIONS ... #-}` pragma
      occurences by `{-# OPTIONS_GHC ... #-}` pragmas.
      23892440
  28. 08 May, 2014 1 commit
  29. 17 Dec, 2013 1 commit
  30. 12 Dec, 2013 1 commit