[PATCH] D23580: [GraphWriter] Change GraphWriter to use NodeRef in GraphTraits

Daniel Berlin via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 17 11:08:11 PDT 2016


On Wed, Aug 17, 2016 at 11:00 AM, David Blaikie via llvm-commits <
llvm-commits at lists.llvm.org> wrote:

>
>
> On Tue, Aug 16, 2016 at 8:42 PM Tim Shen <timshen at google.com> wrote:
>
>> timshen added a comment.
>>
>> In https://reviews.llvm.org/D23580#517447, @dblaikie wrote:
>>
>> > what's the printer used for? Would it be best to generalize it (perhaps
>> adding another extension point to the graph traits, so NodeRefs can be
>> printed out - with a default implementation for pointers)?
>>
>>
>> One usage is to print dot files.
>>
>> I think it's more like that GraphWriter that requires the input nodes to
>> be both fulfilling GraphTraits, and printable, not that GraphTraits has an
>> optional printable requirement - these are two totally orthogonal traits.
>>
>
> Fair - though I'm not sure if it's too important whether that's expressed
> through graph traits or not. I guess maybe it's easier if it's separate.
>
> But, for example, for the heavy references you wanted to implement (that
> motivated all this refactoring) which, if I understand, are something like
> {node number, graph reference} - printing that out would be as simple as
> printing the node number. (or, if you wanted to be able to print multiple
> graphs and know they are distinct, it could print both elements of the
> heavy reference)
>
This is precisely right.


>
> Is there just the one graph algorithm that requires print support? If it's
> just one, I can understand not bothering to introduce another trait, etc
> (especially if only raw pointers are used with the one printing graph
> algorithm)
>

pretty much all of the graphs we have can be written, see view-cfg,
view-dom, etc.

There's basically *one graph writer*. It writes DOT files.
it already has DOTGraphTraits.

The pointer thing is what keeps this comment true:
 // Graphs do not need to implement any interface past what is already
required
 // by the GraphTraits template, but they can choose to implement
     specializations
 // of the DOTGraphTraits template if they want to customize the graphs
output   in
 // any way.


Truthfully, this pointer usage i pointed out should be moved to dot traits,
and removed from GraphWriter itself.

The default dot traits can require pointers, and use it to provide a unique
name,  you can override it for references.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160817/d68b4001/attachment.html>


More information about the llvm-commits mailing list