From: Ben.Lippmeier@anu.edu.au Date: Thu, 17 Sep 2009 10:44:29 +0000 (+0000) Subject: NCG: Remember to keep the entry block first when erasing liveness info X-Git-Tag: 2010-11-18~677 X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=commitdiff_plain;h=af6e6c7022596e69b6aa0269cca18d7b8b1dcbf7 NCG: Remember to keep the entry block first when erasing liveness info --- 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.