Wolfgang Jeltsch pushed to branch wip/jeltsch/improve-closure-property-check at Glasgow Haskell Compiler / GHC

Commits:

2 changed files:

Changes:

  • compiler/GHC/Driver/Downsweep.hs
    ... ... @@ -55,7 +55,6 @@ import Language.Haskell.Syntax.ImpExp
    55 55
     import GHC.Types.UnresolvedImport
    
    56 56
     
    
    57 57
     import GHC.Data.FastString
    
    58
    -import GHC.Data.ShortText (ShortText)
    
    59 58
     import GHC.Data.Maybe      ( expectJust )
    
    60 59
     import qualified GHC.Data.Maybe as M
    
    61 60
     import GHC.Data.OsPath     ( OsPath, unsafeEncodeUtf )
    
    ... ... @@ -93,6 +92,7 @@ import GHC.Unit.Module.Graph
    93 92
     import GHC.Unit.Module.Deps
    
    94 93
     import qualified GHC.Unit.Home.Graph as HUG
    
    95 94
     import GHC.Unit.Module.Stage
    
    95
    +import GHC.Unit.External.Index (GlobalUnitKey, mkGlobalUnitKey)
    
    96 96
     
    
    97 97
     import Data.Either ( partitionEithers, lefts )
    
    98 98
     import Data.Map (Map)
    
    ... ... @@ -961,7 +961,7 @@ checkHomeUnitsClosed unit_env
    961 961
           Set.empty
    
    962 962
         where
    
    963 963
     
    
    964
    -    collect :: [UnitState] -> State (Set ShortText) [(UnitId, UnitId)]
    
    964
    +    collect :: [UnitState] -> State (Set GlobalUnitKey) [(UnitId, UnitId)]
    
    965 965
         collect []
    
    966 966
           = pure []
    
    967 967
         collect (current_unit_state : remaining_unit_states)
    
    ... ... @@ -973,7 +973,7 @@ checkHomeUnitsClosed unit_env
    973 973
     
    
    974 974
           collect_for_home_unit :: UnitInfoMap
    
    975 975
                                 -> [UnitId]
    
    976
    -                            -> State (Set ShortText) [(UnitId, UnitId)]
    
    976
    +                            -> State (Set GlobalUnitKey) [(UnitId, UnitId)]
    
    977 977
           collect_for_home_unit _ []
    
    978 978
             = return []
    
    979 979
           collect_for_home_unit unit_info_map (current_unit : remaining_units) = do
    
    ... ... @@ -988,14 +988,14 @@ checkHomeUnitsClosed unit_env
    988 988
                 unit_not_found_msg :: String
    
    989 989
                 unit_not_found_msg = "Unit not found during closure property check"
    
    990 990
     
    
    991
    -          abi_hash :: ShortText
    
    992
    -          abi_hash = unitAbiHash unit_info
    
    991
    +          global_unit_key :: GlobalUnitKey
    
    992
    +          global_unit_key = mkGlobalUnitKey current_unit (unitAbiHash unit_info)
    
    993 993
     
    
    994
    -        has_been_processed <- gets (Set.member abi_hash)
    
    994
    +        has_been_processed <- gets (Set.member global_unit_key)
    
    995 995
             if has_been_processed
    
    996 996
               then collect_for_home_unit unit_info_map remaining_units
    
    997 997
               else do
    
    998
    -            modify (Set.insert abi_hash)
    
    998
    +            modify (Set.insert global_unit_key)
    
    999 999
                 let
    
    1000 1000
     
    
    1001 1001
                   needed_units :: [UnitId]
    

  • compiler/GHC/Unit/External/Index.hs
    ... ... @@ -308,6 +308,7 @@ data GlobalUnitKey =
    308 308
       GlobalUnitKey
    
    309 309
         !UnitId -- ^ Unit Id of the 'UnitInfo'
    
    310 310
         !UnitAbiHash -- ^ ABI hash of the 'UnitInfo'
    
    311
    +  deriving (Eq, Ord)
    
    311 312
     
    
    312 313
     globalUnitKeyFromUnitInfo :: UnitInfo -> GlobalUnitKey
    
    313 314
     globalUnitKeyFromUnitInfo ui = mkGlobalUnitKey (unitId ui) (unitAbiHash ui)