[commit: ghc] master: Simplify lintIdUnfolding (379bb20)

git at git.haskell.org git at git.haskell.org
Fri Jul 6 18:09:53 UTC 2018


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/379bb201417870482b310cf65505046650fc69b2/ghc

>---------------------------------------------------------------

commit 379bb201417870482b310cf65505046650fc69b2
Author: Matthew Pickering <matthew.pickering at tweag.io>
Date:   Fri Jul 6 11:00:40 2018 -0400

    Simplify lintIdUnfolding
    
    The logic for `DFunUnfolding` seemed quite confusing and unecessary. A
    simpler strategy uses `maybeUnfoldingTemplate`, as that is what is
    actually used when doing inlining and checking that has the right type.
    
    Reviewers: simonpj, goldfire, bgamari
    
    Reviewed By: bgamari
    
    Subscribers: rwbarton, thomie, carter
    
    Differential Revision: https://phabricator.haskell.org/D4919


>---------------------------------------------------------------

379bb201417870482b310cf65505046650fc69b2
 compiler/coreSyn/CoreLint.hs | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/compiler/coreSyn/CoreLint.hs b/compiler/coreSyn/CoreLint.hs
index d2724ba..93826f5 100644
--- a/compiler/coreSyn/CoreLint.hs
+++ b/compiler/coreSyn/CoreLint.hs
@@ -657,18 +657,11 @@ lintRhs _bndr rhs = fmap lf_check_static_ptrs getLintFlags >>= go
     go _ = markAllJoinsBad $ lintCoreExpr rhs
 
 lintIdUnfolding :: Id -> Type -> Unfolding -> LintM ()
-lintIdUnfolding bndr bndr_ty (CoreUnfolding { uf_tmpl = rhs, uf_src = src })
-  | isStableSource src
+lintIdUnfolding bndr bndr_ty uf
+  | isStableUnfolding uf
+  , Just rhs <- maybeUnfoldingTemplate uf
   = do { ty <- lintRhs bndr rhs
        ; ensureEqTys bndr_ty ty (mkRhsMsg bndr (text "unfolding") ty) }
-
-lintIdUnfolding bndr bndr_ty (DFunUnfolding { df_con = con, df_bndrs = bndrs
-                                            , df_args = args })
-  = do { ty <- lintBinders LambdaBind bndrs $ \ bndrs' ->
-               do { res_ty <- lintCoreArgs (dataConRepType con) args
-                  ; return (mkLamTypes bndrs' res_ty) }
-       ; ensureEqTys bndr_ty ty (mkRhsMsg bndr (text "dfun unfolding") ty) }
-
 lintIdUnfolding  _ _ _
   = return ()       -- Do not Lint unstable unfoldings, because that leads
                     -- to exponential behaviour; c.f. CoreFVs.idUnfoldingVars



More information about the ghc-commits mailing list