import CmdLineOpts ( opt_AutoSccsOnIndividualCafs )
import CostCentre -- lots of things
-import Const ( Con(..) )
import Id ( Id, mkSysLocal, idType, idName )
import Module ( Module )
import UniqSupply ( uniqFromSupply, splitUniqSupply, UniqSupply )
import TyCon ( isFunTyCon )
import VarSet
import UniqSet
-import Name ( isLocallyDefinedName )
+import Name ( isLocallyDefined )
import Util ( removeDups )
import Outputable
[CostCentreStack]) -- singleton stacks (for CAFs)
stgMassageForProfiling
- :: Module -> FAST_STRING -- module name, group name
+ :: Module -- module name
-> UniqSupply -- unique supply
-> [StgBinding] -- input
-> (CollectedCCs, [StgBinding])
-stgMassageForProfiling mod_name grp_name us stg_binds
+stgMassageForProfiling mod_name us stg_binds
= let
((local_ccs, extern_ccs, cc_stacks),
stg_binds2)
fixed_cc_stacks ++ cc_stacks), stg_binds2)
where
- all_cafs_cc = mkAllCafsCC mod_name grp_name
+ all_cafs_cc = mkAllCafsCC mod_name
all_cafs_ccs = mkSingletonCCS all_cafs_cc
----------
----------
do_top_rhs :: Id -> StgRhs -> MassageM StgRhs
- do_top_rhs binder (StgRhsClosure _ bi srt fv u [] (StgSCC cc (StgCon (DataCon con) args _)))
+ do_top_rhs binder (StgRhsClosure _ bi srt fv u [] (StgSCC cc (StgConApp con args)))
| not (isSccCountCostCentre cc)
-- Trivial _scc_ around nothing but static data
-- Eliminate _scc_ ... and turn into StgRhsCon
-- Top level CAF without a cost centre attached
-- Attach CAF cc (collect if individual CAF ccs)
= (if opt_AutoSccsOnIndividualCafs
- then let cc = mkAutoCC binder mod_name grp_name CafCC
+ then let cc = mkAutoCC binder mod_name CafCC
ccs = mkSingletonCCS cc
in
collectCC cc `thenMM_`
------
do_expr :: StgExpr -> MassageM StgExpr
+ do_expr (StgLit l) = returnMM (StgLit l)
+
do_expr (StgApp fn args)
= boxHigherOrderArgs (StgApp fn) args
- do_expr (StgCon con args res_ty)
- = boxHigherOrderArgs (\args -> StgCon con args res_ty) args
+ do_expr (StgConApp con args)
+ = boxHigherOrderArgs (\args -> StgConApp con args) args
+
+ do_expr (StgPrimApp con args res_ty)
+ = boxHigherOrderArgs (\args -> StgPrimApp con args res_ty) args
do_expr (StgSCC cc expr) -- Ha, we found a cost centre!
= collectCC cc `thenMM_`
%* *
%************************************************************************
+Boxing is *turned off* at the moment, until we can figure out how to
+do it properly in general.
+
\begin{code}
boxHigherOrderArgs
:: ([StgArg] -> StgExpr)
-> [StgArg] -- arguments which we might box
-> MassageM StgExpr
+#ifndef PROF_DO_BOXING
+boxHigherOrderArgs almost_expr args
+ = returnMM (almost_expr args)
+#else
boxHigherOrderArgs almost_expr args
= getTopLevelIshIds `thenMM` \ ids ->
mapAccumMM (do_arg ids) [] args `thenMM` \ (let_bindings, new_args) ->
returnMM (foldr (mk_stg_let currentCCS) (almost_expr new_args) let_bindings)
where
---------------
- do_arg ids bindings atom@(StgConArg _) = returnMM (bindings, atom)
- do_arg ids bindings atom@(StgVarArg old_var)
- = let
- var_type = idType old_var
+ do_arg ids bindings arg@(StgVarArg old_var)
+ | (not (isLocallyDefined old_var) || elemVarSet old_var ids)
+ && isFunType var_type
+ = -- make a trivial let-binding for the top-level function
+ getUniqueMM `thenMM` \ uniq ->
+ let
+ new_var = mkSysLocal SLIT("sf") uniq var_type
in
- if ( not (isLocallyDefinedName (idName old_var)) ||
- elemVarSet old_var ids ) && isFunType var_type
- then
- -- make a trivial let-binding for the top-level function
- getUniqueMM `thenMM` \ uniq ->
- let
- new_var = mkSysLocal SLIT("sf") uniq var_type
- in
- returnMM ( (new_var, old_var) : bindings, StgVarArg new_var )
- else
- returnMM (bindings, atom)
+ returnMM ( (new_var, old_var) : bindings, StgVarArg new_var )
+ where
+ var_type = idType old_var
+
+ do_arg ids bindings arg = returnMM (bindings, arg)
---------------
mk_stg_let :: CostCentreStack -> (Id, Id) -> StgExpr -> StgExpr
(_, ty) -> case splitTyConApp_maybe ty of
Just (tycon,_) | isFunTyCon tycon -> True
_ -> False
-
+#endif
\end{code}
%************************************************************************