From bcd00882317241e2ae8c83e806aa05091c6d53a3 Mon Sep 17 00:00:00 2001 From: simonmar Date: Wed, 20 Dec 2000 10:36:55 +0000 Subject: [PATCH] [project @ 2000-12-20 10:36:55 by simonmar] simplify the test for a CAF, using exprIsValue. --- ghc/compiler/coreSyn/CoreTidy.lhs | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/ghc/compiler/coreSyn/CoreTidy.lhs b/ghc/compiler/coreSyn/CoreTidy.lhs index ceb6580..bb7992d 100644 --- a/ghc/compiler/coreSyn/CoreTidy.lhs +++ b/ghc/compiler/coreSyn/CoreTidy.lhs @@ -14,7 +14,7 @@ module CoreTidy ( import CmdLineOpts ( DynFlags, DynFlag(..), opt_OmitInterfacePragmas ) import CoreSyn import CoreUnfold ( noUnfolding, mkTopUnfolding, okToUnfoldInHiFile ) -import CoreUtils ( exprArity, exprIsBottom ) +import CoreUtils ( exprArity, exprIsValue ) import CoreFVs ( ruleSomeFreeVars, exprSomeFreeVars ) import CoreLint ( showPass, endPass ) import VarEnv @@ -654,15 +654,13 @@ cafRefss p (e:es) = cafRefs p e `fastOr` cafRefss p es -- in an SRT or not. isCAF :: CoreExpr -> Bool - -- special case for expressions which are always bottom, - -- such as 'error "..."'. We don't need to record it as - -- a CAF, since it can only be entered once. isCAF e - | not_function && is_bottom = False - | not_function && updatable = True - | otherwise = False - where - not_function = exprArity e == 0 - is_bottom = exprIsBottom e - updatable = True {- ToDo: check type for onceness? -} + | exprIsValue e = False + | otherwise = True + {- ToDo: check type for onceness, i.e. non-updatable thunks? -} + +-- we're assuming here that anything for which exprIsValue is True +-- will be non-updatable. This is true for functions and +-- constructors, but we must make sure that partial applications are +-- compiled as non-updatable closures (which CoreToStg does). \end{code} -- 1.7.10.4