[LLVMdev] [patch] Dotty printer for dependency trees

Tobias Grosser grosser at fim.uni-passau.de
Tue Jul 14 15:20:37 PDT 2009


Hi,

I started to work with llvm and liked the CFG dotty printer a lot.
However there was none for the dominance trees.

I implemented dotty printing for dominance trees and introduced these
new flags:

-dot-dom           : Print dominance tree of function to 'dot' file
-dot-dom-only      : Print dominance tree of function to 'dot' file 
                     (with no function bodies)
-dot-postdom       : Print postdominance tree of function to 'dot' file
-dot-postdom-only  : Print postdominance tree of function to 'dot' file
                     (with no function bodies)

-view-dom          : View dominance tree of function
-view-dom-only     : View dominance tree of function
                     (with no function bodies)
-view-postdom      : View postdominance tree of function
-view-postdom-only : View postdominance tree of function
                     (with no function bodies)

The patch contains these changes:

1. Move DOTGraphTraits<const Function*> to CFGPrinter.h to reuse it
later.

2. Add nodes_iterator to GraphTraits<DomTreeNode *>,
GraphTraits<DominatorTree*>, GraphTraits<PostDominatorTree*> to enable
the GraphWriter on these data structures.

3. The file DomPrinter.cpp containing the actual passes, printers & Co.
It is simple as almost everything already existed.

4. A little bug fix in lib/Analysis/CFGPrinter.cpp.

     virtual bool runOnFunction(Function &F) {
-      F.viewCFG();
+      F.viewCFGOnly();
       return false;

"opt -view-cfg-only" showed too much.

Any feedback is highly appreciated.

See you

Tobi






More information about the llvm-dev mailing list