CodeGen: Way to dump cmm only once (#11717)
ClosedPublic

Authored by vTurbine on Jul 8 2016, 9:39 AM.

Details

Summary

The -ddump-cmm put all stages of Cmm processing into one output.
This patch changes its behavior and adds two more options to make
Cmm dumping flexible.

  • -ddump-cmm-from-stg dumps only initial version of Cmm right after STG->Cmm codegen
  • -ddump-cmm dumps the final result of the Cmm pipeline processing
  • -ddump-cmm-verbose dumps intermediate output of each Cmm pipeline step
  • -ddump-cmm-proc and -ddump-cmm-caf seems were lost. Now enabled
Test Plan

./validate

Diff Detail

Repository
rGHC Glasgow Haskell Compiler
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
vTurbine updated this revision to Diff 8160.Jul 8 2016, 9:39 AM
vTurbine retitled this revision from to CodeGen: Way to dump cmm only once (#11717).
vTurbine updated this object.
vTurbine edited the test plan for this revision. (Show Details)
vTurbine updated the Trac tickets for this revision.
vTurbine updated this object.Jul 8 2016, 10:16 AM
vTurbine edited edge metadata.
vTurbine updated this object.Jul 8 2016, 10:20 AM

Thanks for doing this.

What about user manual changes?

If I remember right, one of the issues was that the Cmm parts work one function at a time, so it's hard to produce a single dump for the whole program; stuff tends to come out interleaved. How are you handling that?

thomie requested changes to this revision.Jul 8 2016, 10:44 AM
thomie added a reviewer: thomie.

This looks ok, but it needs some documentation. See point 6 and 7 of https://ghc.haskell.org/trac/ghc/wiki/WorkingConventions/AddingFeatures#HowtocontributeanewfeaturetoGHC.

This revision now requires changes to proceed.Jul 8 2016, 10:44 AM

@simonpj , I didn't manage it completely. As you said, the only flag -ddump-cmm combined output from all phases. The sequence of Cmm transformations was:

StgCmm.codeGen [-ddump-cmm] -> cmmPipeline [-ddump-cmm] -> cmmToRawCmm [-ddump-cmm]

I added additional flags and changed meaning of the -ddump-cmm. Now we have:

StgCmm.codeGen [-ddump-cmm] -> cmmPipeline [-ddump-cmm-verbose] -> cmmToRawCmm [-ddump-cmm-out]

So now it's possible to get the Cmm from the codegen and at the end of the pipeline in separate files. Only cmmPipeline will produce a spaghetti.

Oh, I forgot about the docs. On my way..

Helpful clarification. Could you find a place to record that clarification, and little pictures as a Note somewhere, which you can refer to from the relevant part of the code?

simonmar requested changes to this revision.Jul 9 2016, 2:28 AM
simonmar edited edge metadata.
simonmar added inline comments.
compiler/cmm/CmmParse.y
1396–1397

I don't think this will come out with -ddump-cmm-verbose, will it?

compiler/cmm/CmmPipeline.hs
86

again, this will be missed by -ddump-cmm-verbose

107

Here too

thomie added inline comments.Jul 9 2016, 7:22 AM
compiler/cmm/CmmPipeline.hs
360–361

This comments need updating.

compiler/main/HscMain.hs
1340

parseCmmFile already called Opt_D_dump_cmm_parse, so this one is redundant.

vTurbine updated this revision to Diff 8167.Jul 9 2016, 7:33 AM
vTurbine edited edge metadata.
vTurbine updated this revision to Diff 8169.Jul 9 2016, 7:42 AM
vTurbine marked an inline comment as done.
vTurbine edited edge metadata.
  • T11717: comment updated
  • T11717: comment updated.. again
vTurbine updated this object.Jul 9 2016, 7:44 AM
vTurbine edited edge metadata.

I would slightly prefer to have -ddump-cmm print the final Cmm, rather like -ddump-simpl prints the final Core, and then have -ddump-cmm-from-stg or something to print the output of Stg->Cmm.

vTurbine updated this revision to Diff 8181.Jul 11 2016, 3:57 AM
vTurbine marked 4 inline comments as done.
  • T11717: Flags changed: -ddump-cmm -> -ddump-cmm-from-stg (codegen result) -ddump-cmm-out -> -ddump-cmm (the final Cmm);
vTurbine updated this object.Jul 11 2016, 4:02 AM
vTurbine edited edge metadata.
vTurbine updated this object.
thomie accepted this revision.Jul 11 2016, 4:16 AM
thomie edited edge metadata.

Thanks.

The new flags need to be mentioned in utils/mkUserGuidePart/Options/CompilerDebugging.hs as well (sorry for not alerting you earlier).

vTurbine updated this revision to Diff 8183.Jul 11 2016, 5:21 AM
vTurbine updated this object.
vTurbine edited edge metadata.
`CompilerDebugging.hs` updated
simonmar accepted this revision.Jul 12 2016, 8:09 AM
simonmar edited edge metadata.

Looks good, thanks!

compiler/main/HscMain.hs
1353

Personally I'd squash this Note to avoid duplicating information that's already in the User Guide, but it's up to you.

This revision is now accepted and ready to land.Jul 12 2016, 8:09 AM
simonpj added inline comments.Jul 12 2016, 9:44 AM
compiler/main/HscMain.hs
1353

Equally personally, I like it! It's saying quite bit more than the user manual does, I think, isn't it?

But do point to the user manual

vTurbine updated this revision to Diff 8195.Jul 12 2016, 10:03 AM
vTurbine edited edge metadata.

Redundant Note removed

Oh, I'd better update this wiki page

compiler/cmm/CmmParse.y
1396–1397

I removed the dumpIfSet_dyn here because it have a duplicate in hscCompileCmmFile from HscMain

This revision was automatically updated to reflect the committed changes.