X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2FnativeGen%2FRegSpillCost.hs;h=6a2066a5e80e94e579bd0651a915075ac87ed369;hb=6822f86c440bece1fc053336a75dac264325d077;hp=e639c67b601c2fbddb620c26214619dc2620f422;hpb=220a12e946b80166d3fe20419091135cef01f668;p=ghc-hetmet.git diff --git a/compiler/nativeGen/RegSpillCost.hs b/compiler/nativeGen/RegSpillCost.hs index e639c67..6a2066a 100644 --- a/compiler/nativeGen/RegSpillCost.hs +++ b/compiler/nativeGen/RegSpillCost.hs @@ -21,6 +21,7 @@ import RegLiveness import RegAllocInfo import MachInstrs import MachRegs +import BlockId import Cmm import UniqFM @@ -78,7 +79,7 @@ slurpSpillCostInfo cmm -- the info table from the CmmProc countBlock info (BasicBlock blockId instrs) | LiveInfo _ _ blockLive <- info - , Just rsLiveEntry <- lookupUFM blockLive blockId + , Just rsLiveEntry <- lookupBlockEnv blockLive blockId = countLIs rsLiveEntry instrs | otherwise @@ -132,7 +133,7 @@ chooseSpill -> Reg chooseSpill info graph - = let cost = spillCost info graph + = let cost = spillCost_length info graph node = minimumBy (\n1 n2 -> compare (cost $ nodeId n1) (cost $ nodeId n2)) $ eltsUFM $ graphMap graph @@ -177,14 +178,14 @@ chooseSpill info graph -- Without live range splitting, its's better to spill from the outside in so set the cost of very -- long live ranges to zero -- - -spillCost +{- +spillCost_chaitin :: SpillCostInfo -> Graph Reg RegClass Reg -> Reg -> Float -spillCost info graph reg +spillCost_chaitin info graph reg -- Spilling a live range that only lives for 1 instruction isn't going to help -- us at all - and we definately want to avoid trying to re-spill previously -- inserted spill code. @@ -200,6 +201,21 @@ spillCost info graph reg | otherwise = fromIntegral (uses + defs) / fromIntegral (nodeDegree graph reg) where (_, defs, uses, lifetime) = fromMaybe (reg, 0, 0, 0) $ lookupUFM info reg +-} + +-- Just spill the longest live range. +spillCost_length + :: SpillCostInfo + -> Graph Reg RegClass Reg + -> Reg + -> Float + +spillCost_length info _ reg + | lifetime <= 1 = 1/0 + | otherwise = 1 / fromIntegral lifetime + where (_, _, _, lifetime) + = fromMaybe (reg, 0, 0, 0) $ lookupUFM info reg + lifeMapFromSpillCostInfo :: SpillCostInfo -> UniqFM (Reg, Int)