[commit: ghc] wip/better-ho-cardinality: Do not split void functions (20f8ee7)

git at git.haskell.org git at git.haskell.org
Wed Dec 11 18:34:20 UTC 2013


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

On branch  : wip/better-ho-cardinality
Link       : http://ghc.haskell.org/trac/ghc/changeset/20f8ee758a359231ebb467bcee115671d082cb53/ghc

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

commit 20f8ee758a359231ebb467bcee115671d082cb53
Author: Simon Peyton Jones <simonpj at microsoft.com>
Date:   Wed Dec 11 18:30:54 2013 +0000

    Do not split void functions
    
    This is authored by SPJ, and split out out "Improve the handling of
    used-once stuff" by Joachim.


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

20f8ee758a359231ebb467bcee115671d082cb53
 compiler/stranal/WorkWrap.lhs |   19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/compiler/stranal/WorkWrap.lhs b/compiler/stranal/WorkWrap.lhs
index 6857961..c7b8201 100644
--- a/compiler/stranal/WorkWrap.lhs
+++ b/compiler/stranal/WorkWrap.lhs
@@ -257,7 +257,7 @@ tryWW dflags is_rec fn_id rhs
 	-- Furthermore, don't even expose strictness info
   = return [ (fn_id, rhs) ]
 
-  | is_fun && (any worthSplittingArgDmd wrap_dmds || returnsCPR res_info)
+  | is_fun && (worth_splitting_args wrap_dmds rhs || returnsCPR res_info)
   = checkSize dflags new_fn_id rhs $
     splitFun dflags new_fn_id fn_info wrap_dmds res_info rhs
 
@@ -275,6 +275,12 @@ tryWW dflags is_rec fn_id rhs
     fn_dmd       = demandInfo fn_info
     inline_act   = inlinePragmaActivation (inlinePragInfo fn_info)
 
+    worth_splitting_args [d] (Lam b _)
+      | isAbsDmd d && isVoidTy (idType b)
+      = False  -- Note [Do not split void functions]
+    worth_splitting_args wrap_dmds _
+      = any worthSplittingArgDmd wrap_dmds
+
 	-- In practice it always will have a strictness
 	-- signature, even if it's a uninformative one
     strict_sig  = strictnessInfo fn_info
@@ -395,6 +401,17 @@ noOneShotInfo :: [Bool]
 noOneShotInfo = repeat False
 \end{code}
 
+Note [Do not split void functions]
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+Consider this rather common form of binding:
+        $j = \x:Void# -> ...no use of x...
+
+Since x is not used it'll be marked as absent.  But there is no point
+in w/w-ing because we'll simply add (\y:Void#), see WwLib.mkWorerArgs.
+
+If x has a more interesting type (eg Int, or Int#), there *is* a point
+in w/w so that we don't pass the argument at all.
+
 Note [Thunk splitting]
 ~~~~~~~~~~~~~~~~~~~~~~
 Suppose x is used strictly (never mind whether it has the CPR



More information about the ghc-commits mailing list