[commit: ghc] wip/nested-cpr: Apply state hack only to information about arguments (938cf3d)
git at git.haskell.org
git at git.haskell.org
Tue Dec 3 16:12:38 UTC 2013
Repository : ssh://git@git.haskell.org/ghc
On branch : wip/nested-cpr
Link : http://ghc.haskell.org/trac/ghc/changeset/938cf3d4d6601ca2fce814b20eb75e03c514c341/ghc
>---------------------------------------------------------------
commit 938cf3d4d6601ca2fce814b20eb75e03c514c341
Author: Joachim Breitner <mail at joachim-breitner.de>
Date: Thu Nov 28 10:29:47 2013 +0000
Apply state hack only to information about arguments
>---------------------------------------------------------------
938cf3d4d6601ca2fce814b20eb75e03c514c341
compiler/basicTypes/Demand.lhs | 8 ++++++++
compiler/stranal/DmdAnal.lhs | 4 +++-
compiler/stranal/WwLib.lhs | 2 +-
3 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/compiler/basicTypes/Demand.lhs b/compiler/basicTypes/Demand.lhs
index e3cd5d6..b3fe942 100644
--- a/compiler/basicTypes/Demand.lhs
+++ b/compiler/basicTypes/Demand.lhs
@@ -20,6 +20,7 @@ module Demand (
DmdType(..), dmdTypeDepth, lubDmdType, bothDmdEnv, bothDmdType, bothDmdTypeCase,
topDmdType, botDmdType, mkDmdType, mkTopDmdType,
+ dmdTypeArgTop,
DmdEnv, emptyDmdEnv,
@@ -1141,6 +1142,13 @@ splitDmdTy :: DmdType -> (Demand, DmdType)
splitDmdTy (DmdType fv (dmd:dmds) res_ty) = (dmd, DmdType fv dmds res_ty)
splitDmdTy ty@(DmdType _ [] res_ty) = (resTypeArgDmd res_ty, ty)
+-- We want to forget what we know about the arguments, but keep the information
+-- of the result, see Note [IO State Hack]
+dmdTypeArgTop :: DmdType -> DmdType
+dmdTypeArgTop d@(DmdType _ _ res)
+ = let (DmdType env' ds' _) = d `lubDmdType` topDmdType
+ in DmdType env' ds' res
+
modifyEnv :: Bool -- No-op if False
-> (Demand -> Demand) -- The zapper
-> DmdEnv -> DmdEnv -- Env1 and Env2
diff --git a/compiler/stranal/DmdAnal.lhs b/compiler/stranal/DmdAnal.lhs
index 8da502c..67e5663 100644
--- a/compiler/stranal/DmdAnal.lhs
+++ b/compiler/stranal/DmdAnal.lhs
@@ -307,9 +307,11 @@ dmdAnalAlt env dmd (con,bndrs,rhs)
(rhs_ty, rhs') = dmdAnal env dmd rhs
rhs_ty' = addDataConPatDmds con bndrs rhs_ty
(alt_ty, bndrs') = annotateBndrs env rhs_ty' bndrs
- final_alt_ty | io_hack_reqd = alt_ty `lubDmdType` topDmdType
+ final_alt_ty | io_hack_reqd = dmdTypeArgTop alt_ty
| otherwise = alt_ty
+ -- Note [IO State Hack]
+ --
-- There's a hack here for I/O operations. Consider
-- case foo x s of { (# s, r #) -> y }
-- Is this strict in 'y'. Normally yes, but what if 'foo' is an I/O
diff --git a/compiler/stranal/WwLib.lhs b/compiler/stranal/WwLib.lhs
index 0b819dc..861a03b 100644
--- a/compiler/stranal/WwLib.lhs
+++ b/compiler/stranal/WwLib.lhs
@@ -503,7 +503,7 @@ deepSplitCprType_maybe :: ConTag -> Type -> Maybe (DataCon, [Type], [Type], Coer
deepSplitCprType_maybe con_tag ty
| let (co, ty1) = topNormaliseNewType_maybe ty `orElse` (mkReflCo Representational ty, ty)
, Just (tc, tc_args) <- splitTyConApp_maybe ty1
- , isDataTyCon tc
+ , isDataTyCon tc || isUnboxedTupleTyCon tc
, let cons = tyConDataCons tc
con = ASSERT( cons `lengthAtLeast` con_tag ) cons !! (con_tag - fIRST_TAG)
= Just (con, tc_args, dataConInstArgTys con tc_args, co)
More information about the ghc-commits
mailing list