Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC

Commits:

2 changed files:

Changes:

  • compiler/GHC/HsToCore/Usage.hs
    ... ... @@ -226,11 +226,14 @@ mk_mod_usage_info uc home_unit home_unit_ids this_mod direct_imports imp_decls u
    226 226
       where
    
    227 227
         safe_implicit_imps_req = uc_safe_implicit_imps_req uc
    
    228 228
     
    
    229
    -    used_mods    = moduleEnvKeys ent_map
    
    230
    -    dir_imp_mods = Map.keys direct_imports
    
    231
    -    all_mods     = used_mods ++ filter (`notElem` used_mods) dir_imp_mods
    
    232
    -    usage_mods   = sortBy stableModuleCmp all_mods
    
    233
    -                        -- canonical order is imported, to avoid interface-file
    
    229
    +    used_mods     = nonDetModuleEnvKeys ent_map
    
    230
    +                      -- nonDetModuleEnvKeys is OK here, because the
    
    231
    +                      -- resulting usage_mods are sorted explicitly.
    
    232
    +    is_used_mod m = m `elemModuleEnv` ent_map
    
    233
    +    dir_imp_mods  = Map.keys direct_imports
    
    234
    +    all_mods      = filter (not . is_used_mod) dir_imp_mods ++ used_mods
    
    235
    +    usage_mods    = sortBy stableModuleCmp all_mods
    
    236
    +                        -- canonical order is important, to avoid interface-file
    
    234 237
                             -- wobblage.
    
    235 238
     
    
    236 239
         -- ent_map groups together all the things imported and used
    

  • compiler/GHC/Unit/Module/Env.hs
    ... ... @@ -8,7 +8,7 @@ module GHC.Unit.Module.Env
    8 8
        , lookupWithDefaultModuleEnv, mapModuleEnv, mkModuleEnv, emptyModuleEnv
    
    9 9
        , alterModuleEnv
    
    10 10
        , partitionModuleEnv
    
    11
    -   , moduleEnvKeys, moduleEnvElts, moduleEnvToList
    
    11
    +   , moduleEnvKeys, nonDetModuleEnvKeys, moduleEnvElts, moduleEnvToList
    
    12 12
        , unitModuleEnv, isEmptyModuleEnv, sizeModuleEnv
    
    13 13
        , extendModuleEnvWith, filterModuleEnv, mapMaybeModuleEnv
    
    14 14
     
    
    ... ... @@ -157,8 +157,15 @@ mkModuleEnv xs = ModuleEnv (Map.fromList [(NDModule k, v) | (k,v) <- xs])
    157 157
     emptyModuleEnv :: ModuleEnv a
    
    158 158
     emptyModuleEnv = ModuleEnv Map.empty
    
    159 159
     
    
    160
    +-- | See Note [ModuleEnv performance and determinism].
    
    161
    +--
    
    162
    +-- If you use this, please provide a justification why it doesn't introduce
    
    163
    +-- nondeterminism.
    
    164
    +nonDetModuleEnvKeys :: ModuleEnv a -> [Module]
    
    165
    +nonDetModuleEnvKeys (ModuleEnv e) = map unNDModule $ Map.keys e
    
    166
    +
    
    160 167
     moduleEnvKeys :: ModuleEnv a -> [Module]
    
    161
    -moduleEnvKeys (ModuleEnv e) = sort $ map unNDModule $ Map.keys e
    
    168
    +moduleEnvKeys = sort . nonDetModuleEnvKeys
    
    162 169
       -- See Note [ModuleEnv performance and determinism]
    
    163 170
     
    
    164 171
     moduleEnvElts :: ModuleEnv a -> [a]