- allocCallSlot areaMap (Block id stackInfo t)
- | elemBlockSet id procPoints =
- let young = youngest_live areaMap $ live_in t
- start = case returnOff stackInfo of Just b -> max b young
- Nothing -> young
- z = allocSlotFrom ig areaSize start areaMap (CallArea (Young id))
- in pprTrace "allocCallSlot for" (ppr id <+> ppr young <+> ppr (live_in t) <+> ppr z) z
- allocCallSlot areaMap _ = areaMap
- -- mid foreign calls need to have info tables placed on the stack
+
+ -- Update the successor's incoming SP.
+ setSuccSPs inSp bid areaMap =
+ case (lookupFM areaMap area, lookupBlockEnv (lg_blocks g) bid) of
+ (Just _, _) -> areaMap -- succ already knows incoming SP
+ (Nothing, Just (Block _ _)) ->
+ if elemBlockSet bid procPoints then
+ let young = youngest_live areaMap $ env' bid
+ -- start = case returnOff stackInfo of Just b -> max b young
+ -- Nothing -> young
+ start = young -- maybe wrong, but I don't understand
+ -- why the preceding is necessary...
+ in allocSlotFrom ig areaSize start areaMap area
+ else addToFM areaMap area inSp
+ (_, Nothing) -> panic "Block not found in cfg"
+ where area = CallArea (Young bid)
+
+ allocLast (Block id _) areaMap l =
+ fold_succs (setSuccSPs inSp) l areaMap
+ where inSp = expectJust "sp in" $ lookupFM areaMap (CallArea (Young id))
+