summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Pickering <matthewtpickering@gmail.com>2021-05-13 11:13:45 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-05-19 23:35:24 -0400
commit327256178e8378c9d5cfd9b1990788d7eca2294f (patch)
treec8e5724db0f31b5d3f1b1bbd87092d5c2caca333
parent3c04e7ac90eed14fc8224bc1e1d3a0b27b37bf1f (diff)
downloadhaskell-327256178e8378c9d5cfd9b1990788d7eca2294f.tar.gz
Tidy: Ignore rules (more) when -fomit-interface-pragmas is on
Before this commit, the RHS of a rule would expose additional definitions, despite the fact that the rule wouldn't get exposed so it wouldn't be possible to ever use these definitions. The net-result is slightly less recompilation when specialisation introduces rules. Related to #19836
-rw-r--r--compiler/GHC/Iface/Tidy.hs9
1 files changed, 8 insertions, 1 deletions
diff --git a/compiler/GHC/Iface/Tidy.hs b/compiler/GHC/Iface/Tidy.hs
index 96da0ce2c0..b1e7aa1dc6 100644
--- a/compiler/GHC/Iface/Tidy.hs
+++ b/compiler/GHC/Iface/Tidy.hs
@@ -647,7 +647,14 @@ chooseExternalIds hsc_env mod omit_prags expose_all binds implicit_binds imp_id_
-- See Note [Which rules to expose]
is_external id = isExportedId id || id `elemVarSet` rule_rhs_vars
- rule_rhs_vars = mapUnionVarSet ruleRhsFreeVars imp_id_rules
+ rule_rhs_vars
+ -- No rules are exposed when omit_prags is enabled see #19836
+ -- imp_id_rules are the RULES in /this/ module for /imported/ Ids
+ -- If omit_prags is True, these rules won't be put in the interface file.
+ -- But if omit_prags is False, so imp_id_rules are in the interface file for
+ -- this module, then the local-defined Ids they use must be made external.
+ | omit_prags = emptyVarSet
+ | otherwise = mapUnionVarSet ruleRhsFreeVars imp_id_rules
binders = map fst $ flattenBinds binds
implicit_binders = bindersOfBinds implicit_binds