[commit: ghc] master: Mark evaluated arguments in dataConInstPat (4088799)
git at git.haskell.org
git at git.haskell.org
Thu May 8 12:06:36 UTC 2014
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/40887990f274f900f306ca319d356f3046bf81a1/ghc
>---------------------------------------------------------------
commit 40887990f274f900f306ca319d356f3046bf81a1
Author: Simon Peyton Jones <simonpj at microsoft.com>
Date: Thu May 8 10:33:17 2014 +0100
Mark evaluated arguments in dataConInstPat
See Note [Mark evaluated arguments] in CoreUtils.
This is not a significant change, but avoids a spurious Lint complaint.
>---------------------------------------------------------------
40887990f274f900f306ca319d356f3046bf81a1
compiler/coreSyn/CoreUtils.lhs | 29 ++++++++++++++++++++++++-----
1 file changed, 24 insertions(+), 5 deletions(-)
diff --git a/compiler/coreSyn/CoreUtils.lhs b/compiler/coreSyn/CoreUtils.lhs
index ea2e17f..0acad9d 100644
--- a/compiler/coreSyn/CoreUtils.lhs
+++ b/compiler/coreSyn/CoreUtils.lhs
@@ -1222,7 +1222,7 @@ dataConInstPat :: [FastString] -- A long enough list of FSs to use for
-> [Unique] -- An equally long list of uniques, at least one for each binder
-> DataCon
-> [Type] -- Types to instantiate the universally quantified tyvars
- -> ([TyVar], [Id]) -- Return instantiated variables
+ -> ([TyVar], [Id]) -- Return instantiated variables
-- dataConInstPat arg_fun fss us con inst_tys returns a triple
-- (ex_tvs, arg_ids),
--
@@ -1257,7 +1257,7 @@ dataConInstPat fss uniqs con inst_tys
univ_tvs = dataConUnivTyVars con
ex_tvs = dataConExTyVars con
arg_tys = dataConRepArgTys con
-
+ arg_strs = dataConRepStrictness con -- 1-1 with arg_tys
n_ex = length ex_tvs
-- split the Uniques and FastStrings
@@ -1280,11 +1280,30 @@ dataConInstPat fss uniqs con inst_tys
kind = Type.substTy subst (tyVarKind tv)
-- Make value vars, instantiating types
- arg_ids = zipWith3 mk_id_var id_uniqs id_fss arg_tys
- mk_id_var uniq fs ty = mkUserLocal (mkVarOccFS fs) uniq
- (Type.substTy full_subst ty) noSrcSpan
+ arg_ids = zipWith4 mk_id_var id_uniqs id_fss arg_tys arg_strs
+ mk_id_var uniq fs ty str
+ = mkLocalIdWithInfo name (Type.substTy full_subst ty) info
+ where
+ name = mkInternalName uniq (mkVarOccFS fs) noSrcSpan
+ info | isMarkedStrict str = vanillaIdInfo `setUnfoldingInfo` evaldUnfolding
+ | otherwise = vanillaIdInfo
+ -- See Note [Mark evaluated arguments]
\end{code}
+Note [Mark evaluated arguments]
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+When pattern matching on a constructor with strict fields, the binder
+can have an 'evaldUnfolding'. Moreover, it *should* have one, so that
+when loading an interface file unfolding like:
+ data T = MkT !Int
+ f x = case x of { MkT y -> let v::Int# = case y of I# n -> n+1
+ in ... }
+we don't want Lint to complain. The 'y' is evaluated, so the
+case in the RHS of the binding for 'v' is fine. But only if we
+*know* that 'y' is evaluated.
+
+c.f. add_evals in Simplify.simplAlt
+
%************************************************************************
%* *
Equality
More information about the ghc-commits
mailing list