... | ... | @@ -90,18 +90,67 @@ The core of the Cmm pipeline is implemented by the `cpsTop` function in [compile |
|
|
## Dumping and debugging Cmm
|
|
|
|
|
|
|
|
|
You can dump the generated Cmm code using `-ddump-cmm` flag. This is helpful for debugging Cmm problems. Cmm dump is divided into several sections:
|
|
|
You can dump all stages of Cmm processing. This is helpful for debugging Cmm problems.
|
|
|
|
|
|
|
|
|
Currently we have two ways to run the Cmm pipeline:
|
|
|
|
|
|
- The `.cmm` file passed as input
|
|
|
|
|
|
>
|
|
|
> Here we get into `hscCompileFile` and run the parser first. Ouput
|
|
|
> from the parser can be dumped via the `-ddump-cmm-verbose` flag:
|
|
|
|
|
|
```wiki
|
|
|
==================== Cmm produced by new codegen ====================
|
|
|
...
|
|
|
hscCompileFile
|
|
|
|-> parseCmmFile
|
|
|
|
|
|
|
(dump) [-ddump-cmm-verbose] "== Parsed Cmm =="
|
|
|
|
|
|
|
|-> cmmPipeline (..)
|
|
|
```
|
|
|
|
|
|
- The Haskell source passed as input
|
|
|
|
|
|
>
|
|
|
> The compiler reached the `HscRecomp` phase and started to produce
|
|
|
> hard code through the native codegen:
|
|
|
|
|
|
```wiki
|
|
|
hscGenHardCode
|
|
|
....
|
|
|
|-> doCodegen
|
|
|
. |-> StgCmm.codeGen
|
|
|
. |
|
|
|
. (dump) [-ddump-cmm-from-stg] "== Cmm produced by codegen =="
|
|
|
. |
|
|
|
. |-> cmmPipeline (..)
|
|
|
|
|
|
|
(dump) [-ddump-cmm] "== Output Cmm =="
|
|
|
|->cmmToRawCmm
|
|
|
|
|
|
|
(dump) [-ddump-cmm-raw] "== Raw Cmm =="
|
|
|
```
|
|
|
|
|
|
> *"Cmm produced by codegen"* is emited in `HscMain` module after converting STG to Cmm. This Cmm has not been processed in any way by the Cmm pipeline. If you see that something is incorrect in that dump it means that the problem is located in the STG-\>Cmm pass. The last section, *"Output Cmm"*, is also dumped in `HscMain` but this is done after the Cmm has been processed by the whole Cmm pipeline.
|
|
|
|
|
|
|
|
|
All stages of the Cmm pipeline can be dumped separately (with set of the cmm subflags) or together (when `-ddump-cmm-verbose` specified). Note, that there is still problem with output into file (see ToDo in `CmmPipeline.hs:dumpWith`).
|
|
|
This dump is divided into several sections:
|
|
|
|
|
|
```wiki
|
|
|
==================== Post control-flow optimisations ====================
|
|
|
...
|
|
|
|
|
|
==================== Post common block elimination ====================
|
|
|
...
|
|
|
|
|
|
==================== Post switch plan ====================
|
|
|
...
|
|
|
|
|
|
==================== Proc points ====================
|
|
|
...
|
|
|
|
|
|
==================== Layout Stack ====================
|
|
|
...
|
|
|
|
... | ... | @@ -111,6 +160,12 @@ You can dump the generated Cmm code using `-ddump-cmm` flag. This is helpful for |
|
|
==================== CAFEnv ====================
|
|
|
...
|
|
|
|
|
|
==================== procpoint map ====================
|
|
|
...
|
|
|
|
|
|
==================== Post splitting ====================
|
|
|
...
|
|
|
|
|
|
==================== after setInfoTableStackMap ====================
|
|
|
...
|
|
|
|
... | ... | @@ -119,10 +174,7 @@ You can dump the generated Cmm code using `-ddump-cmm` flag. This is helpful for |
|
|
|
|
|
==================== Post CPS Cmm ====================
|
|
|
...
|
|
|
|
|
|
==================== Output Cmm ====================
|
|
|
...
|
|
|
```
|
|
|
|
|
|
|
|
|
"Cmm produced by new codegen" is emited in `HscMain` module after converting STG to Cmm. This Cmm has not been processed in any way by the Cmm pipeline. If you see that something is incorrect in that dump it means that the problem is located in the STG-\>Cmm pass. The last section, "Output Cmm", is also dumped in `HscMain` but this is done after the Cmm has been processed by the whole Cmm pipeline. All other sections are dumped by the Cmm pipeline. You can dump only selected passes with more specific flags. For example, if you know (or suspect) that the sinking pass is performing some incorrect transformations you can make the dump shorter by adding `-ddump-cmm-sp -ddump-cmm-sink` flags. This will produce only the "Layout Stack" dump (just before sinking pass) and "Sink assignments" dump (just after the sinking pass) allowing you to focus on the changes introduced by the sinking pass. |
|
|
As was mentioned you can dump only selected passes with more specific flags. For example, if you know (or suspect) that the sinking pass is performing some incorrect transformations you can make the dump shorter by adding `-ddump-cmm-sp -ddump-cmm-sink` flags. This will produce only the "Layout Stack" dump (just before sinking pass) and "Sink assignments" dump (just after the sinking pass) allowing you to focus on the changes introduced by the sinking pass. |