Canonical way to visualize LLVM IR?

Hello,

LLVM provides several ways to visual IR structure straight in its core -
Function::viewCFG() to render control flow graph, then -view-* options
to llc to render various stages of transforming to machine code.
However, I wasn't able to find a way to render complete DAG
visualization of normal IR - which besides CFG would also show dataflow
(and other flows, if any). What people use to visualize such structure?

Thanks,
Paul mailto:pmiscml@gmail.com

Hi,

graph.dot.pdf (65.9 KB)

Hello,

For a project involving a tree data structure, we created a graph for
representing IR for further analysis. I attached an excerpt of such a
graph to give you an idea. If it helps, we will see how to proceed :wink:

Well, after grepping LLVM source for apparent lack of it and googling
for couple of apps which didn't bootstrap, I proceeded to write mine
either as a learning exercise, but I'm still not sure I do it the best
way or handle all cases (so far testing on trivial examples of course),
so if your app in open source, definitely would be nice to look at.

What I have on my hands so far: llvm dag — Postimages

Hi Paul,

Hi Paul,

Hi Paul,

Hello,

[...]

Well, after grepping LLVM source for apparent lack of it and googling
for couple of apps which didn't bootstrap, I proceeded to write mine
either as a learning exercise, but I'm still not sure I do it the best
way or handle all cases (so far testing on trivial examples of course),
so if your app in open source, definitely would be nice to look at.

Well, I think my code yet does not handle all cases either. Anyway, I'm
going to wrap things up (needs roughly a day) and then provide it via
GitHub. I'm going to send another mail with the projects link.

You can get the source from

    https://github.com/sdressler/KernelDataFlow

There are some flaws in the code:

- assert is not always used as it is intended to be, i.e. mostly its
within an if-statement and simply performs "assert(0)" with a preceding
error message.

- It can happen that not all instructions are handled. In such a case
you could extend it yourself or write me an email with the code that fails.

- If you are calling the pass from another directory than the one with
the source, don't forget to "mkdir graphs", otherwise subgraphs (which
are related to blocks) will not be generated.

If there are any further questions, don't hesitate to write me. The pass
is at a very early stage, but hopefully it gets some more quality when
someone else uses it.

Cheers,
Sebastian