summaryrefslogtreecommitdiff
path: root/compiler/GHC/Core.hs
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/GHC/Core.hs')
-rw-r--r--compiler/GHC/Core.hs20
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