[commit: ghc] wip/nested-cpr: Do not forget about Divergence of thunks (a7a3e52)

git at git.haskell.org git at git.haskell.org
Fri Nov 29 12:47:42 UTC 2013


Repository : ssh://git@git.haskell.org/ghc

On branch  : wip/nested-cpr
Link       : http://ghc.haskell.org/trac/ghc/changeset/a7a3e525c57341284a289da4ca86e52758c536ee/ghc

>---------------------------------------------------------------

commit a7a3e525c57341284a289da4ca86e52758c536ee
Author: Joachim Breitner <mail at joachim-breitner.de>
Date:   Fri Nov 29 12:47:34 2013 +0000

    Do not forget about Divergence of thunks


>---------------------------------------------------------------

a7a3e525c57341284a289da4ca86e52758c536ee
 compiler/basicTypes/Demand.lhs |    8 ++++++++
 compiler/stranal/DmdAnal.lhs   |    2 +-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/compiler/basicTypes/Demand.lhs b/compiler/basicTypes/Demand.lhs
index c016d68..9839509 100644
--- a/compiler/basicTypes/Demand.lhs
+++ b/compiler/basicTypes/Demand.lhs
@@ -29,6 +29,7 @@ module Demand (
         topRes, botRes, cprConRes, vanillaCprConRes,
         appIsBottom, isBottomingSig, pprIfaceStrictSig, 
         returnsCPR, returnsCPR_maybe,
+        forgetCPR,
         StrictSig(..), mkStrictSig, topSig, botSig, cprProdSig,
         isTopSig, splitStrictSig, increaseStrictSigArity,
         sigMayConverge,
@@ -833,6 +834,13 @@ cutCPRResult n (RetCon tag rs) = RetCon tag (map (cutDmdResult (n-1)) rs)
 divergeDmdResult :: DmdResult -> DmdResult
 divergeDmdResult r = r `lubDmdResult` botRes
 
+-- Forget the CPR information, but remember if it converges or diverges
+-- Used for non-strict thunks
+forgetCPR :: DmdResult -> DmdResult
+forgetCPR Diverges = Diverges
+forgetCPR (Converges _) = Converges NoCPR
+forgetCPR (Dunno _) = Dunno NoCPR
+
 cprConRes :: ConTag -> [DmdType] -> CPRResult
 cprConRes tag arg_tys
   | opt_CprOff = NoCPR
diff --git a/compiler/stranal/DmdAnal.lhs b/compiler/stranal/DmdAnal.lhs
index 4e563cb..e7643bf 100644
--- a/compiler/stranal/DmdAnal.lhs
+++ b/compiler/stranal/DmdAnal.lhs
@@ -663,7 +663,7 @@ dmdAnalRhs top_lvl rec_flag env id rhs
     (lazy_fv, sig_fv) = splitFVs is_thunk rhs_fv1
 
     -- Note [CPR for sum types]
-    rhs_res' | is_sum_type || (is_thunk && not_strict) = topRes
+    rhs_res' | is_sum_type || (is_thunk && not_strict) = forgetCPR rhs_res
              | otherwise                               = rhs_res
         
     -- See Note [CPR for thunks]



More information about the ghc-commits mailing list