[LLVMdev] Call graph printer/viewer

Speziale Ettore speziale.ettore at gmail.com
Thu Jan 10 08:04:07 PST 2013


Hi,

I would like viewing the call graph using opt. Right now this is
not possible. Indeed, to view the call graph one should tell
opt to dump it to a file and then open it with a DOT viewer.

So I started adding support for viewing the call graph from opt.
Basically, there are 2 alternatives:

1) If you are trying to print/view a graph that is a Function
   analysis, then exploit DOTGraphTraits{Viewer,Printer}
   * lib/Analysis/DomPrinter.cpp
   * lib/Analysis/RegionPrinter.cpp

2) Otherwise, use low-level interface {View,Write}Graph
   * lib/Analysis/CFGPrinter.cpp
     - View the graph, defines passes for viewing/printing

   * lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp
   * lib/CodeGen/ScheduleDAGPrinter.cpp
     - View the graph, no associate pass

   * lib/CodeGen/EdgeBundles.cpp
     - MachineFunction pass. Provide a member function to view the
       graph using a custom ViewGraph function because the default 
       implementation "it won't work"

   * lib/CodeGen/MachineFunction.cpp
     - Provide member function to see/print the MachineFunction as a 
       graph. Passes not available. I think because MachineFunctions
       can only be viewed/printed on debug builds

I chosen to follow the first alternative. However, it works only for
FunctionPass, while I need a ModulePass, so I defined
DOTGraphTraitsModule{Viewer,Printer} for handling Module viewer/helpers
and I exploited them for providing call graph viewer/printer.

Attached is the patch. In the case it is OK, maybe
DOTGraphTraits{Viewer,Printer} should be renamed in something like
DOTGraphTraitsFunction{Viewer,Printer} to point out that they handle
function-related graph viewing/printing.

Bye,
speziale.ettore at gmail.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: call-graph-refactor.diff
Type: text/x-patch
Size: 10155 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130110/4f1b8540/attachment.bin>


More information about the llvm-dev mailing list