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

git at git.haskell.org git at git.haskell.org
Tue Dec 3 18:10:34 UTC 2013


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

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

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

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

    Do not forget about Divergence of thunks


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

a9cb62ae9730371bd22f193a655e6e6b131b0034
 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 7eda769..557a9bd 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,
@@ -809,6 +810,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 480f234..3bb197b 100644
--- a/compiler/stranal/DmdAnal.lhs
+++ b/compiler/stranal/DmdAnal.lhs
@@ -668,7 +668,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