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
- To install
graphviz
on Ubuntu, first add itsppa
repository:$ sudo apt-add-repository ppa:dperry/ppa-graphviz-test
- Update the package repository:
$ sudo apt-get update
- 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: ...
Get LLVM Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.