summaryrefslogtreecommitdiff
path: root/compiler/stranal/WorkWrap.hs
diff options
context:
space:
mode:
authorSimon Peyton Jones <simonpj@microsoft.com>2016-10-14 12:05:46 +0100
committerSimon Peyton Jones <simonpj@microsoft.com>2016-10-17 08:41:19 +0100
commit692c8df03969ee6a0de5158f05907b16689945d0 (patch)
treef0609951e365407e009520c15f4679633b722554 /compiler/stranal/WorkWrap.hs
parent82b54fcf815ccd80be8887401dd69ab7a488386e (diff)
downloadhaskell-692c8df03969ee6a0de5158f05907b16689945d0.tar.gz
Fix shadowing in mkWwBodies
This bug, exposed by Trac #12562 was very obscure, and has been lurking for a long time. What happened was that, in the worker/wrapper split a tyvar binder for a worker function accidentally shadowed an in-scope term variable that was mentioned in the body of the function It's jolly hard to provoke, so I have not even attempted to make a test case. There's a Note [Freshen WW arguments] to explain. Interestingly, fixing the bug (which meant fresher type variables) revealed a second lurking bug: I'd failed to apply the substitution to the coercion in the second last case of mkWWArgs, which introduces a Cast.
Diffstat (limited to 'compiler/stranal/WorkWrap.hs')
-rw-r--r--compiler/stranal/WorkWrap.hs4
1 files changed, 3 insertions, 1 deletions
diff --git a/compiler/stranal/WorkWrap.hs b/compiler/stranal/WorkWrap.hs
index 80d966b392..9acc461c20 100644
--- a/compiler/stranal/WorkWrap.hs
+++ b/compiler/stranal/WorkWrap.hs
@@ -10,6 +10,7 @@ module WorkWrap ( wwTopBinds ) where
import CoreSyn
import CoreUnfold ( certainlyWillInline, mkWwInlineRule, mkWorkerUnfolding )
import CoreUtils ( exprType, exprIsHNF )
+import CoreFVs ( exprFreeVars )
import Var
import Id
import IdInfo
@@ -365,7 +366,7 @@ splitFun :: DynFlags -> FamInstEnvs -> Id -> IdInfo -> [Demand] -> DmdResult ->
splitFun dflags fam_envs fn_id fn_info wrap_dmds res_info rhs
= WARN( not (wrap_dmds `lengthIs` arity), ppr fn_id <+> (ppr arity $$ ppr wrap_dmds $$ ppr res_info) ) do
-- The arity should match the signature
- stuff <- mkWwBodies dflags fam_envs fun_ty wrap_dmds res_info
+ stuff <- mkWwBodies dflags fam_envs rhs_fvs fun_ty wrap_dmds res_info
case stuff of
Just (work_demands, wrap_fn, work_fn) -> do
work_uniq <- getUniqueM
@@ -432,6 +433,7 @@ splitFun dflags fam_envs fn_id fn_info wrap_dmds res_info rhs
Nothing -> return [(fn_id, rhs)]
where
+ rhs_fvs = exprFreeVars rhs
fun_ty = idType fn_id
inl_prag = inlinePragInfo fn_info
rule_match_info = inlinePragmaRuleMatchInfo inl_prag