Commit d753ea2a authored by niteria's avatar niteria
Browse files

Use UniqDSet for finding free names in the Linker

This is not necessary for determinism, but it's a choice
between making this deterministic and using `nonDetEltsUFM`
and a comment explaining that it doesn't matter.

Test Plan: ./validate

Reviewers: austin, hvr, bgamari, simonmar

Reviewed By: simonmar

Subscribers: thomie

Differential Revision: https://phabricator.haskell.org/D2295

GHC Trac Issues: #4012
parent dad39ff0
......@@ -34,6 +34,7 @@ import Outputable
import Platform
import Util
import Unique
import UniqDSet
-- From iserv
import SizedSeq
......@@ -65,14 +66,14 @@ import qualified Data.Map as Map
-- | Finds external references. Remember to remove the names
-- defined by this group of BCOs themselves
bcoFreeNames :: UnlinkedBCO -> NameSet
bcoFreeNames :: UnlinkedBCO -> UniqDSet Name
bcoFreeNames bco
= bco_refs bco `minusNameSet` mkNameSet [unlinkedBCOName bco]
= bco_refs bco `uniqDSetMinusUniqSet` mkNameSet [unlinkedBCOName bco]
where
bco_refs (UnlinkedBCO _ _ _ _ nonptrs ptrs)
= unionNameSets (
mkNameSet [ n | BCOPtrName n <- ssElts ptrs ] :
mkNameSet [ n | BCONPtrItbl n <- ssElts nonptrs ] :
= unionManyUniqDSets (
mkUniqDSet [ n | BCOPtrName n <- ssElts ptrs ] :
mkUniqDSet [ n | BCONPtrItbl n <- ssElts nonptrs ] :
map bco_refs [ bco | BCOPtrBCO bco <- ssElts ptrs ]
)
......
......@@ -37,7 +37,6 @@ import Finder
import HscTypes
import Name
import NameEnv
import NameSet
import UniqFM
import Module
import ListSetOps
......@@ -50,6 +49,7 @@ import ErrUtils
import SrcLoc
import qualified Maybes
import UniqSet
import UniqDSet
import FastString
import Platform
import SysTools
......@@ -504,7 +504,7 @@ linkExpr hsc_env span root_ul_bco
; return (pls, fhv)
}}}
where
free_names = nameSetElems (bcoFreeNames root_ul_bco)
free_names = uniqDSetToList (bcoFreeNames root_ul_bco)
needed_mods :: [Module]
needed_mods = [ nameModule n | n <- free_names,
......@@ -730,7 +730,8 @@ linkDecls hsc_env span cbc@CompiledByteCode{..} = do
, itbl_env = ie }
return (pls2, ())
where
free_names = concatMap (nameSetElems . bcoFreeNames) bc_bcos
free_names = uniqDSetToList $
foldr (unionUniqDSets . bcoFreeNames) emptyUniqDSet bc_bcos
needed_mods :: [Module]
needed_mods = [ nameModule n | n <- free_names,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment