Commit 48bb69ac authored by ian@well-typed.com's avatar ian@well-typed.com
Browse files

Small refactoring: Use more idiomatic strictness forcing in AsmCodeGen

parent 497cb612
...@@ -80,6 +80,7 @@ import qualified Stream ...@@ -80,6 +80,7 @@ import qualified Stream
import Data.List import Data.List
import Data.Maybe import Data.Maybe
import Control.Exception
import Control.Monad import Control.Monad
import System.IO import System.IO
...@@ -363,19 +364,16 @@ cmmNativeGens dflags ncgImpl h us (cmm : cmms) impAcc profAcc count ...@@ -363,19 +364,16 @@ cmmNativeGens dflags ncgImpl h us (cmm : cmms) impAcc profAcc count
$ withPprStyleDoc dflags (mkCodeStyle AsmStyle) $ withPprStyleDoc dflags (mkCodeStyle AsmStyle)
$ vcat $ map (pprNatCmmDecl ncgImpl) native $ vcat $ map (pprNatCmmDecl ncgImpl) native
-- carefully evaluate this strictly. Binding it with 'let' let !lsPprNative =
-- and then using 'seq' doesn't work, because the let
-- apparently gets inlined first.
lsPprNative <- return $!
if dopt Opt_D_dump_asm dflags if dopt Opt_D_dump_asm dflags
|| dopt Opt_D_dump_asm_stats dflags || dopt Opt_D_dump_asm_stats dflags
then native then native
else [] else []
count' <- return $! count + 1; let !count' = count + 1
-- force evaulation all this stuff to avoid space leaks -- force evaulation all this stuff to avoid space leaks
{-# SCC "seqString" #-} seqString (showSDoc dflags $ vcat $ map ppr imports) `seq` return () {-# SCC "seqString" #-} evaluate $ seqString (showSDoc dflags $ vcat $ map ppr imports)
cmmNativeGens dflags ncgImpl cmmNativeGens dflags ncgImpl
h us' cmms h us' cmms
...@@ -384,7 +382,7 @@ cmmNativeGens dflags ncgImpl h us (cmm : cmms) impAcc profAcc count ...@@ -384,7 +382,7 @@ cmmNativeGens dflags ncgImpl h us (cmm : cmms) impAcc profAcc count
count' count'
where seqString [] = () where seqString [] = ()
seqString (x:xs) = x `seq` seqString xs `seq` () seqString (x:xs) = x `seq` seqString xs
-- | Complete native code generation phase for a single top-level chunk of Cmm. -- | Complete native code generation phase for a single top-level chunk of Cmm.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment