[project @ 2005-01-31 13:25:33 by simonpj]
authorsimonpj <unknown>
Mon, 31 Jan 2005 13:25:48 +0000 (13:25 +0000)
committersimonpj <unknown>
Mon, 31 Jan 2005 13:25:48 +0000 (13:25 +0000)
commitf25b9225f77ca8aa097a9acb4b5be27daea94891
tree3c2a5c135a7da91fba04b51cda7ce5ef98a6b091
parent04612d54b51bebf809717d1cf0242efb6294ee59
[project @ 2005-01-31 13:25:33 by simonpj]
---------------------------
Types and evaluated-ness in
  CoreTidy and CorePrep
---------------------------

This commmit fixes two problems.

1.  DataToTagOp requires its argument to be evaluated, otherwise it silently
    gives the wrong answer.  This was not happening because we had
case (tag2Enum x) of y -> ...(dataToTag y)...
    and the tag2Enum was being inlined (it's non-speculative), giving
...(dataToTag (tag2Enum x))...

    Rather than relying on a somewhat-delicate global invariant, CorePrep
    now establishes the invariant that DataToTagOp's argument is evaluated.
    It does so by putting up-to-date is-evaluated information into each
    binder's UnfoldingInfo; not a full unfolding, just the (OtherCon [])
    for evaluated binders.

    Then there's a special case for DataToTag where applications are dealt with.

    Finally, we make DataToTagOp strict, which it really is.

2.  CoreTidy now does GADT refinement as it goes. This is important to ensure that
    each variable occurrence has informative type information, which in turn is
    essential to make exprType work (otherwise it can simply crash).
    [This happened in test gadt/tdpe]

    CorePrep has the same problem, but the solution is a little different:
    when looking up in the cloning environment, use the type at the occurrence
    site if we're inside a GADT.  It might be cleaner to use the same story as
    CoreTidy, but then we'd need to keep an in-scope set for type variables.
    No big deal either way.
ghc/compiler/coreSyn/CoreLint.lhs
ghc/compiler/coreSyn/CorePrep.lhs
ghc/compiler/coreSyn/CoreTidy.lhs
ghc/compiler/prelude/primops.txt.pp
ghc/compiler/simplCore/SimplEnv.lhs
ghc/compiler/simplCore/Simplify.lhs
ghc/compiler/types/Unify.lhs