The labels for nodes in DOT can be expressed using HTML syntax
which allows colour to be specified within the text. Add a
query to DefaultDOTGraphTraits defaulting to false that indicates
that the labels for nodes should be in HTML format. This is
a prerequisite change for a new IR change reporter that will
presented in a tutorial in the LLVM developer's conference in Oct, 2020
(see https://hotcrp.llvm.org/usllvm2020/paper/29 for more details).
Details
- Reviewers
bkramer madhur13490 george.karpenkov
Diff Detail
Event Timeline
I can't access the link in the description of the change. Moreover, I don't understand the purpose of making several calls to DTraits.renderNodeUsingHTML(Node). In its current form, the code queries just once and uses the value throughout the code, with your change you'd be calling several times. If this is a pre-requisite to some other change then I'd like to see that change so understand the whole picture. (Phabricator allows you to link revisions and even create a dependency FWIW.)
I think you have to be logged in to the llvm conference website to follow the link. The abstract is available on the conference website.
I originally queried DTraits once and saved the result but clang-tidy complained about it (without a useful message) so I changed it to call it multiple times, which satisfied clang-tidy. I personally prefer the previous code where it only queried it once...
I am in the process of contributing the code for several change printers that only report when a pass actually changes the IR and these changes are for the final change printer. Unfortunately, the commits are best presented in series, starting with https://reviews.llvm.org/D86360. They build on each other, so as changes from reviews are made to the first in the series, the changes bubble up the chain and I was afraid of a lot of churn in the PRs. I will post them and indicate the order and try to keep them current.
The changes in this PR, in particular, are for the final one in the chain of commits, but are independent, which is why I posted them separately. To give context of what they are for, I have created a change reporter which creates a small website with links for each pass that changes the IR. Each link shows the CFG in dot format (similar to -dot-cfg) except that instead of just showing the CFG with instructions, it shows the change that was made by the pass. The instructions that were added are shown in green, those that are deleted are shown in red and those that are common are shown in black. So, for example, if an optimization removes a basic block, the removed block, the arrow to it and the branch instruction to the removed block will be shown in red with the new arrow and branch instruction shown in green underneath the old branch (red) instruction. This greatly simplifies identifying and understanding changes made by a pass. In order to add the colour to the text showing the instructions, the DOT commands have to be in HTML-like format and the changes in this PR will put the output in HTML format under option control from DTraits.
These new options will be introduced in my tutorial "Understanding Changes made by a Pass in the Opt Pipeline." which will be given at the upcoming developers conference. I will be covering existing options (print-before/after-all, etc) and then presenting the new change printers and filters which only report when the pass actually changes the IR, in their various forms.
@madhur13490 I have added a PR https://reviews.llvm.org/D87202 that the contains the code that uses the changes in this PR (and marked this as a parent of it).
The changes in this PR have been incorporated into https://reviews.llvm.org/D87202 as they are easier to understand in the context of those changes.