From 80fee1089b659a7c7ee3a96d4cf999d369c0eb48 Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Thu, 12 Dec 2019 20:38:34 +0100 Subject: Liveness: report live variables before AND after instruction --- Liveness.hs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Liveness.hs b/Liveness.hs index 40c555b..a40c7de 100644 --- a/Liveness.hs +++ b/Liveness.hs @@ -22,10 +22,12 @@ livenessAnalysis -> (bb -> [bbid]) -- control flow graph: subsequents of a basic block -> (ins -> set var) -- read set (variables required to be live when entering this instruction) -> (ins -> set var) -- write set (variables made available after this instruction) - -> [[Set var]] -- variables live at the start of that instruction + -> [[(Set var, Set var)]] -- variables live (before, after) that instruction livenessAnalysis bblocks bidOf bbInss bbNexts fread fwrite = let bbEndLive = computeFlow (Map.fromList (map (,Set.empty) bids)) - in zipWith (\fs endlive -> init (scanr id endlive fs)) (mapToList insTransFs) (mapToList bbEndLive) + in zipWith (\fs endlive -> let lives = scanr id endlive fs + in zip lives (tail lives)) + (mapToList insTransFs) (mapToList bbEndLive) where mapToList m = map (m Map.!) bids bids = map bidOf bblocks -- cgit v1.2.3