diff options
author | Simon Peyton Jones <simonpj@microsoft.com> | 2021-05-22 23:46:43 +0100 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-06-18 12:27:33 -0400 |
commit | 3b783496aa6b74cdca767347916de963b34ca718 (patch) | |
tree | 6655fb0d45d73cf4f04ab70d51bb4bf5f318604c /compiler/GHC/Core.hs | |
parent | a0622459f1d9a7068e81b8a707ffc63e153444f8 (diff) | |
download | haskell-3b783496aa6b74cdca767347916de963b34ca718.tar.gz |
Enhance cast worker/wrapper for INLINABLE
In #19890 we realised that cast worker/wrapper didn't really work
properly for functions with an INLINABLE pragma, and hence a stable
unfolding. This patch fixes the problem.
Instead of disabling cast w/w when there is a stable unfolding (as
we did before), we now tranfer the stable unfolding to the worker.
It turned out that it was easier to do that if I moved the cast
w/w stuff from prepareBinding to completeBind.
No chnages at all in nofib results:
--------------------------------------------------------------------------------
Program Size Allocs Runtime Elapsed TotalMem
--------------------------------------------------------------------------------
Min -0.0% 0.0% -63.8% -78.2% 0.0%
Max -0.0% 0.0% +11.8% +11.7% 0.0%
Geometric Mean -0.0% -0.0% -26.6% -33.4% -0.0%
Small decreases in compile-time allocation for two tests (below)
of around 2%.
T12545 increased in compile-time alloc by 4%, but it's not
reproducible on my machine, and is a known-wobbly test.
Metric Increase:
T12545
Metric Decrease:
T18698a
T18698b
Diffstat (limited to 'compiler/GHC/Core.hs')
-rw-r--r-- | compiler/GHC/Core.hs | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/compiler/GHC/Core.hs b/compiler/GHC/Core.hs index 05df4a7a7d..a17604300f 100644 --- a/compiler/GHC/Core.hs +++ b/compiler/GHC/Core.hs @@ -64,8 +64,8 @@ module GHC.Core ( maybeUnfoldingTemplate, otherCons, isValueUnfolding, isEvaldUnfolding, isCheapUnfolding, isExpandableUnfolding, isConLikeUnfolding, isCompulsoryUnfolding, - isStableUnfolding, hasCoreUnfolding, hasSomeUnfolding, - isBootUnfolding, + isStableUnfolding, isInlineUnfolding, isBootUnfolding, + hasCoreUnfolding, hasSomeUnfolding, canUnfold, neverUnfoldGuidance, isStableSource, -- * Annotated expression data types @@ -1462,6 +1462,22 @@ isStableUnfolding (CoreUnfolding { uf_src = src }) = isStableSource src isStableUnfolding (DFunUnfolding {}) = True isStableUnfolding _ = False +isInlineUnfolding :: Unfolding -> Bool +-- ^ True of a /stable/ unfolding that is +-- (a) always inlined; that is, with an `UnfWhen` guidance, or +-- (b) a DFunUnfolding which never needs to be inlined +isInlineUnfolding (CoreUnfolding { uf_src = src, uf_guidance = guidance }) + | isStableSource src + , UnfWhen {} <- guidance + = True + +isInlineUnfolding (DFunUnfolding {}) + = True + +-- Default case +isInlineUnfolding _ = False + + -- | Only returns False if there is no unfolding information available at all hasSomeUnfolding :: Unfolding -> Bool hasSomeUnfolding NoUnfolding = False |