summaryrefslogtreecommitdiff
path: root/compiler/simplCore/SimplMonad.hs
diff options
context:
space:
mode:
authorEdward Z. Yang <ezyang@cs.stanford.edu>2015-06-03 14:33:05 -0700
committerEdward Z. Yang <ezyang@cs.stanford.edu>2015-06-20 15:13:42 -0700
commit0cb1f5cf26fae946ca745abc5e302e62a8f66feb (patch)
tree07744de6d51cea9bde926d3ea88c1fda2b138974 /compiler/simplCore/SimplMonad.hs
parent85d539754ac07286ef5fed714ad42451bd5a1d28 (diff)
downloadhaskell-0cb1f5cf26fae946ca745abc5e302e62a8f66feb.tar.gz
Filter orphan rules based on imports, fixes #10294 and #10420.
Summary: If we have an orphan rule in our database, don't apply it unless the defining module is transitively imported by the module we are processing. We do this by defining a new RuleEnv data type which includes both the RuleBase as well as the set of visible orphan modules, and threading this through the relevant environments (CoreReader, RuleCheckEnv and ScEnv). This is analogous to the instances fix we applied in #2182 4c834fdddf4d44d12039da4d6a2c63a660975b95, but done for RULES. An important knock-on effect is that we can remove some buggy code in LoadInterface which tried to avoid loading interfaces that were loaded by plugins (which sometimes caused instances and rules to NEVER become visible). One note about tests: I renamed the old plugins07 test to T10420 and replaced plugins07 with a test to ensure that a plugin import did not cause new rules to be loaded in. Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu> Test Plan: validate Reviewers: simonpj, austin, goldfire Subscribers: bgamari, thomie Differential Revision: https://phabricator.haskell.org/D950 GHC Trac Issues: #10420
Diffstat (limited to 'compiler/simplCore/SimplMonad.hs')
-rw-r--r--compiler/simplCore/SimplMonad.hs8
1 files changed, 4 insertions, 4 deletions
diff --git a/compiler/simplCore/SimplMonad.hs b/compiler/simplCore/SimplMonad.hs
index bd60a7942c..c8503a7f3f 100644
--- a/compiler/simplCore/SimplMonad.hs
+++ b/compiler/simplCore/SimplMonad.hs
@@ -22,7 +22,7 @@ module SimplMonad (
import Id ( Id, mkSysLocal )
import Type ( Type )
import FamInstEnv ( FamInstEnv )
-import CoreSyn ( RuleBase )
+import CoreSyn ( RuleEnv(..) )
import UniqSupply
import DynFlags
import CoreMonad
@@ -55,10 +55,10 @@ newtype SimplM result
data SimplTopEnv
= STE { st_flags :: DynFlags
, st_max_ticks :: IntWithInf -- Max #ticks in this simplifier run
- , st_rules :: RuleBase
+ , st_rules :: RuleEnv
, st_fams :: (FamInstEnv, FamInstEnv) }
-initSmpl :: DynFlags -> RuleBase -> (FamInstEnv, FamInstEnv)
+initSmpl :: DynFlags -> RuleEnv -> (FamInstEnv, FamInstEnv)
-> UniqSupply -- No init count; set to 0
-> Int -- Size of the bindings, used to limit
-- the number of ticks we allow
@@ -168,7 +168,7 @@ instance MonadIO SimplM where
x <- m
return (x, us, sc)
-getSimplRules :: SimplM RuleBase
+getSimplRules :: SimplM RuleEnv
getSimplRules = SM (\st_env us sc -> return (st_rules st_env, us, sc))
getFamEnvs :: SimplM (FamInstEnv, FamInstEnv)