mkStrictSig dmd_ty
newRes True _ = BotRes
-newRes False ReturnsCPR = RetCPR
+newRes False ReturnsCPR = retCPR
newRes False NoCPRInfo = TopRes
newDemand :: Demand.Demand -> NewDemand.Demand
GlobalIdDetails(..), CafInfo(..)
)
import NewDemand ( mkStrictSig, strictSigResInfo, DmdResult(..),
- mkTopDmdType, topDmd, evalDmd, lazyDmd,
+ mkTopDmdType, topDmd, evalDmd, lazyDmd, retCPR,
Demand(..), Demands(..) )
import FieldLabel ( mkFieldLabel, fieldLabelName,
firstFieldLabelTag, allFieldLabelTags, fieldLabelType
cpr_info | isProductTyCon tycon &&
isDataTyCon tycon &&
arity > 0 &&
- arity <= mAX_CPR_SIZE = RetCPR
+ arity <= mAX_CPR_SIZE = retCPR
| otherwise = TopRes
-- RetCPR is only true for products that are real data types;
-- that is, not unboxed tuples or [non-recursive] newtypes
DmdType(..), topDmdType, botDmdType, mkDmdType, mkTopDmdType,
dmdTypeDepth, dmdTypeRes, seqDmdType,
DmdEnv, emptyDmdEnv,
- DmdResult(..), isBotRes, returnsCPR, resTypeArgDmd,
+ DmdResult(..), retCPR, isBotRes, returnsCPR, resTypeArgDmd,
Demands(..), mapDmds, zipWithDmds, allTop, seqDemands,
- StrictSig(..), mkStrictSig, topSig, botSig, isTopSig,
+ StrictSig(..), mkStrictSig, topSig, botSig, cprSig,
+ isTopSig,
splitStrictSig, strictSigResInfo,
pprIfaceStrictSig, appIsBottom, isBottomingSig, seqStrictSig,
) where
#include "HsVersions.h"
+import CmdLineOpts ( opt_CprOff )
import BasicTypes ( Arity )
import VarEnv ( VarEnv, emptyVarEnv, isEmptyVarEnv )
import UniqFM ( ufmToList )
-- Handwavey reason: these don't correspond to calling conventions
-- See DmdAnal.funArgDemand for details
+
+-- This guy lets us switch off CPR analysis
+-- by making sure that everything uses TopRes instead of RetCPR
+-- Assuming, of course, that they don't mention RetCPR by name.
+-- They should onlyu use retCPR
+retCPR | opt_CprOff = TopRes
+ | otherwise = RetCPR
+
seqDmdType (DmdType env ds res) =
{- ??? env `seq` -} seqDemandList ds `seq` res `seq` ()
-- without ambiguity
emptyDmdEnv = emptyVarEnv
+
topDmdType = DmdType emptyDmdEnv [] TopRes
botDmdType = DmdType emptyDmdEnv [] BotRes
+cprDmdType = DmdType emptyVarEnv [] retCPR
isTopDmdType :: DmdType -> Bool
-- Only used on top-level types, hence the assert
isTopSig (StrictSig ty) = isTopDmdType ty
+topSig, botSig, cprSig :: StrictSig
topSig = StrictSig topDmdType
botSig = StrictSig botDmdType
+cprSig = StrictSig cprDmdType
+
-- appIsBottom returns true if an application to n args would diverge
appIsBottom (StrictSig (DmdType _ ds BotRes)) n = listLengthCmp ds n /= GT
h <- getByte bh
case h of
0 -> do return TopRes
- 1 -> do return RetCPR
+ 1 -> do return retCPR
_ -> do return BotRes
instance Binary StrictSig where
opt_LiberateCaseThreshold,
opt_StgDoLetNoEscapes,
opt_UnfoldCasms,
+ opt_CprOff,
opt_UsageSPOn,
opt_UnboxStrictFields,
opt_SimplNoPreInlining,
| CoreDoSpecialising
| CoreDoSpecConstr
| CoreDoUSPInf
- | CoreDoCPResult
+ | CoreDoOldStrictness
| CoreDoGlomBinds
| CoreCSE
| CoreDoRuleCheck Int{-CompilerPhase-} String -- Check for non-application of rules
opt_NoMethodSharing = lookUp FSLIT("-fno-method-sharing")
opt_DoSemiTagging = lookUp FSLIT("-fsemi-tagging")
opt_FoldrBuildOn = lookUp FSLIT("-ffoldr-build-on")
+opt_CprOff = lookUp FSLIT("-fcpr-off")
+ -- Switch off CPR analysis in the new demand analyser
opt_LiberateCaseThreshold = lookup_def_int "-fliberate-case-threshold" (10::Int)
opt_StgDoLetNoEscapes = lookUp FSLIT("-flet-no-escape")
opt_UnfoldCasms = lookUp FSLIT("-funfold-casms-in-hi-file")
"static",
"funregisterised",
"fext-core",
- "frule-check"
+ "frule-check",
+ "fcpr-off"
]
|| any (flip prefixMatch f) [
"fcontext-stack",
{-# OPTIONS -#include "hschooks.h" #-}
-----------------------------------------------------------------------------
--- $Id: DriverFlags.hs,v 1.91 2002/04/05 23:24:29 sof Exp $
+-- $Id: DriverFlags.hs,v 1.92 2002/04/22 16:06:36 simonpj Exp $
--
-- Driver flags
--
-- -fno-* pattern below doesn't work. We therefore allow
-- certain optimisation passes to be turned off explicitly:
, ( "fno-strictness" , NoArg (writeIORef v_Strictness False) )
-#ifdef OLD_STRICTNESS
- , ( "fno-cpr" , NoArg (writeIORef v_CPR False) )
-#endif
, ( "fno-cse" , NoArg (writeIORef v_CSE False) )
-- All other "-fno-<blah>" options cancel out "-f<blah>" on the hsc cmdline
-----------------------------------------------------------------------------
--- $Id: DriverState.hs,v 1.76 2002/04/05 23:24:29 sof Exp $
+-- $Id: DriverState.hs,v 1.77 2002/04/22 16:06:36 simonpj Exp $
--
-- Settings for the driver
--
GLOBAL_VAR(v_StgStats, False, Bool)
GLOBAL_VAR(v_UsageSPInf, False, Bool) -- Off by default
GLOBAL_VAR(v_Strictness, True, Bool)
-#ifdef OLD_STRICTNESS
-GLOBAL_VAR(v_CPR, True, Bool)
-#endif
GLOBAL_VAR(v_CSE, True, Bool)
GLOBAL_VAR(v_RuleCheck, Nothing, Maybe String)
max_iter <- readIORef v_MaxSimplifierIterations
usageSP <- readIORef v_UsageSPInf
strictness <- readIORef v_Strictness
-#ifdef OLD_STRICTNESS
- cpr <- readIORef v_CPR
-#endif
cse <- readIORef v_CSE
rule_check <- readIORef v_RuleCheck
case rule_check of { Just pat -> CoreDoRuleCheck 0 pat; Nothing -> CoreDoNothing },
#ifdef OLD_STRICTNESS
- if cpr then CoreDoCPResult else CoreDoNothing,
+ CoreDoOldStrictness
#endif
if strictness then CoreDoStrictness else CoreDoNothing,
CoreDoWorkerWrapper,
import Specialise ( specProgram)
import SpecConstr ( specConstrProgram)
import UsageSPInf ( doUsageSPInf )
-import StrictAnal ( saBinds )
import DmdAnal ( dmdAnalPgm )
import WorkWrap ( wwTopBinds )
+#ifdef OLD_STRICTNESS
+import StrictAnal ( saBinds )
import CprAnalyse ( cprAnalyse )
+#endif
import UniqSupply ( UniqSupply, mkSplitUniqSupply, splitUniqSupply )
import IO ( hPutStr, stderr )
doCorePass dfs rb us binds CoreDoStaticArgs
= _scc_ "StaticArgs" noStats dfs (doStaticArgs us binds)
doCorePass dfs rb us binds CoreDoStrictness
- = _scc_ "Stranal" noStats dfs (strictAnal dfs binds)
+ = _scc_ "Stranal" noStats dfs (dmdAnalPgm dfs binds)
doCorePass dfs rb us binds CoreDoWorkerWrapper
= _scc_ "WorkWrap" noStats dfs (wwTopBinds dfs us binds)
doCorePass dfs rb us binds CoreDoSpecialising
doCorePass dfs rb us binds CoreDoSpecConstr
= _scc_ "SpecConstr" noStats dfs (specConstrProgram dfs us binds)
#ifdef OLD_STRICTNESS
-doCorePass dfs rb us binds CoreDoCPResult
- = _scc_ "CPResult" noStats dfs (cprAnalyse dfs binds)
+doCorePass dfs rb us binds CoreDoOldStrictness
+ = _scc_ "OldStrictness" noStats dfs (doOldStrictness dfs binds)
#endif
doCorePass dfs rb us binds CoreDoPrintCore
= _scc_ "PrintCore" noStats dfs (printCore binds)
doCorePass dfs rb us binds CoreDoNothing
= noStats dfs (return binds)
-strictAnal dfs binds = do
#ifdef OLD_STRICTNESS
- binds <- saBinds dfs binds
+doOldStrictness dfs binds
+ = do binds1 <- saBinds dfs binds
+ binds2 <- cprAnalyse dfs binds1
+ return binds2
#endif
- dmdAnalPgm dfs binds
printCore binds = do dumpIfSet True "Print Core"
(pprCoreBindings binds)
drop_bs (NonRec _ _) (_ : bs) = bs
drop_bs (Rec prs) bs = drop (length prs) bs
- simpl_bind env (NonRec b r) (b':_) = simplRecOrTopPair env TopLevel b b' r
- simpl_bind env (Rec pairs) bs' = simplRecBind env TopLevel pairs bs'
+ simpl_bind env bind bs
+ = getDOptsSmpl `thenSmpl` \ dflags ->
+ if dopt Opt_D_dump_inlinings dflags then
+ pprTrace "SimplBind" (ppr (bindersOf bind)) $ simpl_bind1 env bind bs
+ else
+ simpl_bind1 env bind bs
+
+ simpl_bind1 env (NonRec b r) (b':_) = simplRecOrTopPair env TopLevel b b' r
+ simpl_bind1 env (Rec pairs) bs' = simplRecBind env TopLevel pairs bs'
\end{code}
Just (Eval (Prod ds)) -> extendVarEnv sigs id (cprSig, NotTopLevel)
other -> sigs
-cprSig :: StrictSig
-cprSig = StrictSig (mkDmdType emptyVarEnv [] RetCPR)
-
dmdTransform :: SigEnv -- The strictness environment
-> Id -- The function