Page MenuHomePhabricator

Add a new hidden option -dot-cfg-changes which creates a website of DOT files showing colourized changes as the IR is changed by passes in the new pass manager pipeline.
Needs ReviewPublic

Authored by jamieschmeiser on Sep 5 2020, 9:59 PM.

Details

Summary

Add a new hidden option -dot-cfg-changes which creates a website of
DOT files showing colourized changes as the IR is changed by passes
in the new pass manager pipeline.

A new change reporter is introduced that only reports when a pass actually
changes the IR. The hidden option -dot-cfg-changes=<dir> takes a directory
and in that directory a file passes.html will be created. This html
file contains a list of all the passes that act on the IR. Those that
do not change the IR are listed as omitted because of no change, ignored
or filtered out (using -filter-print-func and -filter-passes). Those that
do change the IR are listed as a link to a DOT file which contains a
CFG depiction of the IR (ala -dot-cfg) except that the instructions,
basic blocks and links that are only in the IR before the pass (ie, removed)
and those that are only in the IR after the pass (ie, added) are shown in
red and green, respectively, while the aspects of the CFG that do not change
are shown in black. Additional hidden options -before-color=<dot named
color>, -after-color=<dot named color> and -common-color=<dot named color>
are defined that allow the customization of the colors used in colorizing
the CFG.

This builds upon the template base classes introduced in
https://reviews.llvm.org/D86360 (landed) and expanded in
https://reviews.llvm.org/D87000 (under review). The changes to the GraphWriter in
https://reviews.llvm.org/D86362 have been incorporated into this PR as they are
difficult to understand in isolation and that PR will be cancelled.

Diff Detail

Event Timeline

jamieschmeiser created this revision.Sep 5 2020, 9:59 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 5 2020, 9:59 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
jamieschmeiser requested review of this revision.Sep 5 2020, 9:59 PM
madhur13490 added inline comments.Sep 8 2020, 1:43 AM
llvm/lib/IR/ChangeReporters.cpp
408 ↗(On Diff #290122)

I can be unsigned

705 ↗(On Diff #290122)

Doxygen comments can be on newlines.

707 ↗(On Diff #290122)

Is it worth filing a bug report for opt bug and refer it here?

779 ↗(On Diff #290122)

I can be unsigned.

795 ↗(On Diff #290122)

Can use shorthand operator.

805 ↗(On Diff #290122)

I think you can use C++ regex here. You can get rid of whole while loop and do the intended thing in one line.

830 ↗(On Diff #290122)

Is there any reason to use series of appends than just a single concatenation?

858 ↗(On Diff #290122)

"Before" and "After" can be more readble.

llvm/lib/Passes/StandardInstrumentations.cpp
1116

Please format the string in a readble way. Please use indentation and newlines just like you'd write in a HTML file.

Changed code to only open output stream when option is specified.

jamieschmeiser retitled this revision from Add a new hidden option -cfg-dot-changed which creates a website of DOT files showing colourized changes as the IR is changed by passes in the new pass manager pipeline. to Add a new hidden option -dot-cfg-changed which creates a website of DOT files showing colourized changes as the IR is changed by passes in the new pass manager pipeline..
jamieschmeiser edited the summary of this revision. (Show Details)

Change option name to dot-cfg-changed to align with existing dot-cfg pass.

jamieschmeiser retitled this revision from Add a new hidden option -dot-cfg-changed which creates a website of DOT files showing colourized changes as the IR is changed by passes in the new pass manager pipeline. to Add a new hidden option -dot-cfg-changes which creates a website of DOT files showing colourized changes as the IR is changed by passes in the new pass manager pipeline..

Change name to dot-cfg-changes as it is more similar to print-changes than to print-changed

jamieschmeiser edited the summary of this revision. (Show Details)

Respond to review comments: use regex, format HTML output to make it easier
to read, other changes.

Update PR based on changes to other PRs in chain, most notably: change
lambdas to virtual overrides.

Matt added a subscriber: Matt.Oct 5 2020, 12:18 PM

I will be updating this to reflect changes to PRs earlier in the chain.

jamieschmeiser edited the summary of this revision. (Show Details)

Update the code based on changes in the earlier PRs in the
chain. Also, the changes to the GraphWriter in
https://reviews.llvm.org/D86362 have been incorporated into this PR as they are
difficult to understand in isolation and that PR will be cancelled.

mamai added a subscriber: mamai.Dec 16 2020, 11:40 AM

A new quiet mode for change printers is being considered in https://reviews.llvm.org/D92589. I will likely have to change this patch based on the results of that, which would introduce a quiet mode into this change reporter also.

MaskRay added inline comments.
llvm/include/llvm/Passes/StandardInstrumentations.h
482

In header files, there is a namespace llvm {} so llvm:: can be omitted.

Can the using declarations be omitted?

llvm/include/llvm/Support/GraphWriter.h
269

Use lower case tags which are more common.