)
import CoreSyn
import CoreFVs ( ruleRhsFreeVars )
-import HscTypes ( PersistentCompilerState(..), ExternalPackageState(..),
- HscEnv(..), GhciMode(..),
+import HscTypes ( HscEnv(..), GhciMode(..),
ModGuts(..), ModGuts, Avails, availsToNameSet,
PackageRuleBase, HomePackageTable, ModDetails(..),
HomeModInfo(..)
import SAT ( doStaticArgs )
import Specialise ( specProgram)
import SpecConstr ( specConstrProgram)
-import UsageSPInf ( doUsageSPInf )
import DmdAnal ( dmdAnalPgm )
import WorkWrap ( wwTopBinds )
#ifdef OLD_STRICTNESS
\begin{code}
core2core :: HscEnv
- -> PersistentCompilerState
+ -> PackageRuleBase
-> ModGuts
-> IO ModGuts
-core2core hsc_env pcs
+core2core hsc_env pkg_rule_base
mod_impl@(ModGuts { mg_exports = exports,
mg_binds = binds_in,
mg_rules = rules_in })
hpt = hsc_HPT hsc_env
ghci_mode = hsc_mode hsc_env
core_todos = dopt_CoreToDo dflags
- pkg_rule_base = eps_rule_base (pcs_EPS pcs) -- Rule-base accumulated from imported packages
us <- mkSplitUniqSupply 's'
let (cp_us, ru_us) = splitUniqSupply us
; us <- mkSplitUniqSupply 's'
- ; let env = emptySimplEnv (SimplPhase 0) [] emptyVarSet
+ ; let env = emptySimplEnv SimplGently [] emptyVarSet
(expr', _counts) = initSmpl dflags us (simplExprGently env expr)
; dumpIfSet_dyn dflags Opt_D_dump_simpl "Simplified expression"
#endif
doCorePass dfs rb us binds CoreDoPrintCore
= _scc_ "PrintCore" noStats dfs (printCore binds)
-doCorePass dfs rb us binds CoreDoUSPInf
- = _scc_ "CoreUsageSPInf" noStats dfs (doUsageSPInf dfs us binds)
doCorePass dfs rb us binds CoreDoGlomBinds
= noStats dfs (glomBinds dfs binds)
doCorePass dfs rb us binds (CoreDoRuleCheck phase pat)
-- alone leaves tons of crud.
-- Used (a) for user expressions typed in at the interactive prompt
-- (b) the LHS and RHS of a RULE
+--
+-- The name 'Gently' suggests that the SimplifierMode is SimplGently,
+-- and in fact that is so.... but the 'Gently' in simplExprGently doesn't
+-- enforce that; it just simplifies the expression twice
+
simplExprGently env expr
= simplExpr env (occurAnalyseGlobalExpr expr) `thenSmpl` \ expr1 ->
simplExpr env (occurAnalyseGlobalExpr expr1)
max_iterations = intSwitchSet sw_chkr MaxSimplifierIterations `orElse` 2
iteration us iteration_no counts binds
+ -- iteration_no is the number of the iteration we are
+ -- about to begin, with '1' for the first
+ | iteration_no > max_iterations -- Stop if we've run out of iterations
+ = do {
+#ifdef DEBUG
+ if max_iterations > 2 then
+ hPutStr stderr ("NOTE: Simplifier still going after " ++
+ show max_iterations ++
+ " iterations; bailing out.\n")
+ else
+ return ();
+#endif
+ -- Subtract 1 from iteration_no to get the
+ -- number of iterations we actually completed
+ return ("Simplifier baled out", iteration_no - 1, counts, binds)
+ }
+
-- Try and force thunks off the binds; significantly reduces
-- space usage, especially with -O. JRS, 000620.
| let sz = coreBindsSize binds in sz == sz
-- t = initSmpl ...
-- counts' = snd t
-- in
- -- case t of {(_,counts') -> if counts'=0 then ...
+ -- case t of {(_,counts') -> if counts'=0 then ... }
-- So the conditional didn't force counts', because the
-- selection got duplicated. Sigh!
case initSmpl dflags us1 (simplTopBinds simpl_env tagged_binds) of {
-- Dump the result of this iteration
dumpIfSet_dyn dflags Opt_D_dump_simpl_iterations herald
- (pprSimplCount counts') ;
+ (pprSimplCount counts') ;
endPass dflags herald Opt_D_dump_simpl_iterations binds' ;
- -- Stop if we've run out of iterations
- if iteration_no == max_iterations then
- do {
-#ifdef DEBUG
- if max_iterations > 2 then
- hPutStr stderr ("NOTE: Simplifier still going after " ++
- show max_iterations ++
- " iterations; bailing out.\n")
- else
-#endif
- return ();
-
- return ("Simplifier baled out", iteration_no, all_counts, binds')
- }
-
- -- Else loop
- else iteration us2 (iteration_no + 1) all_counts binds'
+ -- Loop
+ iteration us2 (iteration_no + 1) all_counts binds'
} } } }
where
(us1, us2) = splitUniqSupply us