[commit: ghc] ghc-8.2: CoreTidy: Don't seq unfoldings (febfbc5)
git at git.haskell.org
git at git.haskell.org
Fri May 5 15:54:00 UTC 2017
Repository : ssh://git@git.haskell.org/ghc
On branch : ghc-8.2
Link : http://ghc.haskell.org/trac/ghc/changeset/febfbc5ad40915e5d6841d41e79f0ffed1370d61/ghc
>---------------------------------------------------------------
commit febfbc5ad40915e5d6841d41e79f0ffed1370d61
Author: Ben Gamari <ben at smart-cactus.org>
Date: Tue May 2 11:36:47 2017 -0400
CoreTidy: Don't seq unfoldings
Previously we would force uf_is_value and friends to ensure that we didn't
retain a reference to the pre-tidying template, resulting in a space leak.
Instead, we now just reinitialize these fields (despite the fact that they
should not have changed). This may result in a bit more computation, but most of
the time we won't ever evaluate them anyways, so the damage shouldn't be so bad.
See #13564.
(cherry picked from commit b3da6a6c3546562d5c5e83b8af5d3fd04c07e0c1)
>---------------------------------------------------------------
febfbc5ad40915e5d6841d41e79f0ffed1370d61
compiler/coreSyn/CoreTidy.hs | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
diff --git a/compiler/coreSyn/CoreTidy.hs b/compiler/coreSyn/CoreTidy.hs
index 89ce692..3578b0b 100644
--- a/compiler/coreSyn/CoreTidy.hs
+++ b/compiler/coreSyn/CoreTidy.hs
@@ -15,7 +15,7 @@ module CoreTidy (
#include "HsVersions.h"
import CoreSyn
-import CoreSeq ( seqUnfolding )
+import CoreUnfold ( mkCoreUnfolding )
import CoreArity
import Id
import IdInfo
@@ -221,17 +221,21 @@ tidyUnfolding tidy_env df@(DFunUnfolding { df_bndrs = bndrs, df_args = args }) _
(tidy_env', bndrs') = tidyBndrs tidy_env bndrs
tidyUnfolding tidy_env
- unf@(CoreUnfolding { uf_tmpl = unf_rhs, uf_src = src })
+ (CoreUnfolding { uf_tmpl = unf_rhs, uf_is_top = top_lvl
+ , uf_src = src, uf_guidance = guidance })
unf_from_rhs
| isStableSource src
- = seqIt $ unf { uf_tmpl = tidyExpr tidy_env unf_rhs } -- Preserves OccInfo
- -- This seqIt avoids a space leak: otherwise the uf_is_value,
- -- uf_is_conlike, ... fields may retain a reference to the
- -- pre-tidied expression forever (ToIface doesn't look at them)
+ = mkCoreUnfolding src top_lvl (tidyExpr tidy_env unf_rhs) guidance
+ -- Preserves OccInfo
+
+ -- Note that uf_is_value and friends may be a thunk containing a reference
+ -- to the old template. Consequently it is important that we rebuild them,
+ -- despite the fact that they won't change, to avoid a space leak (since,
+ -- e.g., ToIface doesn't look at them; see #13564). This is the same
+ -- approach we use in Simplify.simplUnfolding and TcIface.tcUnfolding.
| otherwise
= unf_from_rhs
- where seqIt unf = seqUnfolding unf `seq` unf
tidyUnfolding _ unf _ = unf -- NoUnfolding or OtherCon
{-
More information about the ghc-commits
mailing list