Commit e1db55d8 authored by simonm's avatar simonm
Browse files

[project @ 1999-03-25 13:13:51 by simonm]

Profiling fixes.

	- top-level CAF CCSs now *append* themselves to the
	  current CCS when called.

	- remove DICT stuff.

	- fixes to the auto-scc annotating in the desugarer.
parent a2e5c0a8
%
% (c) The GRASP/AQUA Project, Glasgow University, 1992-1998
%
% $Id: CgExpr.lhs,v 1.21 1999/03/22 16:57:11 simonm Exp $
% $Id: CgExpr.lhs,v 1.22 1999/03/25 13:13:51 simonm Exp $
%
%********************************************************
%* *
......@@ -36,7 +36,7 @@ import CgTailCall ( cgTailCall, performReturn, performPrimReturn,
)
import ClosureInfo ( mkClosureLFInfo, mkSelectorLFInfo,
mkApLFInfo, layOutDynCon )
import CostCentre ( sccAbleCostCentre, isDictCC, isSccCountCostCentre )
import CostCentre ( sccAbleCostCentre, isSccCountCostCentre )
import Id ( idPrimRep, idType, Id )
import VarSet
import DataCon ( DataCon, dataConTyCon )
......@@ -234,7 +234,7 @@ centre.
cgExpr (StgSCC cc expr)
= ASSERT(sccAbleCostCentre cc)
costCentresC
(if isDictCC cc then SLIT("SET_DICT_CCC") else SLIT("SET_CCC"))
SLIT("SET_CCC")
[mkCCostCentre cc, mkIntCLit (if isSccCountCostCentre cc then 1 else 0)]
`thenC`
cgExpr expr
......
......@@ -14,9 +14,7 @@ module CoreUtils (
cheapEqExpr,
substExpr, substId, substIds,
idSpecVars, idFreeVars,
squashableDictishCcExpr
idSpecVars, idFreeVars
) where
#include "HsVersions.h"
......@@ -38,7 +36,7 @@ import Id ( Id, idType, setIdType, idUnique, idAppIsBottom,
)
import IdInfo ( arityLowerBound, InlinePragInfo(..) )
import SpecEnv ( emptySpecEnv, specEnvToList, isEmptySpecEnv )
import CostCentre ( isDictCC, CostCentre )
import CostCentre ( CostCentre )
import Const ( Con, conType )
import Type ( Type, TyVarSubst, mkFunTy, mkForAllTy,
splitFunTy_maybe, applyTys, tyVarsOfType, tyVarsOfTypes,
......@@ -315,22 +313,6 @@ exprIsWHNF e@(App _ _) = case collectArgs e of
_ -> False
\end{code}
I don't like this function but I'n not confidnt enough to change it.
\begin{code}
squashableDictishCcExpr :: CostCentre -> Expr b -> Bool
squashableDictishCcExpr cc expr
| isDictCC cc = False -- that was easy...
| otherwise = squashable expr
where
squashable (Var _) = True
squashable (Con _ _) = True -- I think so... WDP 94/09
squashable (App f a)
| isTypeArg a = squashable f
squashable other = False
\end{code}
@cheapEqExpr@ is a cheap equality test which bales out fast!
True => definitely equal
False => may or may not be equal
......
......@@ -13,7 +13,7 @@ import HsSyn ( MonoBinds )
import TcHsSyn ( TypecheckedMonoBinds, TypecheckedForeignDecl )
import CoreSyn
import DsMonad
import DsBinds ( dsMonoBinds )
import DsBinds ( dsMonoBinds, AutoScc(..) )
import DsForeign ( dsForeigns )
import DsUtils
import DsExpr () -- Forces DsExpr to be compiled; DsBinds only
......@@ -42,7 +42,9 @@ deSugar us global_val_env mod_name all_binds fo_decls = do
beginPass "Desugar"
-- Do desugaring
let (core_prs, ds_warns1) = initDs us1 global_val_env module_and_group
(dsMonoBinds opt_SccProfilingOn all_binds [])
(dsMonoBinds auto_scc all_binds [])
auto_scc | opt_SccProfilingOn = TopLevel
| otherwise = NoSccs
ds_binds' = [Rec core_prs]
((fi_binds, fe_binds, h_code, c_code), ds_warns2) =
......
......@@ -8,7 +8,7 @@ in that the @Rec@/@NonRec@/etc structure is thrown away (whereas at
lower levels it is preserved with @let@/@letrec@s).
\begin{code}
module DsBinds ( dsMonoBinds ) where
module DsBinds ( dsMonoBinds, AutoScc(..) ) where
#include "HsVersions.h"
......@@ -26,16 +26,18 @@ import Match ( matchWrapper )
import BasicTypes ( RecFlag(..) )
import CmdLineOpts ( opt_SccProfilingOn, opt_AutoSccsOnAllToplevs,
opt_AutoSccsOnExportedToplevs
opt_AutoSccsOnExportedToplevs, opt_AutoSccsOnDicts
)
import CostCentre ( mkAutoCC, IsCafCC(..), mkAllDictsCC )
import CostCentre ( CostCentre, mkAutoCC, IsCafCC(..) )
import Id ( idType, Id )
import VarEnv
import Name ( isExported )
import Type ( mkTyVarTy, isDictTy, substTy
)
import Type ( mkTyVarTy, isDictTy, substTy )
import TysWiredIn ( voidTy )
import Outputable
import Maybe
import IOExts (trace)
\end{code}
%************************************************************************
......@@ -45,7 +47,7 @@ import Outputable
%************************************************************************
\begin{code}
dsMonoBinds :: Bool -- False => don't (auto-)annotate scc on toplevs.
dsMonoBinds :: AutoScc -- scc annotation policy (see below)
-> TypecheckedMonoBinds
-> [(Id,CoreExpr)] -- Put this on the end (avoid quadratic append)
-> DsM [(Id,CoreExpr)] -- Result
......@@ -76,33 +78,35 @@ dsMonoBinds auto_scc (FunMonoBind fun _ matches locn) rest
where
error_string = "function " ++ showSDoc (ppr fun)
dsMonoBinds _ (PatMonoBind pat grhss locn) rest
dsMonoBinds auto_scc (PatMonoBind pat grhss locn) rest
= putSrcLocDs locn $
dsGuarded grhss `thenDs` \ body_expr ->
mkSelectorBinds pat body_expr `thenDs` \ sel_binds ->
dsGuarded grhss `thenDs` \ body_expr ->
mkSelectorBinds pat body_expr `thenDs` \ sel_binds ->
mapDs (addAutoScc auto_scc) sel_binds `thenDs` \ sel_binds ->
returnDs (sel_binds ++ rest)
-- Common special case: no type or dictionary abstraction
dsMonoBinds auto_scc (AbsBinds [] [] exports binds) rest
= mapDs (addAutoScc auto_scc) [(global, Var local) | (_, global, local) <- exports] `thenDs` \ exports' ->
dsMonoBinds False binds (exports' ++ rest)
-- Another common case: one exported variable
-- Common case: one exported variable
-- All non-recursive bindings come through this way
dsMonoBinds auto_scc (AbsBinds all_tyvars dicts [(tyvars, global, local)] binds) rest
dsMonoBinds auto_scc (AbsBinds all_tyvars dicts exps@[(tyvars, global, local)] binds) rest
= ASSERT( all (`elem` tyvars) all_tyvars )
dsMonoBinds False binds [] `thenDs` \ core_prs ->
dsMonoBinds (addSccs auto_scc exps) binds [] `thenDs` \ core_prs ->
let
-- Always treat the binds as recursive, because the typechecker
-- makes rather mixed-up dictionary bindings
core_binds = [Rec core_prs]
global' = (global, mkLams tyvars $ mkLams dicts $
mkLets core_binds (Var local))
in
addAutoScc auto_scc (global, mkLams tyvars $ mkLams dicts $
mkLets core_binds (Var local)) `thenDs` \ global' ->
returnDs (global' : rest)
-- Another Common special case: no type or dictionary abstraction
dsMonoBinds auto_scc (AbsBinds [] [] exports binds) rest
= let exports' = [(global, Var local) | (_, global, local) <- exports] in
dsMonoBinds (addSccs auto_scc exports) binds (exports' ++ rest)
dsMonoBinds auto_scc (AbsBinds all_tyvars dicts exports binds) rest
= dsMonoBinds False binds [] `thenDs` \ core_prs ->
= dsMonoBinds (addSccs auto_scc exports) binds []`thenDs` \ core_prs ->
let
core_binds = [Rec core_prs]
......@@ -122,10 +126,9 @@ dsMonoBinds auto_scc (AbsBinds all_tyvars dicts exports binds) rest
-- some of the tyvars will be bound to voidTy
newSysLocalsDs (map (substTy env) local_tys) `thenDs` \ locals' ->
newSysLocalDs (substTy env tup_ty) `thenDs` \ tup_id ->
addAutoScc auto_scc
(global, mkLams tyvars $ mkLams dicts $
mkTupleSelector locals' (locals' !! n) tup_id $
mkApps (mkTyApps (Var poly_tup_id) ty_args) dict_args)
returnDs (global, mkLams tyvars $ mkLams dicts $
mkTupleSelector locals' (locals' !! n) tup_id $
mkApps (mkTyApps (Var poly_tup_id) ty_args) dict_args)
where
mk_ty_arg all_tyvar | all_tyvar `elem` tyvars = mkTyVarTy all_tyvar
| otherwise = voidTy
......@@ -145,16 +148,34 @@ dsMonoBinds auto_scc (AbsBinds all_tyvars dicts exports binds) rest
%************************************************************************
\begin{code}
addAutoScc :: Bool -- if needs be, decorate toplevs?
data AutoScc
= TopLevel
| TopLevelAddSccs (Id -> Maybe Id)
| NoSccs
addSccs :: AutoScc -> [(a,Id,Id)] -> AutoScc
addSccs auto_scc@(TopLevelAddSccs _) exports = auto_scc
addSccs NoSccs exports = NoSccs
addSccs TopLevel exports
= TopLevelAddSccs (\id -> case [ exp | (_,exp,loc) <- exports, loc == id ] of
(exp:_) | opt_AutoSccsOnAllToplevs ||
(isExported exp &&
opt_AutoSccsOnExportedToplevs)
-> Just exp
_ -> Nothing)
addAutoScc :: AutoScc -- if needs be, decorate toplevs?
-> (Id, CoreExpr)
-> DsM (Id, CoreExpr)
addAutoScc auto_scc_candidate pair@(bndr, core_expr)
| auto_scc_candidate && worthSCC core_expr &&
(opt_AutoSccsOnAllToplevs || (isExported bndr && opt_AutoSccsOnExportedToplevs))
addAutoScc (TopLevelAddSccs auto_scc_fn) pair@(bndr, core_expr)
| do_auto_scc && worthSCC core_expr
= getModuleAndGroupDs `thenDs` \ (mod,grp) ->
returnDs (bndr, Note (SCC (mkAutoCC bndr mod grp NotCafCC)) core_expr)
| otherwise
returnDs (bndr, Note (SCC (mkAutoCC top_bndr mod grp NotCafCC)) core_expr)
where do_auto_scc = isJust maybe_auto_scc
maybe_auto_scc = auto_scc_fn bndr
(Just top_bndr) = maybe_auto_scc
addAutoScc _ pair
= returnDs pair
worthSCC (Note (SCC _) _) = False
......@@ -165,15 +186,16 @@ worthSCC core_expr = True
If profiling and dealing with a dict binding, wrap the dict in "_scc_ DICT <dict>":
\begin{code}
addDictScc var rhs
| not ( opt_SccProfilingOn || opt_AutoSccsOnAllToplevs)
-- the latter is so that -unprof-auto-scc-all adds dict sccs
addDictScc var rhs = returnDs rhs
{- DISABLED for now (need to somehow make up a name for the scc) -- SDM
| not ( opt_SccProfilingOn && opt_AutoSccsOnDicts)
|| not (isDictTy (idType var))
= returnDs rhs -- That's easy: do nothing
| otherwise
= getModuleAndGroupDs `thenDs` \ (mod, grp) ->
-- ToDo: do -dicts-all flag (mark dict things with individual CCs)
returnDs (Note (SCC (mkAllDictsCC mod grp False)) rhs)
-}
\end{code}
......@@ -22,7 +22,7 @@ import TcHsSyn ( TypecheckedHsExpr, TypecheckedHsBinds,
import CoreSyn
import DsMonad
import DsBinds ( dsMonoBinds )
import DsBinds ( dsMonoBinds, AutoScc(..) )
import DsGRHSs ( dsGuarded )
import DsCCall ( dsCCall )
import DsListComp ( dsListComp )
......@@ -99,7 +99,7 @@ dsLet (MonoBind (AbsBinds [] [] binder_triples (PatMonoBind pat grhss loc)) sigs
-- Ordinary case for bindings
dsLet (MonoBind binds sigs is_rec) body
= dsMonoBinds False binds [] `thenDs` \ prs ->
= dsMonoBinds NoSccs binds [] `thenDs` \ prs ->
case is_rec of
Recursive -> returnDs (Let (Rec prs) body)
NonRecursive -> returnDs (foldr mk_let body prs)
......
......@@ -20,6 +20,7 @@ module CmdLineOpts (
opt_AutoSccsOnAllToplevs,
opt_AutoSccsOnExportedToplevs,
opt_AutoSccsOnIndividualCafs,
opt_AutoSccsOnDicts,
opt_CompilingPrelude,
opt_D_dump_absC,
opt_D_dump_asm,
......@@ -280,6 +281,7 @@ opt_AllowUndecidableInstances = lookUp SLIT("-fallow-undecidable-instances")
opt_AutoSccsOnAllToplevs = lookUp SLIT("-fauto-sccs-on-all-toplevs")
opt_AutoSccsOnExportedToplevs = lookUp SLIT("-fauto-sccs-on-exported-toplevs")
opt_AutoSccsOnIndividualCafs = lookUp SLIT("-fauto-sccs-on-individual-cafs")
opt_AutoSccsOnDicts = lookUp SLIT("-fauto-sccs-on-dicts")
{-
It's a bit unfortunate to have to re-introduce this chap, but on Win32
platforms we do need a way of distinguishing between the case when we're
......
......@@ -5,7 +5,7 @@
\begin{code}
module CostCentre (
CostCentre(..), CcName, IsDupdCC(..), IsCafCC(..), IsDictCC(..),
CostCentre(..), CcName, IsDupdCC(..), IsCafCC(..),
-- All abstract except to friend: ParseIface.y
CostCentreStack,
......@@ -13,9 +13,9 @@ module CostCentre (
noCostCentre, noCCAttached,
noCCSAttached, isCurrentCCS, isSubsumedCCS, currentOrSubsumedCCS,
mkUserCC, mkAutoCC, mkDictCC, mkAllCafsCC, mkAllDictsCC,
mkUserCC, mkAutoCC, mkAllCafsCC,
mkSingletonCCS, cafifyCC, dupifyCC,
isCafCC, isDictCC, isDupdCC, isEmptyCC, isCafCCS,
isCafCC, isDupdCC, isEmptyCC, isCafCCS,
isSccCountCostCentre,
sccAbleCostCentre,
ccFromThisModule,
......@@ -106,7 +106,6 @@ data CostCentre
cc_name :: CcName, -- Name of the cost centre itself
cc_mod :: Module, -- Name of module defining this CC.
cc_grp :: Group, -- "Group" that this CC is in.
cc_is_dict :: IsDictCC, -- see below
cc_is_dupd :: IsDupdCC, -- see below
cc_is_caf :: IsCafCC -- see below
}
......@@ -119,19 +118,8 @@ data CostCentre
-- per-individual-CAF cost attribution.
}
| AllDictsCC {
cc_mod :: Module, -- Name of module defining this CC.
cc_grp :: Group, -- "Group" that this CC is in.
-- Again, one "big" DICT cc per module, where all
-- DICT costs are attributed unless the user asked for
-- per-individual-DICT cost attribution.
cc_is_dupd :: IsDupdCC
}
type CcName = EncodedFS
data IsDictCC = DictCC | VanillaCC
data IsDupdCC
= OriginalCC -- This says how the CC is *used*. Saying that
| DupdCC -- it is DupdCC doesn't make it a different
......@@ -187,9 +175,6 @@ isSubsumedCCS _ = False
isCafCCS (SingletonCCS cc) = isCafCC cc
isCafCCS _ = False
isDictCCS (SingletonCCS cc) = isDictCC cc
isDictCCS _ = False
currentOrSubsumedCCS SubsumedCCS = True
currentOrSubsumedCCS CurrentCCS = True
currentOrSubsumedCCS _ = False
......@@ -203,33 +188,24 @@ mkUserCC :: UserFS -> Module -> Group -> CostCentre
mkUserCC cc_name module_name group_name
= NormalCC { cc_name = encodeFS cc_name,
cc_mod = module_name, cc_grp = group_name,
cc_is_dict = VanillaCC, cc_is_dupd = OriginalCC, cc_is_caf = NotCafCC {-might be changed-}
cc_is_dupd = OriginalCC, cc_is_caf = NotCafCC {-might be changed-}
}
mkDictCC, mkAutoCC :: Id -> Module -> Group -> IsCafCC -> CostCentre
mkDictCC id module_name group_name is_caf
= NormalCC { cc_name = occNameFS (getOccName id),
cc_mod = module_name, cc_grp = group_name,
cc_is_dict = DictCC, cc_is_dupd = OriginalCC, cc_is_caf = is_caf
}
mkAutoCC :: Id -> Module -> Group -> IsCafCC -> CostCentre
mkAutoCC id module_name group_name is_caf
= NormalCC { cc_name = occNameFS (getOccName id),
cc_mod = module_name, cc_grp = group_name,
cc_is_dict = VanillaCC, cc_is_dupd = OriginalCC, cc_is_caf = is_caf
cc_is_dupd = OriginalCC, cc_is_caf = is_caf
}
mkAllCafsCC m g = AllCafsCC { cc_mod = m, cc_grp = g }
mkAllDictsCC m g is_dupd = AllDictsCC { cc_mod = m, cc_grp = g,
cc_is_dupd = if is_dupd then DupdCC else OriginalCC }
mkSingletonCCS :: CostCentre -> CostCentreStack
mkSingletonCCS cc = SingletonCCS cc
cafifyCC, dupifyCC :: CostCentre -> CostCentre
cafifyCC cc@(AllDictsCC {}) = cc
cafifyCC cc@(NormalCC {cc_is_caf = is_caf})
= ASSERT(not_a_caf_already is_caf)
cc {cc_is_caf = CafCC}
......@@ -240,7 +216,7 @@ cafifyCC cc = pprPanic "cafifyCC" (ppr cc)
dupifyCC cc = cc {cc_is_dupd = DupdCC}
isEmptyCC, isCafCC, isDictCC, isDupdCC :: CostCentre -> Bool
isEmptyCC, isCafCC, isDupdCC :: CostCentre -> Bool
isEmptyCC (NoCostCentre) = True
isEmptyCC _ = False
......@@ -249,11 +225,6 @@ isCafCC (AllCafsCC {}) = True
isCafCC (NormalCC {cc_is_caf = CafCC}) = True
isCafCC _ = False
isDictCC (AllDictsCC {}) = True
isDictCC (NormalCC {cc_is_dict = DictCC}) = True
isDictCC _ = False
isDupdCC (AllDictsCC {cc_is_dupd = DupdCC}) = True
isDupdCC (NormalCC {cc_is_dupd = DupdCC}) = True
isDupdCC _ = False
......@@ -265,7 +236,6 @@ isSccCountCostCentre NoCostCentre = panic "isSccCount:NoCostCentre"
#endif
isSccCountCostCentre cc | isCafCC cc = False
| isDupdCC cc = False
| isDictCC cc = True
| otherwise = True
sccAbleCostCentre :: CostCentre -> Bool
......@@ -291,7 +261,6 @@ instance Ord CostCentre where
cmpCostCentre :: CostCentre -> CostCentre -> Ordering
cmpCostCentre (AllCafsCC {cc_mod = m1}) (AllCafsCC {cc_mod = m2}) = m1 `compare` m2
cmpCostCentre (AllDictsCC {cc_mod = m1}) (AllDictsCC {cc_mod = m2}) = m1 `compare` m2
cmpCostCentre (NormalCC {cc_name = n1, cc_mod = m1, cc_is_caf = c1})
(NormalCC {cc_name = n2, cc_mod = m2, cc_is_caf = c2})
......@@ -308,7 +277,6 @@ cmpCostCentre other_1 other_2
where
tag_CC (NormalCC {}) = (ILIT(1) :: FAST_INT)
tag_CC (AllCafsCC {}) = ILIT(2)
tag_CC (AllDictsCC {}) = ILIT(3)
cmp_caf NotCafCC CafCC = LT
cmp_caf NotCafCC NotCafCC = EQ
......@@ -375,22 +343,16 @@ instance Outputable CostCentre where
-- Printing in an interface file or in Core generally
pprCostCentreCore (AllCafsCC {cc_mod = m, cc_grp = g})
= text "__sccC" <+> braces (pprModule m <+> doubleQuotes (ptext g))
pprCostCentreCore (AllDictsCC {cc_mod = m, cc_grp = g, cc_is_dupd = dup})
= text "__sccD" <+> braces (pprModule m <+> doubleQuotes (ptext g) <+> pp_dup dup)
pprCostCentreCore (NormalCC {cc_name = n, cc_mod = m, cc_grp = g,
cc_is_dict = dic, cc_is_caf = caf, cc_is_dupd = dup})
cc_is_caf = caf, cc_is_dupd = dup})
= text "__scc" <+> braces (hsep [
ptext n,
pprModule m,
doubleQuotes (ptext g),
pp_dict dic,
pp_dup dup,
pp_caf caf
])
pp_dict DictCC = text "__A"
pp_dict other = empty
pp_dup DupdCC = char '!'
pp_dup other = empty
......@@ -401,14 +363,12 @@ pp_caf other = empty
-- Printing as a C label
ppCostCentreLbl (NoCostCentre) = text "CC_NONE"
ppCostCentreLbl (AllCafsCC {cc_mod = m}) = text "CC_CAFs_" <> pprModule m
ppCostCentreLbl (AllDictsCC {cc_mod = m}) = text "CC_DICTs_" <> pprModule m
ppCostCentreLbl (NormalCC {cc_name = n, cc_mod = m}) = text "CC_" <> pprModule m <> ptext n
-- This is the name to go in the user-displayed string,
-- recorded in the cost centre declaration
costCentreUserName (NoCostCentre) = "NO_CC"
costCentreUserName (AllCafsCC {}) = "CAFs_in_..."
costCentreUserName (AllDictsCC {}) = "DICTs_in_..."
costCentreUserName (NormalCC {cc_name = name, cc_is_caf = is_caf})
= case is_caf of { CafCC -> "CAF:"; _ -> "" } ++ decode (_UNPK_ name)
\end{code}
......@@ -441,6 +401,5 @@ pprCostCentreDecl is_local cc
ccSubsumed :: CostCentre -> FAST_STRING -- subsumed value
ccSubsumed cc | isCafCC cc = SLIT("CC_IS_CAF")
| isDictCC cc = SLIT("CC_IS_DICT")
| otherwise = SLIT("CC_IS_BORING")
\end{code}
......@@ -142,7 +142,6 @@ data IfaceToken
| ITstrict ([Demand], Bool)
| ITscc
| ITsccAllCafs
| ITsccAllDicts
| ITdotdot -- reserved symbols
| ITdcolon
......@@ -355,7 +354,6 @@ lex_demand cont buf =
lex_scc cont buf =
case currentChar# buf of
'C'# -> cont ITsccAllCafs (stepOverLexeme (stepOn buf))
'D'# -> cont ITsccAllDicts (stepOverLexeme (stepOn buf))
other -> cont ITscc buf
-----------
......
......@@ -12,7 +12,7 @@ import Const ( Literal(..), mkMachInt_safe )
import BasicTypes ( Fixity(..), FixityDirection(..),
NewOrData(..), Version
)
import CostCentre ( CostCentre(..), IsDictCC(..), IsCafCC(..), IsDupdCC(..) )
import CostCentre ( CostCentre(..), IsCafCC(..), IsDupdCC(..) )
import HsPragmas ( noDataPragmas, noClassPragmas )
import Type ( Kind, mkArrowKind, boxedTypeKind, openTypeKind )
import IdInfo ( ArityInfo, exactArity )
......@@ -92,7 +92,6 @@ import Ratio ( (%) )
'__ccall' { ITccall $$ }
'__scc' { ITscc }
'__sccC' { ITsccAllCafs }
'__sccD' { ITsccAllDicts }
'__A' { ITarity }
'__P' { ITspecialise }
......@@ -683,10 +682,9 @@ ccall_string :: { FAST_STRING }
------------------------------------------------------------------------
scc :: { CostCentre }
: '__sccC' '{' mod_name STRING '}' { AllCafsCC $3 $4 }
| '__sccD' '{' mod_name STRING cc_dup '}' { AllDictsCC $3 $4 $5 }
| '__scc' '(' cc_name mod_name STRING cc_dict cc_dup cc_caf '}'
| '__scc' '(' cc_name mod_name STRING cc_dup cc_caf '}'
{ NormalCC { cc_name = $3, cc_mod = $4, cc_grp = $5,
cc_is_dict = $6, cc_is_dupd = $7, cc_is_caf = $8 } }
cc_is_dupd = $6, cc_is_caf = $7 } }
cc_name :: { EncodedFS }
: CONID { $1 }
......@@ -700,11 +698,6 @@ cc_caf :: { IsCafCC }
: { NotCafCC }
| '__C' { CafCC }
cc_dict :: { IsDictCC }
: { VanillaCC }
| '__A' { DictCC }
-------------------------------------------------------------------
src_loc :: { SrcLoc }
......
......@@ -484,6 +484,7 @@ $PROFing = ''; # set to p or e if profiling
$PROFgroup = ''; # set to group if an explicit -Ggroup specified
$PROFauto = ''; # set to relevant hsc flag if -auto or -auto-all
$PROFcaf = ''; # set to relevant hsc flag if -caf-all
$PROFdict = ''; # set to relevant hsc flag if -auto-dicts
$PROFignore_scc = ''; # set to relevant parser flag if explicit sccs ignored
$UNPROFscc_auto = ''; # set to relevant hsc flag if forcing auto sccs without profiling
$TICKYing = ''; # set to t if compiling for ticky-ticky profiling
......@@ -1000,7 +1001,7 @@ sub setupBuildFlags {
} else {
push(@HsC_flags, $PROFauto) if $PROFauto;
push(@HsC_flags, $PROFcaf) if $PROFcaf;
#push(@HsC_flags, $PROFdict) if $PROFdict;
push(@HsC_flags, $PROFdict) if $PROFdict;
$Oopt_FinalStgProfilingMassage = '-fmassage-stg-for-profiling';
......@@ -2938,13 +2939,14 @@ arg: while($_ = $Args[0]) {
/^-prof$/ && do { $PROFing = 'p'; next arg; }; # profiling -- details later!
/^-auto/ && do {
# generate auto SCCs on top level bindings
# -auto-all = all top level bindings
# -auto = only top level exported bindings
$PROFauto = ( /-all/ )
? '-fauto-sccs-on-all-toplevs'
: '-fauto-sccs-on-exported-toplevs';
/^-auto-dicts$/ && do {
$PROFdicts = '-fauto-sccs-on-dicts';
next arg; };
/^-auto-all$/ && do {
$PROFauto = '-fauto-sccs-on-all-toplevs';
next arg; };
/^-auto$/ && do {
$PROFauto = '-fauto-sccs-on-exported-toplevs';
next arg; };
/^-caf-all/ && do { # generate individual CAF SCC annotations
......
/* -----------------------------------------------------------------------------
* $Id: Profiling.h,v 1.3 1999/02/05 16:02:26 simonm Exp $
* $Id: Profiling.h,v 1.4 1999/03/25 13:14:03 simonm Exp $
*
* (c) The GHC Team, 1998-1999
*
......@@ -29,9 +29,8 @@
/* Constants used to set sumbsumed flag on CostCentres */
#define CC_IS_CAF 'c' /* 'c' => *is* a CAF cc */
#define CC_IS_DICT 'd' /* 'd' => *is* a dictionary cc */
#define CC_IS_SUBSUMED 's' /* 's' => *is* a subsumed cc */
#define CC_IS_BORING 'B' /* 'B' => *not* a CAF/dict/sub cc */
#define CC_IS_BORING 'B' /* 'B' => *not* a CAF/sub cc */
/* Constants used for abreviated output of data in binary format. The order
* is important and corresponds to the "item" elementType in the XML log
......@@ -81,7 +80,6 @@ typedef struct _CostCentreStack {
unsigned long scc_count;
unsigned long sub_scc_count;
unsigned long sub_cafcc_count;
unsigned long sub_dictcc_count;
unsigned long time_ticks;
unsigned long mem_alloc;
......@@ -160,6 +158,7 @@ extern hash_t max_type_no; /* Hash on type description */
* ---------------------------------------------------------------------------*/
CostCentreStack *PushCostCentre ( CostCentreStack *, CostCentre * );
CostCentreStack *AppendCCS ( CostCentreStack *ccs1, CostCentreStack *ccs2 );
CostCentreStack *ActualPush ( CostCentreStack *, CostCentre * );
CostCentreStack *RemoveCC ( CostCentreStack *, CostCentre * );
......
/* -----------------------------------------------------------------------------
* $Id: StgProf.h,v 1.3 1999/03/18 17:57:19 simonm Exp $
* $Id: StgProf.h,v 1.4 1999/03/25 13:14:04 simonm Exp $
*
* (c) The GHC Team, 1998
*
......@@ -102,7 +102,6 @@ extern CostCentreStack *CCS_LIST; /* registered CCS list */
scc_count : 0, \
sub_scc_count : 0, \
sub_cafcc_count : 0, \
sub_dictcc_count : 0, \
time_ticks : 0, \
mem_alloc : 0, \
is_subsumed : subsumed, \
......@@ -132,12 +131,11 @@ extern CostCentreStack *CCS_LIST; /* registered CCS list */
* Pushing a new cost centre (i.e. for scc annotations)
* -------------------------------------------------------------------------- */
# define SET_CCC_X(cc,do_subcc_count,do_subdict_count,do_scc_count) \
do { \
if (do_subcc_count) { CCCS->sub_scc_count++; } \
if (do_subdict_count) { CCCS->sub_dictcc_count++; } \
CCCS = PushCostCentre(CCCS,cc); \
if (do_scc_count) { CCCS->scc_count++; } \
# define SET_CCC_X(cc,do_subcc_count,do_scc_count) \
do { \
if (do_subcc_count) { CCCS->sub_scc_count++; } \
CCCS = PushCostCentre(CCCS,cc); \
if (do_scc_count) { CCCS->scc_count++; } \
} while(0)
/* We sometimes don't increment the scc_count field, for example when
......@@ -146,13 +144,10 @@ extern CostCentreStack *CCS_LIST; /* registered CCS list */
*/
# define SET_CCC(cc_ident,do_scc_count) \
SET_CCC_X(cc_ident,do_scc_count,0,do_scc_count)
# define SET_DICT_CCC(cc_ident,do_scc_count) \
SET_CCC_X(cc_ident,0,do_scc_count,do_scc_count)
SET_CCC_X(cc_ident,do_scc_count,do_scc_count)
# define SET_CCS_TOP(cc_ident) \
SET_CCC_X(cc_ident,0,0,1)
SET_CCC_X(cc_ident,0,1)
/* -----------------------------------------------------------------------------
* Allocating new cost centres / cost centre stacks.
......@@ -181,7 +176,6 @@ extern CostCentreStack *CCS_LIST; /* registered CCS list */
(stack)->scc_count = 0; \
(stack)->time_ticks = 0; \
(stack)->sub_cafcc_count = 0; \