From: simonpj Date: Mon, 2 Sep 2002 16:39:19 +0000 (+0000) Subject: [project @ 2002-09-02 16:39:19 by simonpj] X-Git-Tag: Approx_11550_changesets_converted~1731 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=3a9075020fbffec15481ae06c84a96c5fd9a808d;p=ghc-hetmet.git [project @ 2002-09-02 16:39:19 by simonpj] Wibble in demand analyser; no need to merge --- diff --git a/ghc/compiler/stranal/DmdAnal.lhs b/ghc/compiler/stranal/DmdAnal.lhs index 5320305..c42099d 100644 --- a/ghc/compiler/stranal/DmdAnal.lhs +++ b/ghc/compiler/stranal/DmdAnal.lhs @@ -334,19 +334,27 @@ dmdFix top_lvl sigs orig_pairs -> [(Id,CoreExpr)] -> (SigEnv, DmdEnv, [(Id,CoreExpr)]) loop n sigs pairs - | all (same_sig sigs sigs') bndrs + | found_fixpoint = (sigs', lazy_fv, pairs') -- Note: use pairs', not pairs. pairs' is the result of -- processing the RHSs with sigs (= sigs'), whereas pairs -- is the result of processing the RHSs with the *previous* -- iteration of sigs. - | n >= 10 = pprTrace "dmdFix loop" (ppr n <+> (vcat + + | n >= 10 = pprTrace "dmdFix loop" (ppr n <+> (vcat [ text "Sigs:" <+> ppr [(id,lookup sigs id, lookup sigs' id) | (id,_) <- pairs], text "env:" <+> ppr (ufmToList sigs), text "binds:" <+> pprCoreBinding (Rec pairs)])) - (emptySigEnv, emptyDmdEnv, orig_pairs) -- Safe output + (emptySigEnv, lazy_fv, orig_pairs) -- Safe output + -- The lazy_fv part is really important! orig_pairs has no strictness + -- info, including nothing about free vars. But if we have + -- letrec f = ....y..... in ...f... + -- where 'y' is free in f, we must record that y is mentioned, + -- otherwise y will get recorded as absent altogether + | otherwise = loop (n+1) sigs' pairs' where + found_fixpoint = all (same_sig sigs sigs') bndrs -- Use the new signature to do the next pair -- The occurrence analyser has arranged them in a good order -- so this can significantly reduce the number of iterations needed