summaryrefslogtreecommitdiff
path: root/compiler/main/HscMain.hs
diff options
context:
space:
mode:
authorÖmer Sinan Ağacan <omeragacan@gmail.com>2019-12-30 16:29:58 +0300
committerMarge Bot <ben+marge-bot@smart-cactus.org>2019-12-31 23:45:19 -0500
commitb84c09d533faf576c406ce9f7163efecf3037787 (patch)
treeec54a33babac789c4a76d834476a84209aeba84e /compiler/main/HscMain.hs
parentc4279ff18070c398b5ddc677f9c5a915de68dafc (diff)
downloadhaskell-b84c09d533faf576c406ce9f7163efecf3037787.tar.gz
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.
Diffstat (limited to 'compiler/main/HscMain.hs')
-rw-r--r--compiler/main/HscMain.hs35
1 files changed, 20 insertions, 15 deletions
diff --git a/compiler/main/HscMain.hs b/compiler/main/HscMain.hs
index 016cad9303..7d99c467c1 100644
--- a/compiler/main/HscMain.hs
+++ b/compiler/main/HscMain.hs
@@ -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