summaryrefslogtreecommitdiff
path: root/compiler/simplCore/SimplCore.lhs
diff options
context:
space:
mode:
authorSimon Peyton Jones <simonpj@microsoft.com>2011-09-23 06:46:30 +0100
committerSimon Peyton Jones <simonpj@microsoft.com>2011-09-23 06:46:30 +0100
commit24a2353a77111e9f236325521edd233f35954328 (patch)
tree4d25308abe4fa1d80404c2daeaf10eb0781849c2 /compiler/simplCore/SimplCore.lhs
parent730f6c6e81cd4cd2cf03c6a1e6dbdcb77b1f089e (diff)
downloadhaskell-24a2353a77111e9f236325521edd233f35954328.tar.gz
Add a transformation limit to the simplifier (Trac #5448)
This addresses the rare cases where the simplifier diverges (see the above ticket). We were already counting how many simplifier steps were taking place, but with no limit. This patch adds a limit; at which point we halt compilation, and print out useful stats. The stats show what is begin inlined, and how often, which points you directly to the problem. The limit is set based on the size of the program. Instead of halting compilation, we could instead just inhibit inlining, which would let compilation of the module complete. This is a bit harder to implement, and it's likely to mean that you unrolled the function 1143 times and then ran out of ticks; you probably don't want to complete parsing on this highly-unrolled program. Flags: -dsimpl-tick-factor=N. Default is 100 (percent). A bigger number increases the allowed maximum tick count.
Diffstat (limited to 'compiler/simplCore/SimplCore.lhs')
-rw-r--r--compiler/simplCore/SimplCore.lhs10
1 files changed, 6 insertions, 4 deletions
diff --git a/compiler/simplCore/SimplCore.lhs b/compiler/simplCore/SimplCore.lhs
index 20425db8f6..3c89b0fa5d 100644
--- a/compiler/simplCore/SimplCore.lhs
+++ b/compiler/simplCore/SimplCore.lhs
@@ -18,7 +18,7 @@ import Rules ( RuleBase, emptyRuleBase, mkRuleBase, unionRuleBase,
import PprCore ( pprCoreBindings, pprCoreExpr )
import OccurAnal ( occurAnalysePgm, occurAnalyseExpr )
import IdInfo
-import CoreUtils ( coreBindsSize )
+import CoreUtils ( coreBindsSize, exprSize )
import Simplify ( simplTopBinds, simplExpr )
import SimplUtils ( simplEnvForGHCi, activeRule )
import SimplEnv
@@ -478,7 +478,8 @@ simplifyExpr dflags expr
; us <- mkSplitUniqSupply 's'
- ; let (expr', _counts) = initSmpl dflags emptyRuleBase emptyFamInstEnvs us $
+ ; let sz = exprSize expr
+ (expr', _counts) = initSmpl dflags emptyRuleBase emptyFamInstEnvs us sz $
simplExprGently (simplEnvForGHCi dflags) expr
; Err.dumpIfSet_dyn dflags Opt_D_dump_simpl "Simplified expression"
@@ -581,7 +582,8 @@ simplifyPgmIO pass@(CoreDoSimplify max_iterations mode)
-- Try and force thunks off the binds; significantly reduces
-- space usage, especially with -O. JRS, 000620.
- | let sz = coreBindsSize binds in sz == sz
+ | let sz = coreBindsSize binds
+ , sz == sz -- Force it
= do {
-- Occurrence analysis
let { -- During the 'InitialPhase' (i.e., before vectorisation), we need to make sure
@@ -620,7 +622,7 @@ simplifyPgmIO pass@(CoreDoSimplify max_iterations mode)
-- case t of {(_,counts1) -> if counts1=0 then ... }
-- So the conditional didn't force counts1, because the
-- selection got duplicated. Sigh!
- case initSmpl dflags rule_base2 fam_envs us1 simpl_binds of {
+ case initSmpl dflags rule_base2 fam_envs us1 sz simpl_binds of {
(env1, counts1) -> do {
let { binds1 = getFloats env1