1. 20 Sep, 2008 1 commit
    • simonpj@microsoft.com's avatar
      Tidy up the treatment of dead binders · 7e8cba32
      simonpj@microsoft.com authored
      This patch does a lot of tidying up of the way that dead variables are
      handled in Core.  Just the sort of thing to do on an aeroplane.
      
      * The tricky "binder-swap" optimisation is moved from the Simplifier
        to the Occurrence Analyser.  See Note [Binder swap] in OccurAnal.
        This is really a nice change.  It should reduce the number of
        simplifier iteratoins (slightly perhaps).  And it means that
        we can be much less pessimistic about zapping occurrence info
        on binders in a case expression.  
      
      * For example:
      	case x of y { (a,b) -> e }
        Previously, each time around, even if y,a,b were all dead, the
        Simplifier would pessimistically zap their OccInfo, so that we
        can't see they are dead any more.  As a result virtually no 
        case expression ended up with dead binders.  This wasn't Bad
        in itself, but it always felt wrong.
      
      * I added a check to CoreLint to check that a dead binder really
        isn't used.  That showed up a couple of bugs in CSE. (Only in
        this sense -- they didn't really matter.)
        
      * I've changed the PprCore printer to print "_" for a dead variable.
        (Use -dppr-debug to see it again.)  This reduces clutter quite a
        bit, and of course it's much more useful with the above change.
      
      * Another benefit of the binder-swap change is that I could get rid of
        the Simplifier hack (working, but hacky) in which the InScopeSet was
        used to map a variable to a *different* variable. That allowed me
        to remove VarEnv.modifyInScopeSet, and to simplify lookupInScopeSet
        so that it doesn't look for a fixpoint.  This fixes no bugs, but 
        is a useful cleanup.
      
      * Roman pointed out that Id.mkWildId is jolly dangerous, because
        of its fixed unique.  So I've 
      
           - localied it to MkCore, where it is private (not exported)
      
           - renamed it to 'mkWildBinder' to stress that you should only
             use it at binding sites, unless you really know what you are
             doing
      
           - provided a function MkCore.mkWildCase that emodies the most
             common use of mkWildId, and use that elsewhere
      
         So things are much better
      
      * A knock-on change is that I found a common pattern of localising
        a potentially global Id, and made a function for it: Id.localiseId
      7e8cba32
  2. 05 Sep, 2008 1 commit
  3. 28 Aug, 2008 1 commit
  4. 31 Jul, 2008 1 commit
  5. 20 Jul, 2008 1 commit
  6. 12 Apr, 2008 1 commit
  7. 22 Apr, 2008 2 commits
    • simonpj@microsoft.com's avatar
      Simplify SimplCont, plus some other small changes to the Simplifier · 53f99d84
      simonpj@microsoft.com authored
      The main change in this patch is this:
        
        * The Stop constructor of SimplCont no longer contains the OutType
          of the whole continuation.  This is a nice simplification in 
          lots of places where we build a Stop continuation.  For example,
          rebuildCall no longer needs to maintain the type of the function.
      
        * Similarly StrictArg no longer needs an OutType
      
        * The consequential complication is that contResultType (not called
          much) needs to be given the type of the thing in the middle.  No
          big deal.
      
        * Lots of other small knock-on effects
      
      Other changes in here
      
        * simplLazyBind does do the type-abstraction thing if there's
          a lambda inside.  See comments in simplLazyBind
      
        * simplLazyBind reduces simplifier iterations by keeping 
          unfolding information for stuff for which type abstraction is 
          done (see add_poly_bind)
      
      All of this came up when implementing System IF, but seems worth applying
      to the HEAD
      53f99d84
    • simonpj@microsoft.com's avatar
  8. 10 Apr, 2008 1 commit
    • simonpj@microsoft.com's avatar
      Ensure that arity is accurate in back end · 3dcb2a66
      simonpj@microsoft.com authored
      See Note [exprArity invariant] in CoreUtils.  In code generated by Happy
      I was seeing this after TidyPgm and CorePrep
      
      	f :: Any
      	f {arity 1} = id `cast` unsafe-co
      
      So f claimed to have arity 1 (because exprArity looked inside), but
      did not have any top-level lambdas (because its type is Any).  
      
      This triggered a slightly-obscure ASSERT failure in CoreToStg
      
      This patch 
      	- makes exprArity trim the arity if the type is not a function
      	- adds a stronger ASSERT in TidyPgm
      
      It's not the only way to solve this problem (see Note [exprArity invariant])
      but it's enough for now. 
      3dcb2a66
  9. 28 Feb, 2008 1 commit
  10. 06 Feb, 2008 1 commit
    • rl@cse.unsw.edu.au's avatar
      Teach cheapEqExpr about casts · a4835b8b
      rl@cse.unsw.edu.au authored
      Previously, cheapEqExpr would always return False if it encountered a cast.
      This was bad for two reasons. Firstly, CSE (which uses cheapEqExpr to compare
      expressions) never eliminated expressions which contained casts and secondly,
      it was inconsistent with exprIsBig. This patch fixes this.
      a4835b8b
  11. 30 Jan, 2008 1 commit
  12. 25 Jan, 2008 1 commit
  13. 16 Jan, 2008 1 commit
    • simonpj@microsoft.com's avatar
      A bottoming function should have infinite arity · decb48fc
      simonpj@microsoft.com authored
      I can't think how this one escaped for so long, but
      	(error "foo") 
      should have arityType ABot, just as 'error' itself does.
      
      This improves eta expansion.  I spotted it when looking at the function
      
        Data.Array.Parallel.Arr.BBArr.writeMBB
      
      in the ndp package.
      
      decb48fc
  14. 03 Oct, 2007 1 commit
  15. 01 Oct, 2007 1 commit
  16. 04 Sep, 2007 1 commit
  17. 03 Sep, 2007 1 commit
  18. 01 Sep, 2007 1 commit
  19. 28 Aug, 2007 1 commit
    • chak@cse.unsw.edu.au.'s avatar
      Type checking for type synonym families · 5822cb8d
      chak@cse.unsw.edu.au. authored
      This patch introduces type checking for type families of which associated
      type synonyms are a special case. E.g.
      
              type family Sum n m
      
              type instance Sum Zero n = n
              type instance Sum (Succ n) m = Succ (Sum n m)
      
      where
      
              data Zero       -- empty type
              data Succ n     -- empty type
      
      In addition we support equational constraints of the form:
      
              ty1 ~ ty2
      
      (where ty1 and ty2 are arbitrary tau types) in any context where
      type class constraints are already allowed, e.g.
      
              data Equals a b where
                      Equals :: a ~ b => Equals a b
      
      The above two syntactical extensions are disabled by default. Enable
      with the -XTypeFamilies flag.
      
      For further documentation about the patch, see:
      
              * the master plan
                http://hackage.haskell.org/trac/ghc/wiki/TypeFunctions
      
              * the user-level documentation
                http://haskell.org/haskellwiki/GHC/Indexed_types
      
      The patch is mostly backwards compatible, except for:
      
              * Some error messages have been changed slightly.
      
              * Type checking of GADTs now requires a bit more type declarations:
                not only should the type of a GADT case scrutinee be given, but also
                that of any identifiers used in the branches and the return type.
      
      Please report any unexpected behavior and incomprehensible error message 
      for existing code.
      
      Contributors (code and/or ideas):
              Tom Schrijvers
              Manuel Chakravarty
              Simon Peyton-Jones
              Martin Sulzmann 
      with special thanks to Roman Leshchinskiy
      5822cb8d
  20. 09 Aug, 2007 1 commit
  21. 11 May, 2007 1 commit
  22. 03 May, 2007 1 commit
  23. 02 May, 2007 2 commits
  24. 25 Apr, 2007 1 commit
  25. 09 Feb, 2007 1 commit
    • simonpj@microsoft.com's avatar
      Major improvement to SpecConstr · cac2aca1
      simonpj@microsoft.com authored
      This patch improves the SpecConstr pass, by 
        a) making it work with join points
        b) making it generate specialisations transitively
      
      As part of it, SpecConstr now carries a substitution with it, which
      runs over the whole program as it goes.  This turned out to be 
      a big win; simplified the implementation quite a bit.
      
      I have *disabled* the specialisation on lambdas; it's pretty fragile,
      and sometimes generates more and more specialisations. Something to
      come back to, perhaps.
      
      I rejigged the flag-handling a bit.  Now the specification of passes
      in DynFlags is a bit nicer; see
      	- optLevelFlags top-level data structure
      	- runWhen function
      	- CoreDoPasses constructor
      
      There are now command-line flags
      	-fspec-constr
      	-fliberate-case
      	-fspec-threshold=N
      which do the obvious thing.  -O2 switches on both spec-constr and liberate-case.
      You can use -fno-liberate-case, -fno-spec-constr after -O2 to switch them off again.
      
      The spec-threshold applies to both these transformations; default value 200 for now.
      
      
      
      
      cac2aca1
  26. 05 Feb, 2007 1 commit
    • simonpj@microsoft.com's avatar
      Establish the CoreSyn let/app invariant · 7b01315d
      simonpj@microsoft.com authored
      This patch clears up a long-standing wart.   For some time it's been the
      case that 
      	the RHS of a non-recursive let can be unlifed iff 
      	the RHS is ok-for-speculation
      
      This patch extends the invariant to the argument of an App, and 
      establishes it by the smart constructors mkDsApp, mkDsApps in the desugarer.
      
      Once established, it should be maintained by the optimiser.
      
      This tides up some awkward cases, notably in exprIsHNF, and I think it
      fixes a outright strictness bug in Simplify.prepareRhs.
      7b01315d
  27. 03 Dec, 2006 1 commit
    • Ian Lynagh's avatar
      MERGE: In hashExpr, use Word32 rather than relying on wrapping behaviour of Int · df95de0b
      Ian Lynagh authored
      Fixes #952, as it turns out.
      
      When compiling via C, we are at the mercy of C's undefined behaviour
      with respect to overflow of signed integer operations, and this was
      biting us here.
      
      Perhaps we should always add the -fwrapv flag to gcc, but since
      Haskell doesn't define overflow on Int either, it seemed the right
      thing to do to fix this code anyway.
      df95de0b
  28. 29 Nov, 2006 1 commit
    • andy@galois.com's avatar
      TickBox representation change · 8100cd43
      andy@galois.com authored
      This changes the internal representation of TickBoxes,
      from
              Note (TickBox "module" n)  <expr>
      into
      
              case tick<module,n> of
                _ -> <expr>
      
      tick has type :: #State #World, when the module and tick numbe
      are stored inside IdInfo.
      
      Binary tick boxes change from
      
               Note (BinaryTickBox "module" t f) <expr>
      
      into
      
                btick<module,t,f> <expr>
      
      btick has type :: Bool -> Bool, with the module and tick number
      stored inside IdInfo.
      8100cd43
  29. 24 Nov, 2006 1 commit
    • simonpj@microsoft.com's avatar
      Improve hashing of expressions · 9ba6b031
      simonpj@microsoft.com authored
      We were getting too many cases where different expressions map to the
      same hash code (which shows up in CSE). This patch tries to improve
      the hash algorithm a bit.
      9ba6b031
  30. 25 Oct, 2006 1 commit
  31. 24 Oct, 2006 1 commit
    • andy@galois.com's avatar
      Haskell Program Coverage · d5934bbb
      andy@galois.com authored
      This large checkin is the new ghc version of Haskell
      Program Coverage, an expression-level coverage tool for Haskell.
      
      Parts:
      
       - Hpc.[ch] - small runtime support for Hpc; reading/writing *.tix files.
       - Coverage.lhs - Annotates the HsSyn with coverage tickboxes.
        - New Note's in Core,
            - TickBox      -- ticked on entry to sub-expression
            - BinaryTickBox  -- ticked on exit to sub-expression, depending
      	       	     -- on the boolean result.
      
        - New Stg level TickBox (no BinaryTickBoxes, though) 
      
      You can run the coverage tool with -fhpc at compile time. 
      Main must be compiled with -fhpc. 
      				      
      d5934bbb
  32. 13 Oct, 2006 1 commit
    • simonpj@microsoft.com's avatar
      Add assertion checks for mkCoVar/mkTyVar · ac704fca
      simonpj@microsoft.com authored
      A type variable has a flag saying whether it is a *type* variable or
      a *coercion* variable.  This patch adds assertions to check the flag.
      
      And it adds fixes to places which were Wrong (and hence fired the
      assertion)! 
      
      Also removed isCoVar from Coercion, since it's done by Var.isCoVar.
      
      
      ac704fca
  33. 11 Oct, 2006 2 commits
    • Simon Marlow's avatar
      ab22f4e6
    • Simon Marlow's avatar
      Module header tidyup, phase 1 · 49c98d14
      Simon Marlow authored
      This patch is a start on removing import lists and generally tidying
      up the top of each module.  In addition to removing import lists:
      
         - Change DATA.IOREF -> Data.IORef etc.
         - Change List -> Data.List etc.
         - Remove $Id$
         - Update copyrights
         - Re-order imports to put non-GHC imports last
         - Remove some unused and duplicate imports
      49c98d14
  34. 05 Oct, 2006 1 commit
  35. 29 Sep, 2006 1 commit
  36. 27 Sep, 2006 1 commit
  37. 20 Sep, 2006 1 commit
    • chak@cse.unsw.edu.au.'s avatar
      Small refactoring · 7676e57a
      chak@cse.unsw.edu.au. authored
      Mon Sep 18 17:41:37 EDT 2006  Manuel M T Chakravarty <chak@cse.unsw.edu.au>
        * Small refactoring
        Wed Aug  9 04:41:54 EDT 2006  simonpj@microsoft.com
          * Small refactoring
      7676e57a