[commit: ghc] master: Kill foldUniqSet (3e7a876)

git at git.haskell.org git at git.haskell.org
Mon Jun 6 15:19:21 UTC 2016


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/3e7a876a9cdf10e5153421b4905928b9de981778/ghc

>---------------------------------------------------------------

commit 3e7a876a9cdf10e5153421b4905928b9de981778
Author: Bartosz Nitka <niteria at gmail.com>
Date:   Mon Jun 6 08:15:43 2016 -0700

    Kill foldUniqSet
    
    I planned to just say that we don't care about this part.
    Turns out I was able to document away the uses in the codegenerator.
    
    Test Plan: ./validate
    
    Reviewers: simonmar, austin, bgamari
    
    Subscribers: thomie
    
    Differential Revision: https://phabricator.haskell.org/D2307
    
    GHC Trac Issues: #4012


>---------------------------------------------------------------

3e7a876a9cdf10e5153421b4905928b9de981778
 compiler/nativeGen/RegAlloc/Graph/SpillClean.hs    |  3 ++-
 compiler/nativeGen/RegAlloc/Graph/TrivColorable.hs |  4 +--
 compiler/utils/GraphOps.hs                         | 30 ++++++++++++++--------
 compiler/utils/UniqSet.hs                          |  4 +--
 4 files changed, 24 insertions(+), 17 deletions(-)

diff --git a/compiler/nativeGen/RegAlloc/Graph/SpillClean.hs b/compiler/nativeGen/RegAlloc/Graph/SpillClean.hs
index f472d29..2383d7b 100644
--- a/compiler/nativeGen/RegAlloc/Graph/SpillClean.hs
+++ b/compiler/nativeGen/RegAlloc/Graph/SpillClean.hs
@@ -549,7 +549,8 @@ delAssoc :: (Uniquable a)
 delAssoc a m
         | Just aSet     <- lookupUFM  m a
         , m1            <- delFromUFM m a
-        = foldUniqSet (\x m -> delAssoc1 x a m) m1 aSet
+        = nonDetFoldUFM (\x m -> delAssoc1 x a m) m1 aSet
+          -- It's OK to use nonDetFoldUFM here because deletion is commutative
 
         | otherwise     = m
 
diff --git a/compiler/nativeGen/RegAlloc/Graph/TrivColorable.hs b/compiler/nativeGen/RegAlloc/Graph/TrivColorable.hs
index b632ac7..4bbf5d4 100644
--- a/compiler/nativeGen/RegAlloc/Graph/TrivColorable.hs
+++ b/compiler/nativeGen/RegAlloc/Graph/TrivColorable.hs
@@ -225,8 +225,8 @@ trivColorable classN conflicts exclusions
                 RcFloat         -> (cd,   cf+1)
                 _               -> panic "Regs.trivColorable: reg class not handled"
 
-        tmp                     = foldUniqSet acc (0, 0) conflicts
-        (countInt,  countFloat) = foldUniqSet acc tmp    exclusions
+        tmp                     = nonDetFoldUFM acc (0, 0) conflicts
+        (countInt,  countFloat) = nonDetFoldUFM acc tmp    exclusions
 
         squeese         = worst countInt   classN RcInteger
                         + worst countFloat classN RcFloat
diff --git a/compiler/utils/GraphOps.hs b/compiler/utils/GraphOps.hs
index ba0db0f..8b194ad 100644
--- a/compiler/utils/GraphOps.hs
+++ b/compiler/utils/GraphOps.hs
@@ -58,18 +58,24 @@ addNode :: Uniquable k
 addNode k node graph
  = let
         -- add back conflict edges from other nodes to this one
-        map_conflict
-                = foldUniqSet
-                        (adjustUFM_C (\n -> n { nodeConflicts = addOneToUniqSet (nodeConflicts n) k}))
-                        (graphMap graph)
-                        (nodeConflicts node)
+        map_conflict =
+          nonDetFoldUFM
+            -- It's OK to use nonDetFoldUFM here because the
+            -- operation is commutative
+            (adjustUFM_C (\n -> n { nodeConflicts =
+                                      addOneToUniqSet (nodeConflicts n) k}))
+            (graphMap graph)
+            (nodeConflicts node)
 
         -- add back coalesce edges from other nodes to this one
-        map_coalesce
-                = foldUniqSet
-                        (adjustUFM_C (\n -> n { nodeCoalesce = addOneToUniqSet (nodeCoalesce n) k}))
-                        map_conflict
-                        (nodeCoalesce node)
+        map_coalesce =
+          nonDetFoldUFM
+            -- It's OK to use nonDetFoldUFM here because the
+            -- operation is commutative
+            (adjustUFM_C (\n -> n { nodeCoalesce =
+                                      addOneToUniqSet (nodeCoalesce n) k}))
+            map_conflict
+            (nodeCoalesce node)
 
   in    graph
         { graphMap      = addToUFM map_coalesce k node}
@@ -462,7 +468,9 @@ freezeNode k
                 else node       -- panic "GraphOps.freezeNode: edge to freeze wasn't in the coalesce set"
                                 -- If the edge isn't actually in the coelesce set then just ignore it.
 
-        fm2     = foldUniqSet (adjustUFM_C (freezeEdge k)) fm1
+        fm2     = nonDetFoldUFM (adjustUFM_C (freezeEdge k)) fm1
+                    -- It's OK to use nonDetFoldUFM here because the operation
+                    -- is commutative
                         $ nodeCoalesce node
 
     in  fm2
diff --git a/compiler/utils/UniqSet.hs b/compiler/utils/UniqSet.hs
index a316f53..925997f 100644
--- a/compiler/utils/UniqSet.hs
+++ b/compiler/utils/UniqSet.hs
@@ -22,7 +22,7 @@ module UniqSet (
         unionUniqSets, unionManyUniqSets,
         minusUniqSet,
         intersectUniqSets,
-        foldUniqSet, uniqSetAny, uniqSetAll,
+        uniqSetAny, uniqSetAll,
         elementOfUniqSet,
         elemUniqSet_Directly,
         filterUniqSet,
@@ -61,7 +61,6 @@ unionManyUniqSets :: [UniqSet a] -> UniqSet a
 minusUniqSet  :: UniqSet a -> UniqSet a -> UniqSet a
 intersectUniqSets :: UniqSet a -> UniqSet a -> UniqSet a
 
-foldUniqSet :: (a -> b -> b) -> b -> UniqSet a -> b
 elementOfUniqSet :: Uniquable a => a -> UniqSet a -> Bool
 elemUniqSet_Directly :: Unique -> UniqSet a -> Bool
 filterUniqSet :: (a -> Bool) -> UniqSet a -> UniqSet a
@@ -109,7 +108,6 @@ unionManyUniqSets sets = foldr1 unionUniqSets sets
 minusUniqSet = minusUFM
 intersectUniqSets = intersectUFM
 
-foldUniqSet = foldUFM
 elementOfUniqSet = elemUFM
 elemUniqSet_Directly = elemUFM_Directly
 filterUniqSet = filterUFM



More information about the ghc-commits mailing list