X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2Fcmm%2FCmmCPSZ.hs;h=04f360c7932e0113d291b7a9e51392154059fff6;hb=2bb3a439c106935d97fae7f7a0b60c21493d1bef;hp=5f3775b26f7f7d068614d1f57de52cef937ee6df;hpb=5dc8b425443200a5160b9d1399aca1808bfcffee;p=ghc-hetmet.git diff --git a/compiler/cmm/CmmCPSZ.hs b/compiler/cmm/CmmCPSZ.hs index 5f3775b..04f360c 100644 --- a/compiler/cmm/CmmCPSZ.hs +++ b/compiler/cmm/CmmCPSZ.hs @@ -20,8 +20,8 @@ import DynFlags import ErrUtils import FiniteMap import HscTypes -import Maybe -import Monad +import Data.Maybe +import Control.Monad import Outputable import StaticFlags @@ -84,9 +84,13 @@ cpsTop hsc_env (CmmProc h l args (stackInfo@(entry_off, _), g)) = dump Opt_D_dump_cmmz "Pre common block elimination" g g <- return $ elimCommonBlocks g dump Opt_D_dump_cmmz "Post common block elimination" g + + ----------- Proc points ------------------- procPoints <- run $ minimalProcPointSet callPPs g g <- run $ addProcPointProtocols callPPs procPoints g dump Opt_D_dump_cmmz "Post Proc Points Added" g + + ----------- Spills and reloads ------------------- g <- -- pprTrace "pre Spills" (ppr g) $ dual_rewrite Opt_D_dump_cmmz "spills and reloads" @@ -101,10 +105,15 @@ cpsTop hsc_env (CmmProc h l args (stackInfo@(entry_off, _), g)) = dual_rewrite Opt_D_dump_cmmz "Dead Assignment Elimination" (removeDeadAssignmentsAndReloads procPoints) g -- Remove redundant reloads (and any other redundant asst) + + ----------- Debug only: add code to put zero in dead stack slots---- -- Debugging: stubbing slots on death can cause crashes early g <- -- trace "post dead-assign elim" $ if opt_StubDeadValues then run $ stubSlotsOnDeath g else return g + + + --------------- Stack layout ---------------- slotEnv <- run $ liveSlotAnal g mbpprTrace "live slot analysis results: " (ppr slotEnv) $ return () cafEnv <- @@ -116,25 +125,31 @@ cpsTop hsc_env (CmmProc h l args (stackInfo@(entry_off, _), g)) = mbpprTrace "slotEnv extended for safe foreign calls: " (ppr slotEnv) $ return () let areaMap = layout procPoints slotEnv entry_off g mbpprTrace "areaMap" (ppr areaMap) $ return () + + ------------ Manifest the the stack pointer -------- g <- run $ manifestSP areaMap entry_off g dump Opt_D_dump_cmmz "after manifestSP" g -- UGH... manifestSP can require updates to the procPointMap. -- We can probably do something quicker here for the update... + + ------------- Split into separate procedures ------------ procPointMap <- run $ procPointAnalysis procPoints g dump Opt_D_dump_cmmz "procpoint map" procPointMap gs <- run $ splitAtProcPoints l callPPs procPoints procPointMap (CmmProc h l args (stackInfo, g)) - mapM (dump Opt_D_dump_cmmz "after splitting") gs + mapM_ (dump Opt_D_dump_cmmz "after splitting") gs + + ------------- More CAFs and foreign calls ------------ let localCAFs = catMaybes $ map (localCAFInfo cafEnv) gs mbpprTrace "localCAFs" (ppr localCAFs) $ return () gs <- liftM concat $ run $ foldM lowerSafeForeignCalls [] gs - mapM (dump Opt_D_dump_cmmz "after lowerSafeForeignCalls") gs + mapM_ (dump Opt_D_dump_cmmz "after lowerSafeForeignCalls") gs -- NO MORE GRAPH TRANSFORMATION AFTER HERE -- JUST MAKING INFOTABLES let gs' = map (setInfoTableStackMap slotEnv areaMap) gs - mapM (dump Opt_D_dump_cmmz "after setInfoTableStackMap") gs' + mapM_ (dump Opt_D_dump_cmmz "after setInfoTableStackMap") gs' let gs'' = map (bundleCAFs cafEnv) gs' - mapM (dump Opt_D_dump_cmmz "after bundleCAFs") gs'' + mapM_ (dump Opt_D_dump_cmmz "after bundleCAFs") gs'' return (localCAFs, gs'') where dflags = hsc_dflags hsc_env mbpprTrace x y z = if dopt Opt_D_dump_cmmz dflags then pprTrace x y z else z