summaryrefslogtreecommitdiff
path: root/compiler/GHC/Core/Subst.hs
diff options
context:
space:
mode:
authorSimon Peyton Jones <simonpj@microsoft.com>2022-07-18 12:58:57 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2022-07-22 08:18:41 -0400
commit2c5991ccaf45cb7e68e54d59a27ee144a4499edb (patch)
treef938ee8464dad207108a131fa3bfbe45d3e94763 /compiler/GHC/Core/Subst.hs
parent9a3e1f316598f7d5072ed4f94437f759352580a5 (diff)
downloadhaskell-2c5991ccaf45cb7e68e54d59a27ee144a4499edb.tar.gz
Make the specialiser deal better with specialised methods
This patch fixes #21848, by being more careful to update unfoldings in the type-class specialiser. See the new Note [Update unfolding after specialisation] Now that we are being so much more careful about unfoldings, it turned out that I could dispense with se_interesting, and all its tricky corners. Hooray. This fixes #21368.
Diffstat (limited to 'compiler/GHC/Core/Subst.hs')
-rw-r--r--compiler/GHC/Core/Subst.hs6
1 files changed, 5 insertions, 1 deletions
diff --git a/compiler/GHC/Core/Subst.hs b/compiler/GHC/Core/Subst.hs
index 9f4f20591e..12a3e79559 100644
--- a/compiler/GHC/Core/Subst.hs
+++ b/compiler/GHC/Core/Subst.hs
@@ -494,12 +494,14 @@ It also unconditionally zaps the OccInfo.
-- | Very similar to 'substBndr', but it always allocates a new 'Unique' for
-- each variable in its output. It substitutes the IdInfo though.
+-- Discards non-Stable unfoldings
cloneIdBndr :: Subst -> UniqSupply -> Id -> (Subst, Id)
cloneIdBndr subst us old_id
= clone_id subst subst (old_id, uniqFromSupply us)
-- | Applies 'cloneIdBndr' to a number of 'Id's, accumulating a final
-- substitution from left to right
+-- Discards non-Stable unfoldings
cloneIdBndrs :: Subst -> UniqSupply -> [Id] -> (Subst, [Id])
cloneIdBndrs subst us ids
= mapAccumL (clone_id subst) subst (ids `zip` uniqsFromSupply us)
@@ -525,6 +527,7 @@ cloneRecIdBndrs subst us ids
-- Just like substIdBndr, except that it always makes a new unique
-- It is given the unique to use
+-- Discards non-Stable unfoldings
clone_id :: Subst -- Substitution for the IdInfo
-> Subst -> (Id, Unique) -- Substitution and Id to transform
-> (Subst, Id) -- Transformed pair
@@ -602,6 +605,7 @@ substIdType subst@(Subst _ _ tv_env cv_env) id
------------------
-- | Substitute into some 'IdInfo' with regard to the supplied new 'Id'.
+-- Discards unfoldings, unless they are Stable
substIdInfo :: Subst -> Id -> IdInfo -> Maybe IdInfo
substIdInfo subst new_id info
| nothing_to_do = Nothing
@@ -632,7 +636,7 @@ substUnfolding subst df@(DFunUnfolding { df_bndrs = bndrs, df_args = args })
args' = map (substExpr subst') args
substUnfolding subst unf@(CoreUnfolding { uf_tmpl = tmpl, uf_src = src })
- -- Retain an InlineRule!
+ -- Retain stable unfoldings
| not (isStableSource src) -- Zap an unstable unfolding, to save substitution work
= NoUnfolding
| otherwise -- But keep a stable one!