summaryrefslogtreecommitdiff
path: root/compiler/GHC/Driver/Main.hs
diff options
context:
space:
mode:
authorZubin Duggal <zubin.duggal@gmail.com>2022-02-09 17:01:38 +0530
committerMarge Bot <ben+marge-bot@smart-cactus.org>2022-02-20 13:56:15 -0500
commit4b04f7e175a01b30e098af63dfabe6ea068e9b0b (patch)
tree559e4dc5ba03f5ac8fc8917dcccef9f7c71e6507 /compiler/GHC/Driver/Main.hs
parent67dd5724297094af93be1887ef000845722c6f2b (diff)
downloadhaskell-4b04f7e175a01b30e098af63dfabe6ea068e9b0b.tar.gz
Track object file dependencies for TH accurately (#20604)
`hscCompileCoreExprHook` is changed to return a list of `Module`s required by a splice. These modules are accumulated in the TcGblEnv (tcg_th_needed_mods). Dependencies on the object files of these modules are recording in the interface. The data structures in `LoaderState` are replaced with more efficient versions to keep track of all the information required. The MultiLayerModulesTH_Make allocations increase slightly but runtime is faster. Fixes #20604 ------------------------- Metric Increase: MultiLayerModulesTH_Make -------------------------
Diffstat (limited to 'compiler/GHC/Driver/Main.hs')
-rw-r--r--compiler/GHC/Driver/Main.hs23
1 files changed, 12 insertions, 11 deletions
diff --git a/compiler/GHC/Driver/Main.hs b/compiler/GHC/Driver/Main.hs
index d0d29a83e7..fc9b96f2e7 100644
--- a/compiler/GHC/Driver/Main.hs
+++ b/compiler/GHC/Driver/Main.hs
@@ -1552,7 +1552,7 @@ hscSimplify' plugins ds_result = do
hsc_env <- getHscEnv
hsc_env_with_plugins <- if null plugins -- fast path
then return hsc_env
- else liftIO $ flip initializePlugins (Just $ mg_mnwib ds_result)
+ else liftIO $ initializePlugins
$ hscUpdateFlags (\dflags -> foldr addPluginModuleName dflags plugins)
hsc_env
{-# SCC "Core2Core" #-}
@@ -1955,7 +1955,7 @@ hscParsedStmt hsc_env stmt = runInteractiveHsc hsc_env $ do
-- for linking, else we try to link 'main' and can't find it.
-- Whereas the linker already knows to ignore 'interactive'
let src_span = srcLocSpan interactiveSrcLoc
- hval <- liftIO $ hscCompileCoreExpr hsc_env (src_span, Nothing) ds_expr
+ (hval,_,_) <- liftIO $ hscCompileCoreExpr hsc_env src_span ds_expr
return $ Just (ids, hval, fix_env)
@@ -2052,10 +2052,10 @@ hscParsedDecls hsc_env decls = runInteractiveHsc hsc_env $ do
stg_binds data_tycons mod_breaks
let src_span = srcLocSpan interactiveSrcLoc
- _ <- liftIO $ loadDecls interp hsc_env (src_span, Nothing) cbc
+ _ <- liftIO $ loadDecls interp hsc_env src_span cbc
{- Load static pointer table entries -}
- liftIO $ hscAddSptEntries hsc_env Nothing (cg_spt_entries tidy_cg)
+ liftIO $ hscAddSptEntries hsc_env (cg_spt_entries tidy_cg)
let tcs = filterOut isImplicitTyCon (mg_tcs simpl_mg)
patsyns = mg_patsyns simpl_mg
@@ -2080,12 +2080,13 @@ hscParsedDecls hsc_env decls = runInteractiveHsc hsc_env $ do
-- | Load the given static-pointer table entries into the interpreter.
-- See Note [Grand plan for static forms] in "GHC.Iface.Tidy.StaticPtrTable".
-hscAddSptEntries :: HscEnv -> Maybe ModuleNameWithIsBoot -> [SptEntry] -> IO ()
-hscAddSptEntries hsc_env mnwib entries = do
+hscAddSptEntries :: HscEnv -> [SptEntry] -> IO ()
+hscAddSptEntries hsc_env entries = do
let interp = hscInterp hsc_env
let add_spt_entry :: SptEntry -> IO ()
add_spt_entry (SptEntry i fpr) = do
- val <- loadName interp hsc_env mnwib (idName i)
+ -- These are only names from the current module
+ (val, _, _) <- loadName interp hsc_env (idName i)
addSptEntry interp fpr val
mapM_ add_spt_entry entries
@@ -2195,13 +2196,13 @@ hscParseThingWithLocation source linenumber parser str = do
%* *
%********************************************************************* -}
-hscCompileCoreExpr :: HscEnv -> (SrcSpan, Maybe ModuleNameWithIsBoot) -> CoreExpr -> IO ForeignHValue
+hscCompileCoreExpr :: HscEnv -> SrcSpan -> CoreExpr -> IO (ForeignHValue, [Linkable], PkgsLoaded)
hscCompileCoreExpr hsc_env loc expr =
case hscCompileCoreExprHook (hsc_hooks hsc_env) of
Nothing -> hscCompileCoreExpr' hsc_env loc expr
Just h -> h hsc_env loc expr
-hscCompileCoreExpr' :: HscEnv -> (SrcSpan, Maybe ModuleNameWithIsBoot) -> CoreExpr -> IO ForeignHValue
+hscCompileCoreExpr' :: HscEnv -> SrcSpan -> CoreExpr -> IO (ForeignHValue, [Linkable], PkgsLoaded)
hscCompileCoreExpr' hsc_env srcspan ds_expr
= do { {- Simplify it -}
-- Question: should we call SimpleOpt.simpleOptExpr here instead?
@@ -2240,10 +2241,10 @@ hscCompileCoreExpr' hsc_env srcspan ds_expr
[] Nothing
{- load it -}
- ; fv_hvs <- loadDecls (hscInterp hsc_env) hsc_env srcspan bcos
+ ; (fv_hvs, mods_needed, units_needed) <- loadDecls (hscInterp hsc_env) hsc_env srcspan bcos
{- Get the HValue for the root -}
; return (expectJust "hscCompileCoreExpr'"
- $ lookup (idName binding_id) fv_hvs) }
+ $ lookup (idName binding_id) fv_hvs, mods_needed, units_needed) }
{- **********************************************************************