[commit: ghc] master: Make maybeUnfoldingTemplate respond to DFunUnfoldings (8f09937)

git at git.haskell.org git at git.haskell.org
Thu Aug 28 11:11:53 UTC 2014


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

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/8f09937426a40b9c638d63a2d726c3b755f88f82/ghc

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

commit 8f09937426a40b9c638d63a2d726c3b755f88f82
Author: Simon Peyton Jones <simonpj at microsoft.com>
Date:   Fri May 9 10:59:40 2014 +0100

    Make maybeUnfoldingTemplate respond to DFunUnfoldings
    
    CoreSyn.maybeUnfoldingTemplate is used mainly when specialising,
    so make DFunUnfoldings respond to it makes it possible to specialise
    them properly.


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

8f09937426a40b9c638d63a2d726c3b755f88f82
 compiler/coreSyn/CoreSyn.lhs | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/compiler/coreSyn/CoreSyn.lhs b/compiler/coreSyn/CoreSyn.lhs
index f16e53d..e82303c 100644
--- a/compiler/coreSyn/CoreSyn.lhs
+++ b/compiler/coreSyn/CoreSyn.lhs
@@ -869,9 +869,16 @@ unfoldingTemplate :: Unfolding -> CoreExpr
 unfoldingTemplate = uf_tmpl
 
 -- | Retrieves the template of an unfolding if possible
+-- maybeUnfoldingTemplate is used mainly wnen specialising, and we do
+-- want to specialise DFuns, so it's important to return a template
+-- for DFunUnfoldings
 maybeUnfoldingTemplate :: Unfolding -> Maybe CoreExpr
-maybeUnfoldingTemplate (CoreUnfolding { uf_tmpl = expr })       = Just expr
-maybeUnfoldingTemplate _                            		= Nothing
+maybeUnfoldingTemplate (CoreUnfolding { uf_tmpl = expr })
+  = Just expr
+maybeUnfoldingTemplate (DFunUnfolding { df_bndrs = bndrs, df_con = con, df_args = args })
+  = Just (mkLams bndrs (mkApps (Var (dataConWorkId con)) args))
+maybeUnfoldingTemplate _
+  = Nothing
 
 -- | The constructors that the unfolding could never be: 
 -- returns @[]@ if no information is available



More information about the ghc-commits mailing list