diff options
author | Simon Peyton Jones <simonpj@microsoft.com> | 2017-01-20 15:12:42 +0000 |
---|---|---|
committer | Simon Peyton Jones <simonpj@microsoft.com> | 2017-02-07 14:00:46 +0000 |
commit | a0174d2264358c5930a54e372d5d3ab5e713b87a (patch) | |
tree | f56c0c5b961fffc9ef4c9304f5c24cdd9db3ee95 | |
parent | 17ae5e79cad49ff05941d9d9234648b15d0169dc (diff) | |
download | haskell-a0174d2264358c5930a54e372d5d3ab5e713b87a.tar.gz |
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
-rw-r--r-- | compiler/coreSyn/CoreUnfold.hs | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/compiler/coreSyn/CoreUnfold.hs b/compiler/coreSyn/CoreUnfold.hs index a558dc4383..f9ca36f1a9 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 |