[commit: ghc] master: Do not inline bottoming things (a0174d2)

git at git.haskell.org git at git.haskell.org
Tue Feb 7 14:01:10 UTC 2017


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

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

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

commit a0174d2264358c5930a54e372d5d3ab5e713b87a
Author: Simon Peyton Jones <simonpj at microsoft.com>
Date:   Fri Jan 20 15:12:42 2017 +0000

    Do not inline bottoming things
    
    If a function seems small, worker/wrapper won't split it; instead
    it turns it into an INLINE function.
    
    But if it's a /bottoming/ function that's a bad idea.  We want
    don't want to inline bottoming functions unless they are /really/
    small (smaller than the call itself) and that's handled by a
    different branch in certainlyWillInline.
    
    So this patch adds a not-bottom test to the UnfIfGoodArgs case of
    certainlyWillInline.
    
    No big perf effect, but this will tend to keep error code out of
    functions, and hence make them a bit more likely to inline.
    
    I fell over this when fiddling with #13144


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

a0174d2264358c5930a54e372d5d3ab5e713b87a
 compiler/coreSyn/CoreUnfold.hs | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/compiler/coreSyn/CoreUnfold.hs b/compiler/coreSyn/CoreUnfold.hs
index a558dc4..f9ca36f 100644
--- a/compiler/coreSyn/CoreUnfold.hs
+++ b/compiler/coreSyn/CoreUnfold.hs
@@ -50,6 +50,7 @@ import CoreSubst hiding( substTy )
 import CoreArity       ( manifestArity )
 import CoreUtils
 import Id
+import Demand          ( isBottomingSig )
 import DataCon
 import Literal
 import PrimOp
@@ -1034,6 +1035,10 @@ certainlyWillInline dflags fn_info
       , case inlinePragmaSpec (inlinePragInfo fn_info) of
           NoInline -> False -- NOINLINE; do not say certainlyWillInline!
           _        -> True  -- INLINE, INLINABLE, or nothing
+      , not (isBottomingSig (strictnessInfo fn_info))
+              -- Do not unconditionally inline a bottoming functions even if
+              -- it seems smallish. We've carefully lifted it out to top level,
+              -- so we don't want to re-inline it.
       , let arity = length args
       , size - (10 * (arity + 1)) <= ufUseThreshold dflags
       = Just (fn_unf { uf_src      = InlineStable



More information about the ghc-commits mailing list