diff options
Diffstat (limited to 'compiler/utils')
-rw-r--r-- | compiler/utils/GraphColor.hs | 6 | ||||
-rw-r--r-- | compiler/utils/GraphOps.hs | 18 | ||||
-rw-r--r-- | compiler/utils/GraphPpr.hs | 9 | ||||
-rw-r--r-- | compiler/utils/UniqSet.hs | 3 |
4 files changed, 21 insertions, 15 deletions
diff --git a/compiler/utils/GraphColor.hs b/compiler/utils/GraphColor.hs index 41b367692a..8a1cdd0952 100644 --- a/compiler/utils/GraphColor.hs +++ b/compiler/utils/GraphColor.hs @@ -309,8 +309,9 @@ selectColor colors graph u Just nsConflicts = sequence $ map (lookupNode graph) - $ uniqSetToList + $ nonDetEltsUFM $ nodeConflicts node + -- See Note [Unique Determinism and code generation] colors_conflict = mkUniqSet $ catMaybes @@ -355,7 +356,8 @@ selectColor colors graph u -- it wasn't a preference, but it was still ok | not $ isEmptyUniqSet colors_ok - , c : _ <- uniqSetToList colors_ok + , c : _ <- nonDetEltsUFM colors_ok + -- See Note [Unique Determinism and code generation] = Just c -- no colors were available for us this time. diff --git a/compiler/utils/GraphOps.hs b/compiler/utils/GraphOps.hs index 8b194adba5..a4c565f2eb 100644 --- a/compiler/utils/GraphOps.hs +++ b/compiler/utils/GraphOps.hs @@ -89,11 +89,12 @@ delNode k graph | Just node <- lookupNode graph k = let -- delete conflict edges from other nodes to this one. graph1 = foldl' (\g k1 -> let Just g' = delConflict k1 k g in g') graph - $ uniqSetToList (nodeConflicts node) + $ nonDetEltsUFM (nodeConflicts node) -- delete coalesce edge from other nodes to this one. graph2 = foldl' (\g k1 -> let Just g' = delCoalesce k1 k g in g') graph1 - $ uniqSetToList (nodeCoalesce node) + $ nonDetEltsUFM (nodeCoalesce node) + -- See Note [Unique Determinism and code generation] -- delete the node graph3 = graphMapModify (\fm -> delFromUFM fm k) graph2 @@ -181,7 +182,7 @@ addConflicts addConflicts conflicts getClass -- just a single node, but no conflicts, create the node anyway. - | (u : []) <- uniqSetToList conflicts + | (u : []) <- nonDetEltsUFM conflicts = graphMapModify $ adjustWithDefaultUFM id @@ -191,7 +192,8 @@ addConflicts conflicts getClass | otherwise = graphMapModify $ (\fm -> foldl' (\g u -> addConflictSet1 u getClass conflicts g) fm - $ uniqSetToList conflicts) + $ nonDetEltsUFM conflicts) + -- See Note [Unique Determinism and code generation] addConflictSet1 :: Uniquable k @@ -315,7 +317,8 @@ coalesceGraph' aggressive triv graph kkPairsAcc -- cList = [ (nodeId node1, k2) | node1 <- cNodes - , k2 <- uniqSetToList $ nodeCoalesce node1 ] + , k2 <- nonDetEltsUFM $ nodeCoalesce node1 ] + -- See Note [Unique Determinism and code generation] -- do the coalescing, returning the new graph and a list of pairs of keys -- that got coalesced together. @@ -562,7 +565,7 @@ validateGraph doc isColored graph , not $ isEmptyUniqSet badEdges = pprPanic "GraphOps.validateGraph" ( text "Graph has edges that point to non-existant nodes" - $$ text " bad edges: " <> vcat (map ppr $ uniqSetToList badEdges) + $$ text " bad edges: " <> pprUFM badEdges (vcat . map ppr) $$ doc ) -- Check that no conflicting nodes have the same color @@ -602,7 +605,8 @@ checkNode checkNode graph node | Just color <- nodeColor node , Just neighbors <- sequence $ map (lookupNode graph) - $ uniqSetToList $ nodeConflicts node + $ nonDetEltsUFM $ nodeConflicts node + -- See Note [Unique Determinism and code generation] , neighbourColors <- catMaybes $ map nodeColor neighbors , elem color neighbourColors diff --git a/compiler/utils/GraphPpr.hs b/compiler/utils/GraphPpr.hs index 6f7e9d5bb2..9c246893f7 100644 --- a/compiler/utils/GraphPpr.hs +++ b/compiler/utils/GraphPpr.hs @@ -86,7 +86,8 @@ dotNode colorMap triv node excludes = hcat $ punctuate space $ map (\n -> text "-" <> ppr n) - $ uniqSetToList $ nodeExclusions node + $ nonDetEltsUFM $ nodeExclusions node + -- See Note [Unique Determinism and code generation] preferences = hcat $ punctuate space @@ -144,12 +145,14 @@ dotNodeEdges visited node | otherwise = let dconflicts = map (dotEdgeConflict (nodeId node)) - $ uniqSetToList + $ nonDetEltsUFM + -- See Note [Unique Determinism and code generation] $ minusUniqSet (nodeConflicts node) visited dcoalesces = map (dotEdgeCoalesce (nodeId node)) - $ uniqSetToList + $ nonDetEltsUFM + -- See Note [Unique Determinism and code generation] $ minusUniqSet (nodeCoalesce node) visited out = vcat dconflicts diff --git a/compiler/utils/UniqSet.hs b/compiler/utils/UniqSet.hs index 925997f45a..f08fa866c1 100644 --- a/compiler/utils/UniqSet.hs +++ b/compiler/utils/UniqSet.hs @@ -29,7 +29,6 @@ module UniqSet ( sizeUniqSet, isEmptyUniqSet, lookupUniqSet, - uniqSetToList, partitionUniqSet ) where @@ -69,7 +68,6 @@ partitionUniqSet :: (a -> Bool) -> UniqSet a -> (UniqSet a, UniqSet a) sizeUniqSet :: UniqSet a -> Int isEmptyUniqSet :: UniqSet a -> Bool lookupUniqSet :: Uniquable a => UniqSet b -> a -> Maybe b -uniqSetToList :: UniqSet a -> [a] {- ************************************************************************ @@ -116,7 +114,6 @@ partitionUniqSet = partitionUFM sizeUniqSet = sizeUFM isEmptyUniqSet = isNullUFM lookupUniqSet = lookupUFM -uniqSetToList = eltsUFM uniqSetAny :: (a -> Bool) -> UniqSet a -> Bool uniqSetAny = anyUFM |