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

Daniel Berlin via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 16 23:48:40 PDT 2016


Since i use the graph writing functionality a lot:

I presume you are talking about the usage of:
    O << "\tNode" << static_cast<const void*>(Node) << " [shape=record,";

when you are talking about the pointer requirement.

The pointer part is not necessary. It is just giving unique names to nodes.

IE, the output looks like this:
digraph "Dominator tree for 'sink_store' function" {
        label="Dominator tree for 'sink_store' function";

        Node0x7fe900410e30 [shape=record,label="{entry}"];
        Node0x7fe900410e30 -> Node0x7fe900410e60;
        Node0x7fe900410e30 -> Node0x7fe900410e90;
        Node0x7fe900410e30 -> Node0x7fe900410ec0;
        Node0x7fe900410e60 [shape=record,label="{if.then}"];
        Node0x7fe900410e90 [shape=record,label="{if.end}"];
        Node0x7fe900410ec0 [shape=record,label="{if.else}"];
}


The node name itself is not important, only that it is unique and
consistent.

For example, if graphtraits had an optional getUniqueNodeName that was
implemented for things that wanted to be printed out as graphs, you could
use that.

(sadly, uniquevector does not work with references, so you can't use it to
solve this problem).

--Dan


On Tue, Aug 16, 2016 at 8:42 PM, Tim Shen via llvm-commits <
llvm-commits at lists.llvm.org> 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.
>
>
> https://reviews.llvm.org/D23580
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160816/a713d39b/attachment.html>


More information about the llvm-commits mailing list