NCG: Fix dumping of graphs in regalloc stats for graph allocator
[ghc-hetmet.git] / compiler / nativeGen / RegAlloc / Graph / SpillCost.hs
index 9de48d5..9799587 100644 (file)
@@ -23,11 +23,11 @@ import Reg
 
 import GraphBase
 
-
 import BlockId
 import Cmm
 import UniqFM
 import UniqSet
+import Digraph         (flattenSCCs)
 import Outputable
 import State
 
@@ -71,16 +71,14 @@ slurpSpillCostInfo cmm
        = execState (countCmm cmm) zeroSpillCostInfo
  where
        countCmm CmmData{}              = return ()
-       countCmm (CmmProc info _ _ (ListGraph blocks))
-               = mapM_ (countComp info) blocks
-
-       countComp info (BasicBlock _ blocks)
-               = mapM_ (countBlock info) blocks
+       countCmm (CmmProc info _ _ sccs)
+               = mapM_ (countBlock info)
+               $ flattenSCCs sccs
 
        -- lookup the regs that are live on entry to this block in
        --      the info table from the CmmProc
        countBlock info (BasicBlock blockId instrs)
-               | LiveInfo _ _ blockLive        <- info
+               | LiveInfo _ _ (Just blockLive) <- info
                , Just rsLiveEntry              <- lookupBlockEnv blockLive blockId
 
                , rsLiveEntry_virt      <- mapUniqSet (\(RegVirtual vr) -> vr) 
@@ -95,13 +93,7 @@ slurpSpillCostInfo cmm
                = return ()
 
        -- skip over comment and delta pseudo instrs
-       countLIs rsLive (SPILL{} : lis)
-               = countLIs rsLive lis
-               
-       countLIs rsLive (RELOAD{} : lis)
-               = countLIs rsLive lis
-
-       countLIs rsLive (Instr instr Nothing : lis)
+       countLIs rsLive (LiveInstr instr Nothing : lis)
                | isMetaInstr instr
                = countLIs rsLive lis
 
@@ -109,7 +101,7 @@ slurpSpillCostInfo cmm
                = pprPanic "RegSpillCost.slurpSpillCostInfo"
                        (text "no liveness information on instruction " <> ppr instr)
 
-       countLIs rsLiveEntry (Instr instr (Just live) : lis)
+       countLIs rsLiveEntry (LiveInstr instr (Just live) : lis)
         = do
                -- increment the lifetime counts for regs live on entry to this instr
                mapM_ incLifetime $ uniqSetToList rsLiveEntry