From af6e6c7022596e69b6aa0269cca18d7b8b1dcbf7 Mon Sep 17 00:00:00 2001 From: "Ben.Lippmeier@anu.edu.au" Date: Thu, 17 Sep 2009 10:44:29 +0000 Subject: [PATCH] NCG: Remember to keep the entry block first when erasing liveness info --- compiler/nativeGen/RegAlloc/Liveness.hs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/compiler/nativeGen/RegAlloc/Liveness.hs b/compiler/nativeGen/RegAlloc/Liveness.hs index 69ec7ae..18dd01a 100644 --- a/compiler/nativeGen/RegAlloc/Liveness.hs +++ b/compiler/nativeGen/RegAlloc/Liveness.hs @@ -457,10 +457,21 @@ stripLive live = stripCmm live where stripCmm (CmmData sec ds) = CmmData sec ds - stripCmm (CmmProc (LiveInfo info _ _) label params sccs) - = CmmProc info label params - (ListGraph $ map stripLiveBlock $ flattenSCCs sccs) - + + stripCmm (CmmProc (LiveInfo info (Just first_id) _) label params sccs) + = let final_blocks = flattenSCCs sccs + + -- make sure the block that was first in the input list + -- stays at the front of the output. This is the entry point + -- of the proc, and it needs to come first. + ((first':_), rest') + = partition ((== first_id) . blockId) final_blocks + + in CmmProc info label params + (ListGraph $ map stripLiveBlock $ first' : rest') + + stripCmm _ + = panic "RegAlloc.Liveness.stripLive: no first_id on proc" -- | Strip away liveness information from a basic block, -- and make real spill instructions out of SPILL, RELOAD pseudos along the way. -- 1.7.10.4