X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2Fcmm%2FCmmProcPoint.hs;h=de8cfa378b3e5d6379e3317a485cd69b28dec3b9;hb=c6206fd81612e51e257a650390646421c7c1d1cb;hp=5a159a65651c2a0f064252d95ba5876215807f9c;hpb=81285ec475e94ef93d2ac59386d48cb333da2c96;p=ghc-hetmet.git diff --git a/compiler/cmm/CmmProcPoint.hs b/compiler/cmm/CmmProcPoint.hs index 5a159a6..de8cfa3 100644 --- a/compiler/cmm/CmmProcPoint.hs +++ b/compiler/cmm/CmmProcPoint.hs @@ -4,12 +4,11 @@ module CmmProcPoint ( #include "HsVersions.h" -import Cmm +import BlockId import CmmBrokenBlock import Dataflow import UniqSet -import UniqFM import Panic -- Determine the proc points for a set of basic blocks. @@ -46,7 +45,7 @@ calculateProcPoints blocks = always_proc_point BrokenBlock { brokenBlockEntry = FunctionEntry _ _ _ } = True always_proc_point BrokenBlock { - brokenBlockEntry = ContinuationEntry _ _ } = True + brokenBlockEntry = ContinuationEntry _ _ _ } = True always_proc_point _ = False calculateProcPoints' :: UniqSet BlockId -> [BrokenBlock] -> UniqSet BlockId @@ -77,21 +76,25 @@ calculateNewProcPoints owners block = then unitUniqSet child_id else emptyUniqSet where - parent_owners = lookupWithDefaultUFM owners emptyUniqSet parent_id - child_owners = lookupWithDefaultUFM owners emptyUniqSet child_id - needs_proc_point = not $ isEmptyUniqSet $ - child_owners `minusUniqSet` parent_owners + parent_owners = lookupWithDefaultBEnv owners emptyUniqSet parent_id + child_owners = lookupWithDefaultBEnv owners emptyUniqSet child_id + needs_proc_point = + -- only if parent isn't dead + (not $ isEmptyUniqSet parent_owners) && + -- and only if child has more owners than parent + (not $ isEmptyUniqSet $ + child_owners `minusUniqSet` parent_owners) calculateOwnership :: BlockEnv BrokenBlock -> UniqSet BlockId -> [BrokenBlock] -> BlockEnv (UniqSet BlockId) calculateOwnership blocks_ufm proc_points blocks = - fixedpoint dependants update (map brokenBlockId blocks) emptyUFM + fixedpoint dependants update (map brokenBlockId blocks) emptyBlockEnv where dependants :: BlockId -> [BlockId] dependants ident = - brokenBlockTargets $ lookupWithDefaultUFM + brokenBlockTargets $ lookupWithDefaultBEnv blocks_ufm unknown_block ident update :: BlockId @@ -101,16 +104,16 @@ calculateOwnership blocks_ufm proc_points blocks = update ident cause owners = case (cause, ident `elementOfUniqSet` proc_points) of (Nothing, True) -> - Just $ addToUFM owners ident (unitUniqSet ident) + Just $ extendBlockEnv owners ident (unitUniqSet ident) (Nothing, False) -> Nothing - (Just cause', True) -> Nothing + (Just _, True) -> Nothing (Just cause', False) -> if (sizeUniqSet old) == (sizeUniqSet new) then Nothing - else Just $ addToUFM owners ident new + else Just $ extendBlockEnv owners ident new where - old = lookupWithDefaultUFM owners emptyUniqSet ident + old = lookupWithDefaultBEnv owners emptyUniqSet ident new = old `unionUniqSets` - lookupWithDefaultUFM owners emptyUniqSet cause' + lookupWithDefaultBEnv owners emptyUniqSet cause' - unknown_block = panic "unknown BlockId in selectStackFormat" + unknown_block = panic "unknown BlockId in calculateOwnership"