summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsimonpj@microsoft.com <unknown>2009-11-09 10:37:03 +0000
committersimonpj@microsoft.com <unknown>2009-11-09 10:37:03 +0000
commitec73f013e4ec09a741a69bf50b78ecaf1fe0835f (patch)
tree6d08d41e7634fdbfe80d5b01e2325a244bdac902
parent374a85aec86d9c15ed4c48af3e284f9fee19ad72 (diff)
downloadhaskell-ec73f013e4ec09a741a69bf50b78ecaf1fe0835f.tar.gz
Wibble to substituting InlWrappers
See Note [Worker inlining] in CoreSubst
-rw-r--r--compiler/coreSyn/CoreSubst.lhs24
-rw-r--r--compiler/coreSyn/CoreSyn.lhs1
2 files changed, 18 insertions, 7 deletions
diff --git a/compiler/coreSyn/CoreSubst.lhs b/compiler/coreSyn/CoreSubst.lhs
index 14eccc61a4..b02bc80578 100644
--- a/compiler/coreSyn/CoreSubst.lhs
+++ b/compiler/coreSyn/CoreSubst.lhs
@@ -523,13 +523,11 @@ substUnfolding _ unf = unf -- NoUnfolding, OtherCon
-------------------
substInlineRuleInfo :: Subst -> InlineRuleInfo -> InlineRuleInfo
-substInlineRuleInfo subst (InlWrapper wkr)
- = case lookupIdSubst subst wkr of
- Var w1 -> InlWrapper w1
- other -> WARN( not (exprIsTrivial other), text "CoreSubst.substWorker:" <+> ppr wkr )
- InlVanilla -- Worker has got substituted away altogether
- -- (This can happen if it's trivial, via
- -- postInlineUnconditionally, hence only warning)
+substInlineRuleInfo (Subst in_scope ids _) (InlWrapper wkr)
+ | Just (Var w1) <- lookupVarEnv ids wkr = InlWrapper w1
+ | Just w1 <- lookupInScope in_scope wkr = InlWrapper w1
+ | otherwise = WARN( True, text "Interesting! CoreSubst.substWorker:" <+> ppr wkr )
+ InlVanilla -- Note [Worker inlining]
substInlineRuleInfo _ info = info
------------------
@@ -584,6 +582,18 @@ substVarSet subst fvs
| otherwise = Type.tyVarsOfType (lookupTvSubst subst fv)
\end{code}
+Note [Worker inlining]
+~~~~~~~~~~~~~~~~~~~~~~
+A worker can get sustituted away entirely.
+ - it might be trivial
+ - it might simply be very small
+We do not treat an InlWrapper as an 'occurrence' in the occurence
+analyser, so it's possible that the worker is not even in scope any more.
+
+In all all these cases we simply drop the special case, returning to
+InlVanilla. The WARN is just so I can see if it happens a lot.
+
+
%************************************************************************
%* *
The Very Simple Optimiser
diff --git a/compiler/coreSyn/CoreSyn.lhs b/compiler/coreSyn/CoreSyn.lhs
index e9e7f8db14..072463081b 100644
--- a/compiler/coreSyn/CoreSyn.lhs
+++ b/compiler/coreSyn/CoreSyn.lhs
@@ -477,6 +477,7 @@ data InlineRuleInfo
| InlWrapper Id -- This unfolding is a the wrapper in a
-- worker/wrapper split from the strictness analyser
+ -- The Id is the worker-id
-- Used to abbreviate the uf_tmpl in interface files
-- which don't need to contain the RHS;
-- it can be derived from the strictness info