summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSylvain Henry <sylvain@haskus.fr>2020-11-05 09:50:33 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-11-21 01:14:09 -0500
commit72f2257c792e6178933f12ee3401939da11584b6 (patch)
tree84b0f2ff63bbb6caa439fc5c33593796c399017e
parentecfd0278cb811c93853c176fe5df60222d1a8fb5 (diff)
downloadhaskell-72f2257c792e6178933f12ee3401939da11584b6.tar.gz
Don't initialize plugins in the Core2Core pipeline
Some plugins can be added via TH (cf addCorePlugin). Initialize them in the driver instead of in the Core2Core pipeline.
-rw-r--r--compiler/GHC/Core/Opt/Pipeline.hs8
-rw-r--r--compiler/GHC/Driver/Main.hs12
2 files changed, 11 insertions, 9 deletions
diff --git a/compiler/GHC/Core/Opt/Pipeline.hs b/compiler/GHC/Core/Opt/Pipeline.hs
index 918d1308dd..abddab3e45 100644
--- a/compiler/GHC/Core/Opt/Pipeline.hs
+++ b/compiler/GHC/Core/Opt/Pipeline.hs
@@ -60,7 +60,6 @@ import GHC.Unit.Module.Env
import GHC.Unit.Module.ModGuts
import GHC.Unit.Module.Deps
-import GHC.Runtime.Loader -- ( initializePlugins )
import GHC.Runtime.Context
import GHC.Types.SrcLoc
@@ -88,17 +87,14 @@ core2core hsc_env guts@(ModGuts { mg_module = mod
, mg_loc = loc
, mg_deps = deps
, mg_rdr_env = rdr_env })
- = do { -- make sure all plugins are loaded
-
- ; let builtin_passes = getCoreToDo dflags
+ = do { let builtin_passes = getCoreToDo dflags
orph_mods = mkModuleSet (mod : dep_orphs deps)
uniq_mask = 's'
;
; (guts2, stats) <- runCoreM hsc_env hpt_rule_base uniq_mask mod
orph_mods print_unqual loc $
do { hsc_env' <- getHscEnv
- ; hsc_env'' <- liftIO $ initializePlugins hsc_env'
- ; all_passes <- withPlugins hsc_env''
+ ; all_passes <- withPlugins hsc_env'
installCoreToDos
builtin_passes
; runCorePasses all_passes guts }
diff --git a/compiler/GHC/Driver/Main.hs b/compiler/GHC/Driver/Main.hs
index 7672dcb3e7..cd37ac4f3a 100644
--- a/compiler/GHC/Driver/Main.hs
+++ b/compiler/GHC/Driver/Main.hs
@@ -1426,16 +1426,22 @@ hscGetSafeMode tcg_env = do
-- Simplifiers
--------------------------------------------------------------
+-- | Run Core2Core simplifier. The list of String is a list of (Core) plugin
+-- module names added via TH (cf 'addCorePlugin').
hscSimplify :: HscEnv -> [String] -> ModGuts -> IO ModGuts
hscSimplify hsc_env plugins modguts =
runHsc hsc_env $ hscSimplify' plugins modguts
+-- | Run Core2Core simplifier. The list of String is a list of (Core) plugin
+-- module names added via TH (cf 'addCorePlugin').
hscSimplify' :: [String] -> ModGuts -> Hsc ModGuts
hscSimplify' plugins ds_result = do
hsc_env <- getHscEnv
- let hsc_env_with_plugins = hsc_env
- { hsc_dflags = foldr addPluginModuleName (hsc_dflags hsc_env) plugins
- }
+ hsc_env_with_plugins <- if null plugins -- fast path
+ then return hsc_env
+ else liftIO $ initializePlugins $ hsc_env
+ { hsc_dflags = foldr addPluginModuleName (hsc_dflags hsc_env) plugins
+ }
{-# SCC "Core2Core" #-}
liftIO $ core2core hsc_env_with_plugins ds_result