[commit: ghc] master: Make worker/wrapper robust to bogus unsafeCorece (a1b6932)
git at git.haskell.org
git at git.haskell.org
Fri Nov 8 10:51:48 UTC 2013
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/a1b6932419a2d425b2a3b7672926a0f9c368f234/ghc
>---------------------------------------------------------------
commit a1b6932419a2d425b2a3b7672926a0f9c368f234
Author: Simon Peyton Jones <simonpj at microsoft.com>
Date: Fri Nov 8 10:51:20 2013 +0000
Make worker/wrapper robust to bogus unsafeCorece
Fixes Trac #8037
>---------------------------------------------------------------
a1b6932419a2d425b2a3b7672926a0f9c368f234
compiler/stranal/WwLib.lhs | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/compiler/stranal/WwLib.lhs b/compiler/stranal/WwLib.lhs
index 2548b0e..10e5ed3 100644
--- a/compiler/stranal/WwLib.lhs
+++ b/compiler/stranal/WwLib.lhs
@@ -444,6 +444,8 @@ mkWWstr_one dflags arg
-- See Note [Unpacking arguments with product and polymorphic demands]
, Just (data_con, inst_tys, inst_con_arg_tys, co)
<- deepSplitProductType_maybe (idType arg)
+ , cs `equalLength` inst_con_arg_tys
+ -- See Note [mkWWstr and unsafeCore]
= do { (uniq1:uniqs) <- getUniquesM
; let unpk_args = zipWith mk_ww_local uniqs inst_con_arg_tys
unpk_args_w_ds = zipWithEqual "mkWWstr" set_worker_arg_info unpk_args cs
@@ -473,6 +475,13 @@ nop_fn :: CoreExpr -> CoreExpr
nop_fn body = body
\end{code}
+Note [mkWWstr and unsafeCoerce]
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+Byy using usafeCoerce, it is possible to make the number of demands fail to
+match the number of constructor arguments; this happened in Trac #8037.
+If so, the worker/wrapper split doesn't work right and we get a Core Lint
+bug. The fix here is simply to decline to do w/w if that happens.
+
\begin{code}
deepSplitProductType_maybe :: Type -> Maybe (DataCon, [Type], [Type], Coercion)
-- If deepSplitProductType_maybe ty = Just (dc, tys, arg_tys, co)
More information about the ghc-commits
mailing list