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/Types | |
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/Types')
-rw-r--r-- | compiler/GHC/Types/Id.hs | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/compiler/GHC/Types/Id.hs b/compiler/GHC/Types/Id.hs index 55ff3f9335..7c78c1928b 100644 --- a/compiler/GHC/Types/Id.hs +++ b/compiler/GHC/Types/Id.hs @@ -94,7 +94,7 @@ module GHC.Types.Id ( -- ** Reading 'IdInfo' fields idArity, idCallArity, idFunRepArity, - idUnfolding, realIdUnfolding, + idUnfolding, realIdUnfolding, hasInlineUnfolding, idSpecialisation, idCoreRules, idHasRules, idCafInfo, idLFInfo_maybe, idOneShotInfo, idStateHackOneShotInfo, @@ -124,7 +124,8 @@ module GHC.Types.Id ( import GHC.Prelude import GHC.Core ( CoreRule, isStableUnfolding, evaldUnfolding, - isCompulsoryUnfolding, Unfolding( NoUnfolding ) ) + isCompulsoryUnfolding, isInlineUnfolding, + Unfolding( NoUnfolding ) ) import GHC.Types.Id.Info import GHC.Types.Basic @@ -721,6 +722,12 @@ idUnfolding id where info = idInfo id +hasInlineUnfolding :: Id -> Bool +-- ^ True of a non-loop-breaker Id that has a /stable/ unfolding that is +-- (a) always inlined; that is, with an `UnfWhen` guidance, or +-- (b) a DFunUnfolding which never needs to be inlined +hasInlineUnfolding id = isInlineUnfolding (idUnfolding id) + realIdUnfolding :: Id -> Unfolding -- Expose the unfolding if there is one, including for loop breakers realIdUnfolding id = unfoldingInfo (idInfo id) |