O'Reilly logo

LLVM Cookbook by Suyog Sarda, Mayur Pandey

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Visualizing LLVM IR CFG using GraphViz

The LLVM IR control flow graph can be visualized using the GraphViz tool. It gives a visual depiction of the nodes formed and how the code flow follows in the IR generated. Since the important data structures in LLVM are graphs, this can be a very useful way to understand the IR flow when writing a custom pass or studying the behavior of the IR pattern.

Getting ready

  1. To install graphviz on Ubuntu, first add its ppa repository:
    $ sudo apt-add-repository ppa:dperry/ppa-graphviz-test
    
  2. Update the package repository:
    $ sudo apt-get update
    
  3. Install graphviz:
    $ sudo apt-get install graphviz
    

    Note

    If you get the graphviz : Depends: libgraphviz4 (>= 2.18) but it is not going to be installed error, run the following commands: ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required