From 638181c4f19f38898abf5ff41b891eaa62ea9325 Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Sat, 14 Dec 2019 22:56:31 +0100 Subject: Fix serious correctness issue in Optimiser globalPropAssigns The optimisation pass would often not collect all assignments to a particular reference, so that it would wrongly conclude that a reference is only ever assigned once while it is actually assigned in multiple places. I have _no_ idea why this didn't result in issues before. --- Optimiser.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/Optimiser.hs b/Optimiser.hs index c59c40e..4cff2ea 100644 --- a/Optimiser.hs +++ b/Optimiser.hs @@ -98,6 +98,7 @@ globalPropAssigns :: [BB] -> [BB] globalPropAssigns bbs = let asgmap = map ((,) <$> fst . head <*> map snd) . groupBy ((==) `on` fst) + . sortOn fst $ [pair | BB _ inss _ <- bbs, pair <- inss] replacements = concatMap (\(dest, inss) -> case inss of [IAssign ref@(RConst _)] -> [(dest, ref)] -- cgit v1.2.3