Hannes Siebenhandl pushed to branch wip/fendor/one-shot-no-eps at Glasgow Haskell Compiler / GHC

Commits:

3 changed files:

Changes:

  • compiler/GHC/Core/Opt/Pipeline.hs
    ... ... @@ -102,7 +102,7 @@ core2core hsc_env guts@(ModGuts { mg_module = mod
    102 102
         logger         = hsc_logger hsc_env
    
    103 103
         unit_env       = hsc_unit_env hsc_env
    
    104 104
         extra_vars     = interactiveInScope (hsc_IC hsc_env)
    
    105
    -    home_pkg_rules = hugRulesBelow (hsc_mod_graph hsc_env) (hsc_HUG hsc_env) (moduleUnitId mod)
    
    105
    +    home_pkg_rules = hugRulesBelow (hsc_unit_env hsc_env) (moduleUnitId mod)
    
    106 106
                           (GWIB { gwib_mod = moduleName mod, gwib_isBoot = NotBoot })
    
    107 107
         name_ppr_ctx   = mkNamePprCtx ptc unit_env rdr_env
    
    108 108
         ptc            = initPromotionTickContext dflags
    

  • compiler/GHC/Driver/Env.hs
    ... ... @@ -260,26 +260,26 @@ hscUIC hsc_env = ue_uic (hsc_unit_env hsc_env)
    260 260
     
    
    261 261
     -- | Find all rules in modules that are in the transitive closure of the given
    
    262 262
     -- module.
    
    263
    -hugRulesBelow :: ModuleGraph -> HomeUnitGraph -> UnitId -> ModuleNameWithIsBoot -> IO RuleBase
    
    264
    -hugRulesBelow mg hug uid mn = foldr (flip extendRuleBaseList) emptyRuleBase <$>
    
    265
    -  hugSomeThingsBelowUs (md_rules . hm_details) False mg hug uid mn
    
    263
    +hugRulesBelow :: UnitEnv -> UnitId -> ModuleNameWithIsBoot -> IO RuleBase
    
    264
    +hugRulesBelow unit_env uid mn = foldr (flip extendRuleBaseList) emptyRuleBase <$>
    
    265
    +  hugSomeThingsBelowUs (md_rules . hm_details) False unit_env uid mn
    
    266 266
     
    
    267 267
     -- | Get annotations from all modules "below" this one (in the dependency
    
    268 268
     -- sense) within the home units. If the module is @Nothing@, returns /all/
    
    269 269
     -- annotations in the home units.
    
    270
    -hugAnnsBelow :: ModuleGraph -> HomeUnitGraph -> UnitId -> ModuleNameWithIsBoot -> IO AnnEnv
    
    271
    -hugAnnsBelow mg hug uid mn = foldr (flip extendAnnEnvList) emptyAnnEnv <$>
    
    272
    -  hugSomeThingsBelowUs (md_anns . hm_details) False mg hug uid mn
    
    270
    +hugAnnsBelow :: UnitEnv -> UnitId -> ModuleNameWithIsBoot -> IO AnnEnv
    
    271
    +hugAnnsBelow unit_env uid mn = foldr (flip extendAnnEnvList) emptyAnnEnv <$>
    
    272
    +  hugSomeThingsBelowUs (md_anns . hm_details) False unit_env uid mn
    
    273 273
     
    
    274 274
     -- | Find all COMPLETE pragmas in modules that are in the transitive closure of the
    
    275 275
     -- given module.
    
    276
    -hugCompleteSigsBelow :: ModuleGraph -> HomeUnitGraph -> UnitId -> ModuleNameWithIsBoot -> IO CompleteMatches
    
    277
    -hugCompleteSigsBelow mg hug uid mn = foldr (++) [] <$>
    
    278
    -  hugSomeThingsBelowUs (md_complete_matches . hm_details) False mg hug uid mn
    
    276
    +hugCompleteSigsBelow :: UnitEnv -> UnitId -> ModuleNameWithIsBoot -> IO CompleteMatches
    
    277
    +hugCompleteSigsBelow unit_env uid mn = foldr (++) [] <$>
    
    278
    +  hugSomeThingsBelowUs (md_complete_matches . hm_details) False unit_env uid mn
    
    279 279
     
    
    280 280
     -- | Find instances visible from the given set of imports
    
    281
    -hugInstancesBelow :: ModuleGraph -> HomeUnitGraph -> UnitId -> ModuleNameWithIsBoot -> IO (InstEnv, [FamInst])
    
    282
    -hugInstancesBelow mg hug uid mnwib = do
    
    281
    +hugInstancesBelow :: UnitEnv -> UnitId -> ModuleNameWithIsBoot -> IO (InstEnv, [FamInst])
    
    282
    +hugInstancesBelow unit_env uid mnwib = do
    
    283 283
      let mn = mkModule uid (gwib_mod mnwib)
    
    284 284
      (insts, famInsts) <-
    
    285 285
          unzip . concat <$>
    
    ... ... @@ -290,8 +290,7 @@ hugInstancesBelow mg hug uid mnwib = do
    290 290
                                            then []
    
    291 291
                                            else [(md_insts details, md_fam_insts details)])
    
    292 292
                               True -- Include -hi-boot
    
    293
    -                          mg
    
    294
    -                          hug
    
    293
    +                          unit_env
    
    295 294
                               uid
    
    296 295
                               mnwib
    
    297 296
      return (foldl' unionInstEnv emptyInstEnv insts, concat famInsts)
    
    ... ... @@ -299,18 +298,19 @@ hugInstancesBelow mg hug uid mnwib = do
    299 298
     -- | Get things from modules in the transitive closure of the given module.
    
    300 299
     --
    
    301 300
     -- Note: Don't expose this function. This is a footgun if exposed!
    
    302
    -hugSomeThingsBelowUs :: (HomeModInfo -> [a]) -> Bool -> ModuleGraph -> HomeUnitGraph -> UnitId -> ModuleNameWithIsBoot -> IO [[a]]
    
    301
    +hugSomeThingsBelowUs :: (HomeModInfo -> [a]) -> Bool -> UnitEnv -> UnitId -> ModuleNameWithIsBoot -> IO [[a]]
    
    303 302
     -- An explicit check to see if we are in one-shot mode to avoid poking the ModuleGraph thunk
    
    304
    --- These things are currently stored in the EPS for home packages. (See #25795 for
    
    303
    +-- These things are currently stored in the HPT's loader state for home packages. (See #25795 for
    
    305 304
     -- progress in removing these kind of checks; and making these functions of
    
    306 305
     -- `UnitEnv` rather than `HscEnv`)
    
    307 306
     -- See Note [The ModuleGraph]
    
    308
    -hugSomeThingsBelowUs extract include_hi_boot mg hug uid mn =
    
    309
    -  -- If the first hpt is a one-shot table, we don't recurse into it.
    
    310
    -  -- TODO @fendor: I guess that's nonsense to a certain degree
    
    311
    -  if HPT.isOneShotMode $ homeUnitEnv_hpt $ unitEnv_lookup uid hug
    
    312
    -    then pure []
    
    313
    -    else
    
    307
    +hugSomeThingsBelowUs extract include_hi_boot unit_env uid mn
    
    308
    +  | HPT.isOneShotMode (ue_hpt unit_env)
    
    309
    +  = pure []
    
    310
    +  | otherwise
    
    311
    +  = let hug = ue_home_unit_graph unit_env
    
    312
    +        mg  = ue_module_graph unit_env
    
    313
    +    in
    
    314 314
         sequence
    
    315 315
         [ things
    
    316 316
           -- "Finding each non-hi-boot module below me" maybe could be cached (well,
    
    ... ... @@ -350,7 +350,7 @@ prepareAnnotations hsc_env mb_guts = do
    350 350
             -- entries regardless of dependency ordering.
    
    351 351
             get_mod mg = (moduleUnitId (mg_module mg), GWIB (moduleName (mg_module mg)) NotBoot)
    
    352 352
         home_pkg_anns  <- fromMaybe (hugAllAnns (hsc_unit_env hsc_env))
    
    353
    -                      $ uncurry (hugAnnsBelow (hsc_mod_graph hsc_env) (hsc_HUG hsc_env))
    
    353
    +                      $ uncurry (hugAnnsBelow (hsc_unit_env hsc_env))
    
    354 354
                           . get_mod <$> mb_guts
    
    355 355
         more_home_pkg_anns <- HomePackageTable.hptLoadedAnnEnv $ hsc_HPT hsc_env
    
    356 356
         let
    

  • compiler/GHC/Tc/Module.hs
    ... ... @@ -501,13 +501,13 @@ tcRnImports hsc_env import_decls
    501 501
               -- modules batch (@--make@) compiled before this one, but
    
    502 502
               -- which are not below this one.
    
    503 503
             ; (home_insts, home_fam_insts) <- liftIO $
    
    504
    -              hugInstancesBelow (hsc_mod_graph hsc_env) (hsc_HUG hsc_env) unitId mnwib
    
    504
    +              hugInstancesBelow (hsc_unit_env hsc_env) unitId mnwib
    
    505 505
     
    
    506 506
               -- We use 'unsafeInterleaveIO' to avoid redundant memory allocations
    
    507 507
               -- See Note [Lazily loading COMPLETE pragmas] from GHC.HsToCore.Monad
    
    508 508
               -- and see https://gitlab.haskell.org/ghc/ghc/-/merge_requests/14274#note_620545
    
    509 509
             ; completeSigsBelow <- liftIO $ unsafeInterleaveIO $
    
    510
    -              hugCompleteSigsBelow (hsc_mod_graph hsc_env) (hsc_HUG hsc_env) unitId mnwib
    
    510
    +              hugCompleteSigsBelow (hsc_unit_env hsc_env) unitId mnwib
    
    511 511
     
    
    512 512
               -- Record boot-file info in the HPT, so that it's
    
    513 513
               -- visible to loadHiBootInterface in tcRnSrcDecls,