Commit e731cb13 authored by ian@well-typed.com's avatar ian@well-typed.com

Make -f(no-)pre-inlining a dynamic flag

parent a327c140
......@@ -341,6 +341,10 @@ data DynFlag
| Opt_RelativeDynlibPaths
| Opt_Hpc
-- PreInlining is on by default. The option is there just to see how
-- bad things get if you turn it off!
| Opt_SimplPreInlining
-- output style opts
| Opt_ErrorSpans -- Include full span info in error messages,
-- instead of just the start position.
......@@ -2331,6 +2335,7 @@ fFlags = [
( "prof-count-entries", Opt_ProfCountEntries, nop ),
( "prof-cafs", Opt_AutoSccsOnIndividualCafs, nop ),
( "hpc", Opt_Hpc, nop ),
( "pre-inlining", Opt_SimplPreInlining, nop ),
( "use-rpaths", Opt_RPath, nop )
]
......@@ -2512,6 +2517,7 @@ defaultFlags settings
Opt_GhciHistory,
Opt_HelpfulErrors,
Opt_ProfCountEntries,
Opt_SimplPreInlining,
Opt_RPath
]
......
......@@ -120,7 +120,6 @@ isStaticFlag f =
"dno-black-holing",
"fno-state-hack",
"fruntime-types",
"fno-pre-inlining",
"fno-opt-coercion",
"fno-flat-cache",
"fexcess-precision",
......
......@@ -35,7 +35,6 @@ module StaticFlags (
-- optimisation opts
opt_NoStateHack,
opt_CprOff,
opt_SimplNoPreInlining,
opt_SimplExcessPrecision,
opt_NoOptCoercion,
opt_NoFlatCache,
......@@ -179,10 +178,6 @@ opt_CprOff = lookUp (fsLit "-fcpr-off")
-- Switch off CPR analysis in the new demand analyser
-- Simplifier switches
opt_SimplNoPreInlining :: Bool
opt_SimplNoPreInlining = lookUp (fsLit "-fno-pre-inlining")
-- NoPreInlining is there just to see how bad things
-- get if you don't do it!
opt_SimplExcessPrecision :: Bool
opt_SimplExcessPrecision = lookUp (fsLit "-fexcess-precision")
......
......@@ -34,7 +34,6 @@ import SimplEnv
import CoreMonad ( SimplifierMode(..), Tick(..) )
import MkCore ( sortQuantVars )
import DynFlags
import StaticFlags
import CoreSyn
import qualified CoreSubst
import PprCore
......@@ -812,12 +811,12 @@ is a term (not a coercion) so we can't necessarily inline the latter in
the former.
\begin{code}
preInlineUnconditionally :: SimplEnv -> TopLevelFlag -> InId -> InExpr -> Bool
preInlineUnconditionally env top_lvl bndr rhs
preInlineUnconditionally :: DynFlags -> SimplEnv -> TopLevelFlag -> InId -> InExpr -> Bool
preInlineUnconditionally dflags env top_lvl bndr rhs
| not active = False
| isStableUnfolding (idUnfolding bndr) = False -- Note [InlineRule and preInlineUnconditionally]
| isTopLevel top_lvl && isBottomingId bndr = False -- Note [Top-level bottoming Ids]
| opt_SimplNoPreInlining = False
| not (dopt Opt_SimplPreInlining dflags) = False
| isCoVar bndr = False -- Note [Do not inline CoVars unconditionally]
| otherwise = case idOccInfo bndr of
IAmDead -> True -- Happens in ((\x.1) v)
......
......@@ -291,12 +291,12 @@ simplRecOrTopPair :: SimplEnv
-> SimplM SimplEnv -- Returns an env that includes the binding
simplRecOrTopPair env top_lvl is_rec old_bndr new_bndr rhs
| preInlineUnconditionally env top_lvl old_bndr rhs -- Check for unconditional inline
= do { tick (PreInlineUnconditionally old_bndr)
; return (extendIdSubst env old_bndr (mkContEx env rhs)) }
| otherwise
= simplLazyBind env top_lvl is_rec old_bndr new_bndr rhs env
= do dflags <- getDynFlags
-- Check for unconditional inline
if preInlineUnconditionally dflags env top_lvl old_bndr rhs
then do tick (PreInlineUnconditionally old_bndr)
return (extendIdSubst env old_bndr (mkContEx env rhs))
else simplLazyBind env top_lvl is_rec old_bndr new_bndr rhs env
\end{code}
......@@ -1333,21 +1333,24 @@ simplNonRecE env bndr (Type ty_arg, rhs_se) (bndrs, body) cont
; simplLam (extendTvSubst env bndr ty_arg') bndrs body cont }
simplNonRecE env bndr (rhs, rhs_se) (bndrs, body) cont
| preInlineUnconditionally env NotTopLevel bndr rhs
= do { tick (PreInlineUnconditionally bndr)
; -- pprTrace "preInlineUncond" (ppr bndr <+> ppr rhs) $
simplLam (extendIdSubst env bndr (mkContEx rhs_se rhs)) bndrs body cont }
| isStrictId bndr -- Includes coercions
= do { simplExprF (rhs_se `setFloats` env) rhs
(StrictBind bndr bndrs body env cont) }
| otherwise
= ASSERT( not (isTyVar bndr) )
do { (env1, bndr1) <- simplNonRecBndr env bndr
; let (env2, bndr2) = addBndrRules env1 bndr bndr1
; env3 <- simplLazyBind env2 NotTopLevel NonRecursive bndr bndr2 rhs rhs_se
; simplLam env3 bndrs body cont }
= do dflags <- getDynFlags
case () of
_
| preInlineUnconditionally dflags env NotTopLevel bndr rhs ->
do { tick (PreInlineUnconditionally bndr)
; -- pprTrace "preInlineUncond" (ppr bndr <+> ppr rhs) $
simplLam (extendIdSubst env bndr (mkContEx rhs_se rhs)) bndrs body cont }
| isStrictId bndr -> -- Includes coercions
do { simplExprF (rhs_se `setFloats` env) rhs
(StrictBind bndr bndrs body env cont) }
| otherwise ->
ASSERT( not (isTyVar bndr) )
do { (env1, bndr1) <- simplNonRecBndr env bndr
; let (env2, bndr2) = addBndrRules env1 bndr bndr1
; env3 <- simplLazyBind env2 NotTopLevel NonRecursive bndr bndr2 rhs rhs_se
; simplLam env3 bndrs body cont }
\end{code}
%************************************************************************
......
......@@ -1627,7 +1627,7 @@
<row>
<entry><option>-fno-pre-inlining</option></entry>
<entry>Turn off pre-inlining</entry>
<entry>static</entry>
<entry>dynamic</entry>
<entry>-</entry>
</row>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment