Commit b84c09d5 authored by Ömer Sinan Ağacan's avatar Ömer Sinan Ağacan Committed by Marge Bot

Tweak Cmm dumps to avoid generating sections for empty groups

When dumping Cmm groups check if the group is empty, to avoid generating
empty sections in dump files like

    ==================== Output Cmm ====================
    []

Also fixes a few bad indentation in the code around changes.
parent c4279ff1
......@@ -1456,9 +1456,10 @@ hscGenHardCode hsc_env cgguts location output_filename = do
rawcmms0 <- {-# SCC "cmmToRawCmm" #-}
cmmToRawCmm dflags cmms
let dump a = do dumpIfSet_dyn dflags Opt_D_dump_cmm_raw "Raw Cmm"
FormatCMM (ppr a)
return a
let dump a = do
unless (null a) $
dumpIfSet_dyn dflags Opt_D_dump_cmm_raw "Raw Cmm" FormatCMM (ppr a)
return a
rawcmms1 = Stream.mapM dump rawcmms0
(output_filename, (_stub_h_exists, stub_c_exists), foreign_fps, ())
......@@ -1512,8 +1513,9 @@ hscCompileCmmFile hsc_env filename output_filename = runHsc hsc_env $ do
mod_name = mkModuleName $ "Cmm$" ++ FilePath.takeFileName filename
cmm_mod = mkModule (thisPackage dflags) mod_name
(_, cmmgroup) <- cmmPipeline hsc_env (emptySRT cmm_mod) cmm
dumpIfSet_dyn dflags Opt_D_dump_cmm "Output Cmm"
FormatCMM (ppr cmmgroup)
unless (null cmmgroup) $
dumpIfSet_dyn dflags Opt_D_dump_cmm "Output Cmm"
FormatCMM (ppr cmmgroup)
rawCmms <- cmmToRawCmm dflags (Stream.yield cmmgroup)
_ <- codeOutput dflags cmm_mod output_filename no_loc NoStubs [] []
rawCmms
......@@ -1550,20 +1552,23 @@ doCodeGen hsc_env this_mod data_tycons
-- CmmGroup on input may produce many CmmGroups on output due
-- to proc-point splitting).
let dump1 a = do dumpIfSet_dyn dflags Opt_D_dump_cmm_from_stg
"Cmm produced by codegen" FormatCMM (ppr a)
return a
let dump1 a = do
unless (null a) $
dumpIfSet_dyn dflags Opt_D_dump_cmm_from_stg
"Cmm produced by codegen" FormatCMM (ppr a)
return a
ppr_stream1 = Stream.mapM dump1 cmm_stream
pipeline_stream
= {-# SCC "cmmPipeline" #-}
let run_pipeline = cmmPipeline hsc_env
in void $ Stream.mapAccumL run_pipeline (emptySRT this_mod) ppr_stream1
pipeline_stream =
{-# SCC "cmmPipeline" #-}
let run_pipeline = cmmPipeline hsc_env
in void $ Stream.mapAccumL run_pipeline (emptySRT this_mod) ppr_stream1
dump2 a = do dumpIfSet_dyn dflags Opt_D_dump_cmm
"Output Cmm" FormatCMM (ppr a)
return a
dump2 a = do
unless (null a) $
dumpIfSet_dyn dflags Opt_D_dump_cmm "Output Cmm" FormatCMM (ppr a)
return a
ppr_stream2 = Stream.mapM dump2 pipeline_stream
......
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