import OccurAnal ( occurAnalysePgm, occurAnalyseExpr )
import IdInfo ( setNewStrictnessInfo, newStrictnessInfo,
setWorkerInfo, workerInfo,
+ setInlinePragInfo, inlinePragInfo,
setSpecInfo, specInfo, specInfoRules )
import CoreUtils ( coreBindsSize )
import Simplify ( simplTopBinds, simplExpr )
doCorePasses hsc_env rb us stats guts []
= return (stats, guts)
+doCorePasses hsc_env rb us stats guts (CoreDoPasses to_dos1 : to_dos2)
+ = doCorePasses hsc_env rb us stats guts (to_dos1 ++ to_dos2)
+
doCorePasses hsc_env rb us stats guts (to_do : to_dos)
= do
let (us1, us2) = splitUniqSupply us
(stats1, guts1) <- doCorePass to_do hsc_env us1 rb guts
doCorePasses hsc_env rb us2 (stats `plusSimplCount` stats1) guts1 to_dos
+doCorePass :: CoreToDo -> HscEnv -> UniqSupply -> RuleBase
+ -> ModGuts -> IO (SimplCount, ModGuts)
doCorePass (CoreDoSimplify mode sws) = _scc_ "Simplify" simplifyPgm mode sws
doCorePass CoreCSE = _scc_ "CommonSubExpr" trBinds cseProgram
-doCorePass CoreLiberateCase = _scc_ "LiberateCase" trBinds liberateCase
+doCorePass CoreLiberateCase = _scc_ "LiberateCase" liberateCase
doCorePass CoreDoFloatInwards = _scc_ "FloatInwards" trBinds floatInwards
doCorePass (CoreDoFloatOutwards f) = _scc_ "FloatOutwards" trBindsU (floatOutwards f)
doCorePass CoreDoStaticArgs = _scc_ "StaticArgs" trBinds doStaticArgs
doCorePass CoreDoNothing = observe (\ _ _ -> return ())
#ifdef OLD_STRICTNESS
doCorePass CoreDoOldStrictness = _scc_ "OldStrictness" trBinds doOldStrictness
+#else
+doCorePass CoreDoOldStrictness = panic "CoreDoOldStrictness"
#endif
+doCorePass (CoreDoPasses _) = panic "CoreDoPasses"
#ifdef OLD_STRICTNESS
doOldStrictness dfs binds
text "",
pprSimplCount counts_out]);
- endPass dflags "Simplify" Opt_D_verbose_core2core binds';
+ endPass dflags ("Simplify phase " ++ phase_info ++ " done") Opt_D_verbose_core2core binds';
return (counts_out, guts { mg_binds = binds' })
}
-- because indirection-shorting uses the export flag on *occurrences*
-- and that isn't guaranteed to be ok until after the first run propagates
-- stuff from the binding site to its occurrences
+ --
+ -- ToDo: alas, this means that indirection-shorting does not happen at all
+ -- if the simplifier does nothing (not common, I know, but unsavoury)
let { binds'' = _scc_ "ZapInd" shortOutIndirections binds' } ;
-- Dump the result of this iteration
shortOutIndirections :: [CoreBind] -> [CoreBind]
shortOutIndirections binds
| isEmptyVarEnv ind_env = binds
- | no_need_to_flatten = binds'
- | otherwise = [Rec (flattenBinds binds')] -- See Note [Rules and indirect-zapping]
+ | no_need_to_flatten = binds' -- See Note [Rules and indirect-zapping]
+ | otherwise = [Rec (flattenBinds binds')] -- for this no_need_to_flatten stuff
where
ind_env = makeIndEnv binds
exp_ids = varSetElems ind_env -- These exported Ids are the subjects
-----------------
transferIdInfo :: Id -> Id -> Id
+-- If we have
+-- lcl_id = e; exp_id = lcl_id
+-- and lcl_id has useful IdInfo, we don't want to discard it by going
+-- gbl_id = e; lcl_id = gbl_id
+-- Instead, transfer IdInfo from lcl_id to exp_id
+-- Overwriting, rather than merging, seems to work ok.
transferIdInfo exported_id local_id
= modifyIdInfo transfer exported_id
where
local_info = idInfo local_id
transfer exp_info = exp_info `setNewStrictnessInfo` newStrictnessInfo local_info
`setWorkerInfo` workerInfo local_info
+ `setInlinePragInfo` inlinePragInfo local_info
`setSpecInfo` addSpecInfo (specInfo exp_info)
(specInfo local_info)
\end{code}