Commit c59e584e authored by Alex D's avatar Alex D 🍄

Change behaviour of -ddump-cmm-verbose to dump each Cmm pass output to a...

Change behaviour of -ddump-cmm-verbose to dump each Cmm pass output to a separate file and add -ddump-cmm-verbose-by-proc to keep old behaviour (#16930)
parent d0f8ed20
Pipeline #8746 passed with stages
in 421 minutes and 25 seconds
......@@ -353,9 +353,10 @@ dumpGraph dflags flag name g = do
dumpWith :: DynFlags -> DumpFlag -> String -> SDoc -> IO ()
dumpWith dflags flag txt sdoc = do
-- ToDo: No easy way of say "dump all the cmm, *and* split
-- them into files." Also, -ddump-cmm-verbose doesn't play
-- nicely with -ddump-to-file, since the headers get omitted.
dumpIfSet_dyn dflags flag txt sdoc
when (not (dopt flag dflags)) $
dumpIfSet_dyn dflags Opt_D_dump_cmm_verbose txt sdoc
dumpIfSet_dyn dflags flag txt sdoc
when (not (dopt flag dflags)) $
-- If `-ddump-cmm-verbose -ddump-to-file` is specified,
-- dump each Cmm pipeline stage output to a separate file. #16930
when (dopt Opt_D_dump_cmm_verbose dflags)
$ dumpSDoc dflags alwaysQualify flag txt sdoc
dumpIfSet_dyn dflags Opt_D_dump_cmm_verbose_by_proc txt sdoc
......@@ -407,10 +407,13 @@ data DumpFlag
= Opt_D_dump_cmm
| Opt_D_dump_cmm_from_stg
| Opt_D_dump_cmm_raw
| Opt_D_dump_cmm_verbose
| Opt_D_dump_cmm_verbose_by_proc
-- All of the cmm subflags (there are a lot!) automatically
-- enabled if you run -ddump-cmm-verbose
-- enabled if you run -ddump-cmm-verbose-by-proc
-- Each flag corresponds to exact stage of Cmm pipeline.
| Opt_D_dump_cmm_verbose
-- same as -ddump-cmm-verbose-by-proc but writes each stage
-- to a separate file (if used with -ddump-to-file)
| Opt_D_dump_cmm_cfg
| Opt_D_dump_cmm_cbe
| Opt_D_dump_cmm_switch
......@@ -3302,6 +3305,8 @@ dynamic_flags_deps = [
(setDumpFlag Opt_D_dump_cmm_raw)
, make_ord_flag defGhcFlag "ddump-cmm-verbose"
(setDumpFlag Opt_D_dump_cmm_verbose)
, make_ord_flag defGhcFlag "ddump-cmm-verbose-by-proc"
(setDumpFlag Opt_D_dump_cmm_verbose_by_proc)
, make_ord_flag defGhcFlag "ddump-cmm-cfg"
(setDumpFlag Opt_D_dump_cmm_cfg)
, make_ord_flag defGhcFlag "ddump-cmm-cbe"
......
......@@ -1472,7 +1472,7 @@ hscCompileCmmFile hsc_env filename output_filename = runHsc hsc_env $ do
let dflags = hsc_dflags hsc_env
cmm <- ioMsgMaybe $ parseCmmFile dflags filename
liftIO $ do
dumpIfSet_dyn dflags Opt_D_dump_cmm_verbose "Parsed Cmm" (ppr cmm)
dumpIfSet_dyn dflags Opt_D_dump_cmm_verbose_by_proc "Parsed Cmm" (ppr cmm)
let -- Make up a module name to give the NCG. We can't pass bottom here
-- lest we reproduce #11784.
mod_name = mkModuleName $ "Cmm$" ++ FilePath.takeFileName filename
......
......@@ -391,8 +391,8 @@ C-\\- representation
These flags dump various phases of GHC's C-\\- pipeline.
.. ghc-flag:: -ddump-cmm-verbose
:shortdesc: Show output from main C-\\- pipeline passes
.. ghc-flag:: -ddump-cmm-verbose-by-proc
:shortdesc: Show output from main C-\\- pipeline passes (grouped by proc)
:type: dynamic
Dump output from main C-\\- pipeline stages. In case of
......@@ -404,6 +404,13 @@ These flags dump various phases of GHC's C-\\- pipeline.
Cmm dumps don't include unreachable blocks since we print
blocks in reverse post-order.
.. ghc-flag:: -ddump-cmm-verbose
:shortdesc: Write output from main C-\\- pipeline passes to files
:type: dynamic
If used in conjunction with `-ddump-to-file`, writes dump
output from main C-\\- pipeline stages to files (each stage per file).
.. ghc-flag:: -ddump-cmm-from-stg
:shortdesc: Dump STG-to-C-\\- output
:type: dynamic
......
TOP=../../..
include $(TOP)/mk/boilerplate.mk
include $(TOP)/mk/test.mk
## check if -ddump-cmm-verbose -ddump-to-file generates files
# for all cmm stages and dumps correspond to correct procs
T16930:
echo "testing -ddump-cmm-verbose for T16930 ..."
'$(TEST_HC)' $(TEST_HC_OPTS) T16930.hs -fforce-recomp -ddump-cmm-verbose -ddump-to-file
grep -rl "CAFEnv" . --include=\T16930.*
grep -rl "Post control-flow optimisations" . --include=\T16930.*
grep -rl "Post CPS Cmm" . --include=\T16930.*
grep -rl "after setInfoTableStackMap" . --include=\T16930.*
grep -rl "Layout Stack" . --include=\T16930.*
grep -rl "Post switch plan" . --include=\T16930.*
module Main where
a :: Int
a = 1
b :: Int
b = a + 7
main :: IO ()
main = return ()
testing -ddump-cmm-verbose for T16930 ...
[1 of 1] Compiling Main ( T16930.hs, T16930.o )
Linking T16930 ...
./T16930.dump-cmm-caf
./T16930.dump-cmm-cfg
./T16930.dump-cmm-cps
./T16930.dump-cmm-info
./T16930.dump-cmm-sp
./T16930.dump-cmm-switch
#
test('selfloop', [cmm_src], compile, [''])
test('T16930', normal, makefile_test, ['T16930'])
......@@ -9,13 +9,13 @@ debug:
# Without optimisations, we should get annotations for basically
# all expressions in the example program.
echo == Dbg ==
'$(TEST_HC)' $(TEST_HC_OPTS) debug -fforce-recomp -g -ddump-cmm-verbose \
'$(TEST_HC)' $(TEST_HC_OPTS) debug -fforce-recomp -g -ddump-cmm-verbose-by-proc \
| grep -o src\<debug.hs:.*\> | sort -u
./debug
# With optimisations we will get fewer annotations.
echo == Dbg -O2 ==
'$(TEST_HC)' $(TEST_HC_OPTS) debug -fforce-recomp -g -ddump-cmm-verbose -O2 \
'$(TEST_HC)' $(TEST_HC_OPTS) debug -fforce-recomp -g -ddump-cmm-verbose-by-proc -O2 \
> debug.cmm
cat debug.cmm | grep -o src\<debug.hs:.*\> | sort -u
......
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